Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions modules/mcc/src/checker_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ namespace cv
namespace mcc
{

std::mutex mtx; // mutex for critical section

Ptr<CCheckerDetector> CCheckerDetector::create()
{
return makePtr<CCheckerDetectorImpl>();
Expand Down Expand Up @@ -113,7 +111,7 @@ bool CCheckerDetectorImpl::
// Get chanels
split(img_rgb_org, rgb_planes);
split(img_ycbcr_org, ycbcr_planes);

cv::Mutex mtx;
parallel_for_(
Range(0, (int)img_bw.size()), [&](const Range &range) {
const int begin = range.start;
Expand Down Expand Up @@ -237,9 +235,10 @@ bool CCheckerDetectorImpl::
for (cv::Point2f &corner : checker->getBox())
corner += static_cast<cv::Point2f>(region.tl());

mtx.lock(); // push_back is not thread safe
m_checkers.push_back(checker);
mtx.unlock();
{
cv::AutoLock lock(mtx);
m_checkers.push_back(checker);
}
}
}
#ifdef MCC_DEBUG
Expand Down Expand Up @@ -332,7 +331,7 @@ bool CCheckerDetectorImpl::
cv::Mat3f img_rgb_f(img_bgr);
cv::cvtColor(img_rgb_f, img_rgb_f, COLOR_BGR2RGB);
img_rgb_f /= 255;

cv::Mutex mtx;
parallel_for_(
Range(0, (int)img_bw.size()), [&](const Range &range) {
const int begin = range.start;
Expand Down Expand Up @@ -456,9 +455,11 @@ bool CCheckerDetectorImpl::
{
for (cv::Point2f &corner : checker->getBox())
corner += static_cast<cv::Point2f>(region.tl() + innerRegion.tl());
mtx.lock(); // push_back is not thread safe
m_checkers.push_back(checker);
mtx.unlock();

{
cv::AutoLock lock(mtx);
m_checkers.push_back(checker);
}
}
}
#ifdef MCC_DEBUG
Expand Down Expand Up @@ -1236,7 +1237,7 @@ void CCheckerDetectorImpl::
// Create table charts information
// |p_size|average|stddev|max|min|
// RGB | | | | | |
// YCbCr |
// YCbCr |

Mat _charts_rgb = cv::Mat(cv::Size(5, 3 * (int)N), CV_64F);
Mat _charts_ycbcr = cv::Mat(cv::Size(5, 3 * (int)N), CV_64F);
Expand Down
1 change: 0 additions & 1 deletion modules/mcc/src/precomp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

#include <vector>
#include <string>
#include <mutex> // std::mutex

#include "opencv2/mcc.hpp"

Expand Down