From: Vadim Pisarevsky Date: Tue, 9 Oct 2012 18:38:04 +0000 (+0400) Subject: expanded cv::threshold parallelization to other threading frameworks; fixed potential... X-Git-Tag: accepted/2.0/20130307.220821~364^2~83 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=044d38a051703b96525027474c2a7e3de7c85025;p=profile%2Fivi%2Fopencv.git expanded cv::threshold parallelization to other threading frameworks; fixed potential bug with unprocessed bottom of the image; fixed build problem in stitching --- diff --git a/modules/imgproc/src/thresh.cpp b/modules/imgproc/src/thresh.cpp index 1fb4847..06bd02a 100644 --- a/modules/imgproc/src/thresh.cpp +++ b/modules/imgproc/src/thresh.cpp @@ -661,7 +661,7 @@ getThreshVal_Otsu_8u( const Mat& _src ) return max_val; } -class ThresholdRunner +class ThresholdRunner : public ParallelLoopBody { public: ThresholdRunner(Mat _src, Mat _dst, int _nStripes, double _thresh, double _maxval, int _thresholdType) @@ -676,10 +676,11 @@ public: thresholdType = _thresholdType; } - void operator () ( const BlockedRange& range ) const + void operator () ( const Range& range ) const { - int row0 = std::min(cvRound(range.begin() * src.rows / nStripes), src.rows); - int row1 = std::min(cvRound(range.end() * src.rows / nStripes), src.rows); + int row0 = std::min(cvRound(range.start * src.rows / nStripes), src.rows); + int row1 = range.end >= nStripes ? src.rows : + std::min(cvRound(range.end * src.rows / nStripes), src.rows); /*if(0) printf("Size = (%d, %d), range[%d,%d), row0 = %d, row1 = %d\n", @@ -756,12 +757,10 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m } else src.copyTo(dst); + return thresh; } - else - { - parallel_for(BlockedRange(0, nStripes), - ThresholdRunner(src, dst, nStripes, (uchar)ithresh, (uchar)imaxval, type)); - } + thresh = ithresh; + maxval = imaxval; } else if( src.depth() == CV_16S ) { @@ -785,21 +784,18 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m } else src.copyTo(dst); + return thresh; } - else - { - parallel_for(BlockedRange(0, nStripes), - ThresholdRunner(src, dst, nStripes, (short)ithresh, (short)imaxval, type)); - } + thresh = ithresh; + maxval = imaxval; } else if( src.depth() == CV_32F ) - { - parallel_for(BlockedRange(0, nStripes), - ThresholdRunner(src, dst, nStripes, (float)thresh, (float)maxval, type)); - } + ; else CV_Error( CV_StsUnsupportedFormat, "" ); - + + parallel_for_(Range(0, nStripes), + ThresholdRunner(src, dst, nStripes, thresh, maxval, type)); return thresh; } diff --git a/samples/cpp/stitching_detailed.cpp b/samples/cpp/stitching_detailed.cpp index 1e46117..cbd050d 100644 --- a/samples/cpp/stitching_detailed.cpp +++ b/samples/cpp/stitching_detailed.cpp @@ -41,6 +41,7 @@ // //M*/ +#include #include #include #include "opencv2/opencv_modules.hpp"