From 540a60fca7c68dab442d8e9cb51f1b8f6c7d3774 Mon Sep 17 00:00:00 2001 From: juanmanpr Date: Tue, 25 Feb 2014 00:29:07 +0100 Subject: [PATCH 1/2] Replaced calls to cout from photo module, by CV_Assert --- modules/photo/src/contrast_preserve.cpp | 12 +----------- modules/photo/src/seamless_cloning.cpp | 7 +------ 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/modules/photo/src/contrast_preserve.cpp b/modules/photo/src/contrast_preserve.cpp index 806afdf312..baafd6d4a8 100644 --- a/modules/photo/src/contrast_preserve.cpp +++ b/modules/photo/src/contrast_preserve.cpp @@ -45,7 +45,6 @@ #include "math.h" #include #include -#include #include "contrast_preserve.hpp" using namespace std; @@ -60,16 +59,7 @@ void cv::decolor(InputArray _src, OutputArray _dst, OutputArray _color_boost) _color_boost.create(I.size(), CV_8UC3); Mat color_boost = _color_boost.getMat(); - if(!I.data ) - { - cout << "Could not open or find the image" << endl ; - return; - } - if(I.channels() !=3) - { - cout << "Input Color Image" << endl; - return; - } + CV_Assert((I.data) && (I.channels()==3)); // Parameter Setting int maxIter = 15; diff --git a/modules/photo/src/seamless_cloning.cpp b/modules/photo/src/seamless_cloning.cpp index 63f4530477..9aece0f05e 100644 --- a/modules/photo/src/seamless_cloning.cpp +++ b/modules/photo/src/seamless_cloning.cpp @@ -41,7 +41,6 @@ #include "precomp.hpp" #include "opencv2/photo.hpp" -#include #include #include "seamless_cloning.hpp" @@ -93,11 +92,7 @@ void cv::seamlessClone(InputArray _src, InputArray _dst, InputArray _mask, Point int minyd = p.x - leny/2; int maxyd = p.x + leny/2; - if(minxd < 0 || minyd < 0 || maxxd > dest.size().height || maxyd > dest.size().width) - { - cout << "Index out of range" << endl; - exit(0); - } + CV_Assert((minxd<0) && (minyd<0) && (maxxd>dest.size().height) && (maxyd>dest.size().width)); Rect roi_d(minyd,minxd,leny,lenx); Rect roi_s(miny,minx,leny,lenx); From 7a68e3d20733d38cd726ad878d6ead77e8e19f31 Mon Sep 17 00:00:00 2001 From: juanmanpr Date: Tue, 25 Feb 2014 19:58:08 +0100 Subject: [PATCH 2/2] CV_Assert for photo module corrected --- modules/photo/src/contrast_preserve.cpp | 2 +- modules/photo/src/seamless_cloning.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/photo/src/contrast_preserve.cpp b/modules/photo/src/contrast_preserve.cpp index baafd6d4a8..55ea32189e 100644 --- a/modules/photo/src/contrast_preserve.cpp +++ b/modules/photo/src/contrast_preserve.cpp @@ -59,7 +59,7 @@ void cv::decolor(InputArray _src, OutputArray _dst, OutputArray _color_boost) _color_boost.create(I.size(), CV_8UC3); Mat color_boost = _color_boost.getMat(); - CV_Assert((I.data) && (I.channels()==3)); + CV_Assert(!I.empty() && (I.channels()==3)); // Parameter Setting int maxIter = 15; diff --git a/modules/photo/src/seamless_cloning.cpp b/modules/photo/src/seamless_cloning.cpp index 9aece0f05e..6ddadb3202 100644 --- a/modules/photo/src/seamless_cloning.cpp +++ b/modules/photo/src/seamless_cloning.cpp @@ -92,7 +92,7 @@ void cv::seamlessClone(InputArray _src, InputArray _dst, InputArray _mask, Point int minyd = p.x - leny/2; int maxyd = p.x + leny/2; - CV_Assert((minxd<0) && (minyd<0) && (maxxd>dest.size().height) && (maxyd>dest.size().width)); + CV_Assert(minxd >= 0 && minyd >= 0 && maxxd <= dest.rows && maxyd <= dest.cols); Rect roi_d(minyd,minxd,leny,lenx); Rect roi_s(miny,minx,leny,lenx);