@ -489,6 +489,80 @@ TEST_P(NV12toBGRTest, AccuracyTest)
}
}
static void toPlanar ( const cv : : Mat & in , cv : : Mat & out )
{
GAPI_Assert ( out . depth ( ) = = in . depth ( ) ) ;
GAPI_Assert ( out . channels ( ) = = 1 ) ;
GAPI_Assert ( in . channels ( ) = = 3 ) ;
GAPI_Assert ( out . cols = = in . cols ) ;
GAPI_Assert ( out . rows = = 3 * in . rows ) ;
std : : vector < cv : : Mat > outs ( 3 ) ;
for ( int i = 0 ; i < 3 ; i + + ) {
outs [ i ] = out ( cv : : Rect ( 0 , i * in . rows , in . cols , in . rows ) ) ;
}
cv : : split ( in , outs ) ;
}
TEST_P ( NV12toRGBpTest , AccuracyTest )
{
cv : : Size sz_p = cv : : Size ( sz . width , sz . height * 3 ) ;
// G-API code //////////////////////////////////////////////////////////////
cv : : GMat in_y ;
cv : : GMat in_uv ;
auto out = cv : : gapi : : NV12toRGBp ( in_y , in_uv ) ;
// Additional mat for uv
cv : : Mat in_mat_uv ( cv : : Size ( sz . width / 2 , sz . height / 2 ) , CV_8UC2 ) ;
cv : : randn ( in_mat_uv , cv : : Scalar : : all ( 127 ) , cv : : Scalar : : all ( 40.f ) ) ;
cv : : GComputation c ( cv : : GIn ( in_y , in_uv ) , cv : : GOut ( out ) ) ;
cv : : Mat out_mat_gapi_planar ( cv : : Size ( sz . width , sz . height * 3 ) , CV_8UC1 ) ;
c . apply ( cv : : gin ( in_mat1 , in_mat_uv ) , cv : : gout ( out_mat_gapi_planar ) , getCompileArgs ( ) ) ;
// OpenCV code /////////////////////////////////////////////////////////////
cv : : Mat out_mat_ocv_planar ( cv : : Size ( sz . width , sz . height * 3 ) , CV_8UC1 ) ;
{
cv : : cvtColorTwoPlane ( in_mat1 , in_mat_uv , out_mat_ocv , cv : : COLOR_YUV2RGB_NV12 ) ;
toPlanar ( out_mat_ocv , out_mat_ocv_planar ) ;
}
// Comparison //////////////////////////////////////////////////////////////
{
EXPECT_TRUE ( cmpF ( out_mat_gapi_planar , out_mat_ocv_planar ) ) ;
EXPECT_EQ ( out_mat_gapi_planar . size ( ) , sz_p ) ;
}
}
TEST_P ( NV12toBGRpTest , AccuracyTest )
{
cv : : Size sz_p = cv : : Size ( sz . width , sz . height * 3 ) ;
// G-API code //////////////////////////////////////////////////////////////
cv : : GMat in_y ;
cv : : GMat in_uv ;
auto out = cv : : gapi : : NV12toBGRp ( in_y , in_uv ) ;
// Additional mat for uv
cv : : Mat in_mat_uv ( cv : : Size ( sz . width / 2 , sz . height / 2 ) , CV_8UC2 ) ;
cv : : randn ( in_mat_uv , cv : : Scalar : : all ( 127 ) , cv : : Scalar : : all ( 40.f ) ) ;
cv : : GComputation c ( cv : : GIn ( in_y , in_uv ) , cv : : GOut ( out ) ) ;
cv : : Mat out_mat_gapi_planar ( cv : : Size ( sz . width , sz . height * 3 ) , CV_8UC1 ) ;
c . apply ( cv : : gin ( in_mat1 , in_mat_uv ) , cv : : gout ( out_mat_gapi_planar ) , getCompileArgs ( ) ) ;
// OpenCV code /////////////////////////////////////////////////////////////
cv : : Mat out_mat_ocv_planar ( cv : : Size ( sz . width , sz . height * 3 ) , CV_8UC1 ) ;
{
cv : : cvtColorTwoPlane ( in_mat1 , in_mat_uv , out_mat_ocv , cv : : COLOR_YUV2BGR_NV12 ) ;
toPlanar ( out_mat_ocv , out_mat_ocv_planar ) ;
}
// Comparison //////////////////////////////////////////////////////////////
{
EXPECT_TRUE ( cmpF ( out_mat_gapi_planar , out_mat_ocv_planar ) ) ;
EXPECT_EQ ( out_mat_gapi_planar . size ( ) , sz_p ) ;
}
}
TEST_P ( RGB2LabTest , AccuracyTest )
{
// G-API code //////////////////////////////////////////////////////////////