@@ -40,8 +40,6 @@ namespace cv
4040namespace mcc
4141{
4242
43- std::mutex mtx; // mutex for critical section
44-
4543Ptr<CCheckerDetector> CCheckerDetector::create ()
4644{
4745 return makePtr<CCheckerDetectorImpl>();
@@ -113,7 +111,7 @@ bool CCheckerDetectorImpl::
113111 // Get chanels
114112 split (img_rgb_org, rgb_planes);
115113 split (img_ycbcr_org, ycbcr_planes);
116-
114+ cv::Mutex mtx;
117115 parallel_for_ (
118116 Range (0 , (int )img_bw.size ()), [&](const Range &range) {
119117 const int begin = range.start ;
@@ -237,9 +235,10 @@ bool CCheckerDetectorImpl::
237235 for (cv::Point2f &corner : checker->getBox ())
238236 corner += static_cast <cv::Point2f>(region.tl ());
239237
240- mtx.lock (); // push_back is not thread safe
241- m_checkers.push_back (checker);
242- mtx.unlock ();
238+ {
239+ cv::AutoLock lock (mtx);
240+ m_checkers.push_back (checker);
241+ }
243242 }
244243 }
245244#ifdef MCC_DEBUG
@@ -332,7 +331,7 @@ bool CCheckerDetectorImpl::
332331 cv::Mat3f img_rgb_f (img_bgr);
333332 cv::cvtColor (img_rgb_f, img_rgb_f, COLOR_BGR2RGB);
334333 img_rgb_f /= 255 ;
335-
334+ cv::Mutex mtx;
336335 parallel_for_ (
337336 Range (0 , (int )img_bw.size ()), [&](const Range &range) {
338337 const int begin = range.start ;
@@ -456,9 +455,11 @@ bool CCheckerDetectorImpl::
456455 {
457456 for (cv::Point2f &corner : checker->getBox ())
458457 corner += static_cast <cv::Point2f>(region.tl () + innerRegion.tl ());
459- mtx.lock (); // push_back is not thread safe
460- m_checkers.push_back (checker);
461- mtx.unlock ();
458+
459+ {
460+ cv::AutoLock lock (mtx);
461+ m_checkers.push_back (checker);
462+ }
462463 }
463464 }
464465#ifdef MCC_DEBUG
@@ -1236,7 +1237,7 @@ void CCheckerDetectorImpl::
12361237 // Create table charts information
12371238 // |p_size|average|stddev|max|min|
12381239 // RGB | | | | | |
1239- // YCbCr |
1240+ // YCbCr |
12401241
12411242 Mat _charts_rgb = cv::Mat (cv::Size (5 , 3 * (int )N), CV_64F);
12421243 Mat _charts_ycbcr = cv::Mat (cv::Size (5 , 3 * (int )N), CV_64F);
0 commit comments