Commit 0e91983b authored by Jaykob's avatar Jaykob Committed by Alexander Alekhin

Merge pull request #1330 from Jaykob:parallelize_structured_edge_detection

* Replace OpenMP parallelization with OpenCV's general parallel_for_ to cover other backends than OpenMP.

* Fixed shadowing of range variable in C++11 mode.
parent 17069889
......@@ -729,11 +729,14 @@ protected:
offsetY[n] = x2*features.cols*nchannels + y2*nchannels + z;
}
// lookup tables for mapping linear index to offset pairs
#ifdef _OPENMP
#pragma omp parallel for
#ifdef CV_CXX11
parallel_for_(cv::Range(0, height), [&](const cv::Range& range)
#else
const cv::Range range(0, height);
#endif
for (int i = 0; i < height; ++i)
{
for(int i = range.start; i < range.end; ++i) {
float *regFeaturesPtr = regFeatures.ptr<float>(i*stride/shrink);
float *ssFeaturesPtr = ssFeatures.ptr<float>(i*stride/shrink);
......@@ -775,16 +778,21 @@ protected:
indexPtr[j*nTreesEval + k] = currentNode;
}
}
}
#ifdef CV_CXX11
);
#endif
NChannelsMat dstM(dst.size(),
CV_MAKETYPE(DataType<float>::type, outNum));
dstM.setTo(0);
float step = 2.0f * CV_SQR(stride) / CV_SQR(ipSize) / nTreesEval;
#ifdef _OPENMP
#pragma omp parallel for
#ifdef CV_CXX11
parallel_for_(cv::Range(0, height), [&](const cv::Range& range)
#endif
for (int i = 0; i < height; ++i)
{
for(int i = range.start; i < range.end; ++i)
{
int *pIndex = indexes.ptr<int>(i);
float *pDst = dstM.ptr<float>(i*stride);
......@@ -805,6 +813,10 @@ protected:
pDst[offset + offsetE[__rf.edgeBins[p]]] += step;
}
}
}
#ifdef CV_CXX11
);
#endif
cv::reduce( dstM.reshape(1, int( dstM.total() ) ), dstM, 2, CV_REDUCE_SUM);
imsmooth( dstM.reshape(1, dst.rows), 1 ).copyTo(dst);
......
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