@ -32,6 +32,10 @@ G_TYPED_KERNEL(PointIncrement, <GPointArray(GMat, GPointArray)>, "test.point_inc
{
static GArrayDesc outMeta ( const GMatDesc & , const GArrayDesc & ) { return empty_array_desc ( ) ; }
} ;
G_TYPED_KERNEL ( CountContours , < GOpaque < size_t > ( GArray < GPointArray > ) > , " test.array.array.in " )
{
static GOpaqueDesc outMeta ( const GArrayDesc & ) { return empty_gopaque_desc ( ) ; }
} ;
} // namespace ThisTest
namespace
@ -70,6 +74,14 @@ GAPI_OCV_KERNEL(OCVPointIncrement, ThisTest::PointIncrement)
}
} ;
GAPI_OCV_KERNEL ( OCVCountContours , ThisTest : : CountContours )
{
static void run ( const std : : vector < std : : vector < cv : : Point > > & contours , size_t & out )
{
out = contours . size ( ) ;
}
} ;
cv : : Mat cross ( int w , int h )
{
cv : : Mat mat = cv : : Mat : : eye ( h , w , CV_8UC1 ) * 255 ;
@ -177,6 +189,24 @@ TEST(GArray, TestIntermediateOutput)
EXPECT_EQ ( 10 , out_count [ 0 ] ) ;
}
TEST ( GArray , TestGArrayGArrayKernelInput )
{
cv : : GMat in ;
auto contours = cv : : gapi : : findContours ( in , cv : : RETR_EXTERNAL , cv : : CHAIN_APPROX_NONE ) ;
auto out = ThisTest : : CountContours : : on ( contours ) ;
cv : : GComputation c ( GIn ( in ) , GOut ( out ) ) ;
// Create input - two filled rectangles
cv : : Mat in_mat = cv : : Mat : : zeros ( 50 , 50 , CV_8UC1 ) ;
cv : : rectangle ( in_mat , cv : : Point { 5 , 5 } , cv : : Point { 20 , 20 } , 255 , cv : : FILLED ) ;
cv : : rectangle ( in_mat , cv : : Point { 25 , 25 } , cv : : Point { 40 , 40 } , 255 , cv : : FILLED ) ;
size_t out_count = 0u ;
c . apply ( gin ( in_mat ) , gout ( out_count ) , cv : : compile_args ( cv : : gapi : : kernels < OCVCountContours > ( ) ) ) ;
EXPECT_EQ ( 2u , out_count ) < < " Two contours must be found " ;
}
TEST ( GArray , GArrayConstValInitialization )
{
std : : vector < cv : : Point > initial_vec { Point ( 0 , 0 ) , Point ( 1 , 1 ) , Point ( 2 , 2 ) } ;