How to use lambda as a parameter to parallel_for_
Is it possible to pass the functor to parallel_for_
as a lambda?
cv::parallel_for_(cv::Range(0, X), [&] (const cv::Range & r) {
for (int index = r.start; index != r.end; ++index) {
// do work
}
});
The above code fails to compile:
..\src\test.cpp: In function 'int main()':
..\src\test.cpp:29:3: error: invalid initialization of reference of type 'const cv::ParallelLoopBody&' from expression of type 'main()::<lambda(const cv::Range&)>'
C:\opencv\build\include/opencv2/core/core.hpp:4787:17: error: in passing argument 2 of 'void cv::parallel_for_(const cv::Range&, const cv::ParallelLoopBody&, double)'
I'd like to capture local variables.