Commit 8f970caa authored by Andrey Kamaev's avatar Andrey Kamaev

#1349 tbb::mutex is moved to outer scope to be sure that its initialization is…

#1349 tbb::mutex is moved to outer scope to be sure that its initialization is completed before the parallel loop
parent 4eda1662
...@@ -257,6 +257,10 @@ interpolateKeypoint( float N9[3][9], int dx, int dy, int ds, KeyPoint& kpt ) ...@@ -257,6 +257,10 @@ interpolateKeypoint( float N9[3][9], int dx, int dy, int ds, KeyPoint& kpt )
return ok; return ok;
} }
#ifdef HAVE_TBB
static tbb::mutex findMaximaInLayer_m;
#endif
/* /*
* Find the maxima in the determinant of the Hessian in a layer of the * Find the maxima in the determinant of the Hessian in a layer of the
* scale-space pyramid * scale-space pyramid
...@@ -352,10 +356,9 @@ findMaximaInLayer( const Mat& sum, const Mat& mask_sum, ...@@ -352,10 +356,9 @@ findMaximaInLayer( const Mat& sum, const Mat& mask_sum,
if( interp_ok ) if( interp_ok )
{ {
/*printf( "KeyPoint %f %f %d\n", point.pt.x, point.pt.y, point.size );*/ /*printf( "KeyPoint %f %f %d\n", point.pt.x, point.pt.y, point.size );*/
#ifdef HAVE_TBB #ifdef HAVE_TBB
static tbb::mutex m; tbb::mutex::scoped_lock lock(findMaximaInLayer_m);
tbb::mutex::scoped_lock lock(m); #endif
#endif
keypoints.push_back(kpt); keypoints.push_back(kpt);
} }
} }
...@@ -411,6 +414,11 @@ struct SURFFindInvoker ...@@ -411,6 +414,11 @@ struct SURFFindInvoker
keypoints = &_keypoints; keypoints = &_keypoints;
nOctaveLayers = _nOctaveLayers; nOctaveLayers = _nOctaveLayers;
hessianThreshold = _hessianThreshold; hessianThreshold = _hessianThreshold;
#ifdef HAVE_TBB
//touch the mutex to ensure that it's initialization is finished
CV_Assert(&findMaximaInLayer_m > 0);
#endif
} }
void operator()(const BlockedRange& range) const void operator()(const BlockedRange& range) const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment