Ask Your Question

Revision history [back]

You need to implement a sort of adapter pattern because cv::parallel_for_ is not a template method so the implementation could be like this:

class LambdaBody : public cv::ParallelLoopBody {    
public:
    typedef void(*LambdaParallelLoopBody)(const cv::Range & range);
    LambdaBody(LambdaParallelLoopBody body){
        _body = body;
    }

    void operator() (const cv::Range & range) const
    {
        _body(range);
    }    
private:
    LambdaParallelLoopBody _body;
};

and then call it like this

cv::parallel_for_(cv::Range(0, 10), LambdaBody([&](const cv::Range & range){
        std::cout << range.start << " - " << range.end << std::endl;
    }));

hope it works for you!