@@ -40,8 +40,6 @@ namespace cv
40
40
namespace mcc
41
41
{
42
42
43
- std::mutex mtx; // mutex for critical section
44
-
45
43
Ptr <CCheckerDetector> CCheckerDetector::create ()
46
44
{
47
45
return makePtr<CCheckerDetectorImpl>();
@@ -113,7 +111,7 @@ bool CCheckerDetectorImpl::
113
111
// Get chanels
114
112
split (img_rgb_org, rgb_planes);
115
113
split (img_ycbcr_org, ycbcr_planes);
116
-
114
+ cv::Mutex mtx;
117
115
parallel_for_ (
118
116
Range (0 , (int )img_bw.size ()), [&](const Range &range) {
119
117
const int begin = range.start ;
@@ -237,9 +235,10 @@ bool CCheckerDetectorImpl::
237
235
for (cv::Point2f &corner : checker->getBox ())
238
236
corner += static_cast <cv::Point2f>(region.tl ());
239
237
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
+ }
243
242
}
244
243
}
245
244
#ifdef MCC_DEBUG
@@ -332,7 +331,7 @@ bool CCheckerDetectorImpl::
332
331
cv::Mat3f img_rgb_f (img_bgr);
333
332
cv::cvtColor (img_rgb_f, img_rgb_f, COLOR_BGR2RGB);
334
333
img_rgb_f /= 255 ;
335
-
334
+ cv::Mutex mtx;
336
335
parallel_for_ (
337
336
Range (0 , (int )img_bw.size ()), [&](const Range &range) {
338
337
const int begin = range.start ;
@@ -456,9 +455,11 @@ bool CCheckerDetectorImpl::
456
455
{
457
456
for (cv::Point2f &corner : checker->getBox ())
458
457
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
+ }
462
463
}
463
464
}
464
465
#ifdef MCC_DEBUG
@@ -1236,7 +1237,7 @@ void CCheckerDetectorImpl::
1236
1237
// Create table charts information
1237
1238
// |p_size|average|stddev|max|min|
1238
1239
// RGB | | | | | |
1239
- // YCbCr |
1240
+ // YCbCr |
1240
1241
1241
1242
Mat _charts_rgb = cv::Mat (cv::Size (5 , 3 * (int )N), CV_64F);
1242
1243
Mat _charts_ycbcr = cv::Mat (cv::Size (5 , 3 * (int )N), CV_64F);
0 commit comments