@@ -539,17 +539,18 @@ void CCheckerDetectorImpl::
539
539
// number of window sizes (scales) to apply adaptive thresholding
540
540
int nScales = (params->adaptiveThreshWinSizeMax - params->adaptiveThreshWinSizeMin ) / params->adaptiveThreshWinSizeStep + 1 ;
541
541
thresholdImgs.create (nScales, 1 , CV_8U);
542
- std::vector<cv::Mat> _thresholdImgs;
543
- for (int i = 0 ; i < nScales; i++)
544
- {
545
- int currScale = params->adaptiveThreshWinSizeMin + i * params->adaptiveThreshWinSizeStep ;
546
-
547
- cv::Mat tempThresholdImg;
548
- cv::adaptiveThreshold (grayscaleImg, tempThresholdImg, 255 , cv::ADAPTIVE_THRESH_MEAN_C,
549
- cv::THRESH_BINARY_INV, currScale, params->adaptiveThreshConstant );
550
-
551
- _thresholdImgs.push_back (tempThresholdImg);
552
- }
542
+ std::vector<cv::Mat> _thresholdImgs (nScales);
543
+ parallel_for_ (Range (0 , nScales),[&](const Range& range) {
544
+ const int start = range.start ;
545
+ const int end = range.end ;
546
+ for (int i = start; i < end; i++) {
547
+ int currScale = params->adaptiveThreshWinSizeMin + i * params->adaptiveThreshWinSizeStep ;
548
+ cv::Mat tempThresholdImg;
549
+ cv::adaptiveThreshold (grayscaleImg, tempThresholdImg, 255 , ADAPTIVE_THRESH_MEAN_C,
550
+ THRESH_BINARY_INV, currScale, params->adaptiveThreshConstant );
551
+ _thresholdImgs[i] = tempThresholdImg;
552
+ }
553
+ });
553
554
554
555
thresholdImgs.assign (_thresholdImgs);
555
556
}
0 commit comments