From 14ee306b9ec7c4dcd09014b8480d85a955c7706f Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Tue, 3 Dec 2013 15:55:10 +0400 Subject: [PATCH 1/2] fix gpu test for Demosaicing: check that input images was loaded correctly --- modules/gpu/test/test_color.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/gpu/test/test_color.cpp b/modules/gpu/test/test_color.cpp index 4bd53c919..3f5a37fd0 100644 --- a/modules/gpu/test/test_color.cpp +++ b/modules/gpu/test/test_color.cpp @@ -2357,6 +2357,7 @@ struct Demosaicing : testing::TestWithParam GPU_TEST_P(Demosaicing, BayerBG2BGR) { cv::Mat img = readImage("stereobm/aloe-L.png"); + ASSERT_FALSE(img.empty()) << "Can't load input image"; cv::Mat_ src; mosaic(img, src, cv::Point(1, 1)); @@ -2370,6 +2371,7 @@ GPU_TEST_P(Demosaicing, BayerBG2BGR) GPU_TEST_P(Demosaicing, BayerGB2BGR) { cv::Mat img = readImage("stereobm/aloe-L.png"); + ASSERT_FALSE(img.empty()) << "Can't load input image"; cv::Mat_ src; mosaic(img, src, cv::Point(0, 1)); @@ -2383,6 +2385,7 @@ GPU_TEST_P(Demosaicing, BayerGB2BGR) GPU_TEST_P(Demosaicing, BayerRG2BGR) { cv::Mat img = readImage("stereobm/aloe-L.png"); + ASSERT_FALSE(img.empty()) << "Can't load input image"; cv::Mat_ src; mosaic(img, src, cv::Point(0, 0)); @@ -2396,6 +2399,7 @@ GPU_TEST_P(Demosaicing, BayerRG2BGR) GPU_TEST_P(Demosaicing, BayerGR2BGR) { cv::Mat img = readImage("stereobm/aloe-L.png"); + ASSERT_FALSE(img.empty()) << "Can't load input image"; cv::Mat_ src; mosaic(img, src, cv::Point(1, 0)); @@ -2409,6 +2413,7 @@ GPU_TEST_P(Demosaicing, BayerGR2BGR) GPU_TEST_P(Demosaicing, BayerBG2BGR_MHT) { cv::Mat img = readImage("stereobm/aloe-L.png"); + ASSERT_FALSE(img.empty()) << "Can't load input image"; cv::Mat_ src; mosaic(img, src, cv::Point(1, 1)); @@ -2422,6 +2427,7 @@ GPU_TEST_P(Demosaicing, BayerBG2BGR_MHT) GPU_TEST_P(Demosaicing, BayerGB2BGR_MHT) { cv::Mat img = readImage("stereobm/aloe-L.png"); + ASSERT_FALSE(img.empty()) << "Can't load input image"; cv::Mat_ src; mosaic(img, src, cv::Point(0, 1)); @@ -2435,6 +2441,7 @@ GPU_TEST_P(Demosaicing, BayerGB2BGR_MHT) GPU_TEST_P(Demosaicing, BayerRG2BGR_MHT) { cv::Mat img = readImage("stereobm/aloe-L.png"); + ASSERT_FALSE(img.empty()) << "Can't load input image"; cv::Mat_ src; mosaic(img, src, cv::Point(0, 0)); @@ -2448,6 +2455,7 @@ GPU_TEST_P(Demosaicing, BayerRG2BGR_MHT) GPU_TEST_P(Demosaicing, BayerGR2BGR_MHT) { cv::Mat img = readImage("stereobm/aloe-L.png"); + ASSERT_FALSE(img.empty()) << "Can't load input image"; cv::Mat_ src; mosaic(img, src, cv::Point(1, 0)); From adb2040980e61a4bf76675c163c0ada20809a7e2 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Tue, 3 Dec 2013 15:55:47 +0400 Subject: [PATCH 2/2] added additional check in cv::gpu::demosaicing that source is not empty --- modules/gpu/src/color.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gpu/src/color.cpp b/modules/gpu/src/color.cpp index 76793d520..864c4755e 100644 --- a/modules/gpu/src/color.cpp +++ b/modules/gpu/src/color.cpp @@ -1863,7 +1863,7 @@ void cv::gpu::demosaicing(const GpuMat& src, GpuMat& dst, int code, int dcn, Str { const int depth = src.depth(); - CV_Assert( src.channels() == 1 ); + CV_Assert( src.channels() == 1 && !src.empty() ); switch (code) {