optimized some gpu::cvtColor functions

This commit is contained in:
Vladislav Vinogradov 2011-08-22 11:07:52 +00:00
parent 628447c251
commit 0ed6d86a49
3 changed files with 1539 additions and 190 deletions

View File

@ -53,6 +53,173 @@ namespace cv { namespace gpu { namespace device
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<bgra_to_bgr555_traits::functor_type> : DefaultTransformFunctorTraits<bgra_to_bgr555_traits::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<rgba_to_bgr555_traits::functor_type> : DefaultTransformFunctorTraits<rgba_to_bgr555_traits::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<bgra_to_bgr565_traits::functor_type> : DefaultTransformFunctorTraits<bgra_to_bgr565_traits::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<rgba_to_bgr565_traits::functor_type> : DefaultTransformFunctorTraits<rgba_to_bgr565_traits::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<bgr555_to_bgra_traits::functor_type> : DefaultTransformFunctorTraits<bgr555_to_bgra_traits::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<bgr555_to_rgba_traits::functor_type> : DefaultTransformFunctorTraits<bgr555_to_rgba_traits::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<bgr565_to_bgra_traits::functor_type> : DefaultTransformFunctorTraits<bgr565_to_bgra_traits::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<bgr565_to_rgba_traits::functor_type> : DefaultTransformFunctorTraits<bgr565_to_rgba_traits::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<gray_to_bgra_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<gray_to_bgra_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<gray_to_bgr555_traits::functor_type> : DefaultTransformFunctorTraits<gray_to_bgr555_traits::functor_type>
{
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<gray_to_bgr565_traits::functor_type> : DefaultTransformFunctorTraits<gray_to_bgr565_traits::functor_type>
{
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<bgra_to_yuv4_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<bgra_to_yuv4_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<rgba_to_yuv4_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<rgba_to_yuv4_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<yuv4_to_bgra_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<yuv4_to_bgra_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<yuv4_to_rgba_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<yuv4_to_rgba_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<bgra_to_YCrCb4_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<bgra_to_YCrCb4_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<rgba_to_YCrCb4_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<rgba_to_YCrCb4_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<YCrCb4_to_bgra_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<YCrCb4_to_bgra_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<YCrCb4_to_rgba_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<YCrCb4_to_rgba_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<bgra_to_xyz4_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<bgra_to_xyz4_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<rgba_to_xyz4_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<rgba_to_xyz4_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<xyz4_to_bgra_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<xyz4_to_bgra_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<xyz4_to_rgba_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<xyz4_to_rgba_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<bgra_to_hsv4_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<bgra_to_hsv4_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<rgba_to_hsv4_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<rgba_to_hsv4_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<hsv4_to_bgra_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<hsv4_to_bgra_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<hsv4_to_rgba_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<hsv4_to_rgba_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<bgra_to_hls4_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<bgra_to_hls4_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<rgba_to_hls4_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<rgba_to_hls4_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<hls4_to_bgra_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<hls4_to_bgra_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
template <> struct TransformFunctorTraits<hls4_to_rgba_traits<uchar>::functor_type> : DefaultTransformFunctorTraits<hls4_to_rgba_traits<uchar>::functor_type>
{
enum { smart_block_dim_y = 8 };
enum { smart_shift = 4 };
};
#define OPENCV_GPU_IMPLEMENT_CVTCOLOR(name, traits) \
void name(const DevMem2D& src, const DevMem2D& dst, cudaStream_t stream) \
{ \

File diff suppressed because it is too large Load Diff

View File

@ -1352,6 +1352,63 @@ TEST_P(CvtColor, RGB2XYZ)
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
}
TEST_P(CvtColor, BGR2XYZ4)
{
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src = img;
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_BGR2XYZ);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_BGR2XYZ, 4);
gpuRes.download(dst);
);
ASSERT_EQ(4, dst.channels());
cv::Mat channels[4];
cv::split(dst, channels);
cv::merge(channels, 3, dst);
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
}
TEST_P(CvtColor, BGRA2XYZ4)
{
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2BGRA);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_BGR2XYZ);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_BGR2XYZ, 4);
gpuRes.download(dst);
);
ASSERT_EQ(4, dst.channels());
cv::Mat channels[4];
cv::split(dst, channels);
cv::merge(channels, 3, dst);
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
}
TEST_P(CvtColor, XYZ2BGR)
{
PRINT_PARAM(devInfo);
@ -1398,6 +1455,62 @@ TEST_P(CvtColor, XYZ2RGB)
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
}
TEST_P(CvtColor, XYZ42BGR)
{
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2XYZ);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_XYZ2BGR);
cv::Mat channels[4];
cv::split(src, channels);
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
cv::merge(channels, 4, src);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_XYZ2BGR);
gpuRes.download(dst);
);
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
}
TEST_P(CvtColor, XYZ42BGRA)
{
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2XYZ);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_XYZ2BGR, 4);
cv::Mat channels[4];
cv::split(src, channels);
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
cv::merge(channels, 4, src);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_XYZ2BGR, 4);
gpuRes.download(dst);
);
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
}
TEST_P(CvtColor, BGR2YCrCb)
{
PRINT_PARAM(devInfo);
@ -1443,6 +1556,63 @@ TEST_P(CvtColor, RGB2YCrCb)
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
}
TEST_P(CvtColor, BGR2YCrCb4)
{
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src = img;
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_BGR2YCrCb);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_BGR2YCrCb, 4);
gpuRes.download(dst);
);
ASSERT_EQ(4, dst.channels());
cv::Mat channels[4];
cv::split(dst, channels);
cv::merge(channels, 3, dst);
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
}
TEST_P(CvtColor, RGBA2YCrCb4)
{
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2RGBA);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_BGR2YCrCb);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_BGR2YCrCb, 4);
gpuRes.download(dst);
);
ASSERT_EQ(4, dst.channels());
cv::Mat channels[4];
cv::split(dst, channels);
cv::merge(channels, 3, dst);
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
}
TEST_P(CvtColor, YCrCb2BGR)
{
PRINT_PARAM(devInfo);
@ -1489,6 +1659,62 @@ TEST_P(CvtColor, YCrCb2RGB)
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
}
TEST_P(CvtColor, YCrCb42RGB)
{
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2YCrCb);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_YCrCb2RGB);
cv::Mat channels[4];
cv::split(src, channels);
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
cv::merge(channels, 4, src);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_YCrCb2RGB);
gpuRes.download(dst);
);
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
}
TEST_P(CvtColor, YCrCb42RGBA)
{
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2YCrCb);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_YCrCb2RGB, 4);
cv::Mat channels[4];
cv::split(src, channels);
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
cv::merge(channels, 4, src);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_YCrCb2RGB, 4);
gpuRes.download(dst);
);
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
}
TEST_P(CvtColor, BGR2HSV)
{
if (type == CV_16U)
@ -1540,6 +1766,70 @@ TEST_P(CvtColor, RGB2HSV)
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, RGB2HSV4)
{
if (type == CV_16U)
return;
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2RGB);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_RGB2HSV);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_RGB2HSV, 4);
gpuRes.download(dst);
);
ASSERT_EQ(4, dst.channels());
cv::Mat channels[4];
cv::split(dst, channels);
cv::merge(channels, 3, dst);
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, RGBA2HSV4)
{
if (type == CV_16U)
return;
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2RGBA);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_RGB2HSV);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_RGB2HSV, 4);
gpuRes.download(dst);
);
ASSERT_EQ(4, dst.channels());
cv::Mat channels[4];
cv::split(dst, channels);
cv::merge(channels, 3, dst);
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, BGR2HLS)
{
if (type == CV_16U)
@ -1591,6 +1881,70 @@ TEST_P(CvtColor, RGB2HLS)
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, RGB2HLS4)
{
if (type == CV_16U)
return;
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2RGB);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_RGB2HLS);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_RGB2HLS, 4);
gpuRes.download(dst);
);
ASSERT_EQ(4, dst.channels());
cv::Mat channels[4];
cv::split(dst, channels);
cv::merge(channels, 3, dst);
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, RGBA2HLS4)
{
if (type == CV_16U)
return;
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2RGBA);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_RGB2HLS);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_RGB2HLS, 4);
gpuRes.download(dst);
);
ASSERT_EQ(4, dst.channels());
cv::Mat channels[4];
cv::split(dst, channels);
cv::merge(channels, 3, dst);
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, HSV2BGR)
{
if (type == CV_16U)
@ -1643,6 +1997,68 @@ TEST_P(CvtColor, HSV2RGB)
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, HSV42BGR)
{
if (type == CV_16U)
return;
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2HSV);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_HSV2BGR);
cv::Mat channels[4];
cv::split(src, channels);
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
cv::merge(channels, 4, src);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_HSV2BGR);
gpuRes.download(dst);
);
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, HSV42BGRA)
{
if (type == CV_16U)
return;
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2HSV);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_HSV2BGR, 4);
cv::Mat channels[4];
cv::split(src, channels);
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
cv::merge(channels, 4, src);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_HSV2BGR, 4);
gpuRes.download(dst);
);
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, HLS2BGR)
{
if (type == CV_16U)
@ -1695,6 +2111,68 @@ TEST_P(CvtColor, HLS2RGB)
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, HLS42RGB)
{
if (type == CV_16U)
return;
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2HLS);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_HLS2RGB);
cv::Mat channels[4];
cv::split(src, channels);
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
cv::merge(channels, 4, src);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_HLS2RGB);
gpuRes.download(dst);
);
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, HLS42RGBA)
{
if (type == CV_16U)
return;
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2HLS);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_HLS2RGB, 4);
cv::Mat channels[4];
cv::split(src, channels);
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
cv::merge(channels, 4, src);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_HLS2RGB, 4);
gpuRes.download(dst);
);
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, BGR2HSV_FULL)
{
if (type == CV_16U)
@ -1746,6 +2224,70 @@ TEST_P(CvtColor, RGB2HSV_FULL)
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, RGB2HSV4_FULL)
{
if (type == CV_16U)
return;
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2RGB);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_RGB2HSV_FULL);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_RGB2HSV_FULL, 4);
gpuRes.download(dst);
);
ASSERT_EQ(4, dst.channels());
cv::Mat channels[4];
cv::split(dst, channels);
cv::merge(channels, 3, dst);
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, RGBA2HSV4_FULL)
{
if (type == CV_16U)
return;
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2RGBA);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_RGB2HSV_FULL);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_RGB2HSV_FULL, 4);
gpuRes.download(dst);
);
ASSERT_EQ(4, dst.channels());
cv::Mat channels[4];
cv::split(dst, channels);
cv::merge(channels, 3, dst);
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, BGR2HLS_FULL)
{
if (type == CV_16U)
@ -1797,6 +2339,70 @@ TEST_P(CvtColor, RGB2HLS_FULL)
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, RGB2HLS4_FULL)
{
if (type == CV_16U)
return;
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2RGB);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_RGB2HLS_FULL);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_RGB2HLS_FULL, 4);
gpuRes.download(dst);
);
ASSERT_EQ(4, dst.channels());
cv::Mat channels[4];
cv::split(dst, channels);
cv::merge(channels, 3, dst);
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, RGBA2HLS4_FULL)
{
if (type == CV_16U)
return;
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2RGBA);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_RGB2HLS_FULL);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_RGB2HLS_FULL, 4);
gpuRes.download(dst);
);
ASSERT_EQ(4, dst.channels());
cv::Mat channels[4];
cv::split(dst, channels);
cv::merge(channels, 3, dst);
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, HSV2BGR_FULL)
{
if (type == CV_16U)
@ -1849,6 +2455,68 @@ TEST_P(CvtColor, HSV2RGB_FULL)
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, HSV42RGB_FULL)
{
if (type == CV_16U)
return;
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2HSV_FULL);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_HSV2RGB_FULL);
cv::Mat channels[4];
cv::split(src, channels);
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
cv::merge(channels, 4, src);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_HSV2RGB_FULL);
gpuRes.download(dst);
);
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, HSV42RGBA_FULL)
{
if (type == CV_16U)
return;
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2HSV_FULL);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_HSV2RGB_FULL, 4);
cv::Mat channels[4];
cv::split(src, channels);
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
cv::merge(channels, 4, src);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_HSV2RGB_FULL, 4);
gpuRes.download(dst);
);
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, HLS2BGR_FULL)
{
if (type == CV_16U)
@ -1901,6 +2569,68 @@ TEST_P(CvtColor, HLS2RGB_FULL)
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, HLS42RGB_FULL)
{
if (type == CV_16U)
return;
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2HLS_FULL);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_HLS2RGB_FULL);
cv::Mat channels[4];
cv::split(src, channels);
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
cv::merge(channels, 4, src);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_HLS2RGB_FULL);
gpuRes.download(dst);
);
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, HLS42RGBA_FULL)
{
if (type == CV_16U)
return;
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2HLS_FULL);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_HLS2RGB_FULL, 4);
cv::Mat channels[4];
cv::split(src, channels);
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
cv::merge(channels, 4, src);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_HLS2RGB_FULL, 4);
gpuRes.download(dst);
);
EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
}
TEST_P(CvtColor, BGR2YUV)
{
PRINT_PARAM(devInfo);
@ -1969,6 +2699,62 @@ TEST_P(CvtColor, YUV2BGR)
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
}
TEST_P(CvtColor, YUV42BGR)
{
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2YUV);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_YUV2BGR);
cv::Mat channels[4];
cv::split(src, channels);
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
cv::merge(channels, 4, src);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_YUV2BGR);
gpuRes.download(dst);
);
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
}
TEST_P(CvtColor, YUV42BGRA)
{
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2YUV);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_YUV2BGR, 4);
cv::Mat channels[4];
cv::split(src, channels);
channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
cv::merge(channels, 4, src);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_YUV2BGR, 4);
gpuRes.download(dst);
);
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
}
TEST_P(CvtColor, YUV2RGB)
{
PRINT_PARAM(devInfo);
@ -1992,6 +2778,63 @@ TEST_P(CvtColor, YUV2RGB)
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
}
TEST_P(CvtColor, BGR2YUV4)
{
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src = img;
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_BGR2YUV);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_BGR2YUV, 4);
gpuRes.download(dst);
);
ASSERT_EQ(4, dst.channels());
cv::Mat channels[4];
cv::split(dst, channels);
cv::merge(channels, 3, dst);
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
}
TEST_P(CvtColor, RGBA2YUV4)
{
PRINT_PARAM(devInfo);
PRINT_TYPE(type);
cv::Mat src;
cv::cvtColor(img, src, CV_BGR2RGBA);
cv::Mat dst_gold;
cv::cvtColor(src, dst_gold, CV_RGB2YUV);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes;
cv::gpu::cvtColor(cv::gpu::GpuMat(src), gpuRes, CV_RGB2YUV, 4);
gpuRes.download(dst);
);
ASSERT_EQ(4, dst.channels());
cv::Mat channels[4];
cv::split(dst, channels);
cv::merge(channels, 3, dst);
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
}
INSTANTIATE_TEST_CASE_P(ImgProc, CvtColor, testing::Combine(
testing::ValuesIn(devices()),
testing::Values(CV_8U, CV_16U, CV_32F)));