OpenCV 3.0 Template matching using OpenCL

asked 2015-01-28 10:33:39 -0600

updated 2020-11-02 17:24:51 -0600

I am trying to do template matching using OpenCL kernels included in OpenCL 3.0 beta, in vain. See below:

CV_IMPL void
cvMatchTemplate( const CvArr* _img, const CvArr* _templ, CvArr* _result, int method )
{
    cv::Mat img = cv::cvarrToMat(_img), templ = cv::cvarrToMat(_templ),
        result = cv::cvarrToMat(_result);
    CV_Assert( result.size() == cv::Size(std::abs(img.cols - templ.cols) + 1,
                                         std::abs(img.rows - templ.rows) + 1) &&
              result.type() == CV_32F );
    matchTemplate(img, templ, result, method);
}

and later, inside matchTemplate function:

CV_OCL_RUN(_img.dims() <= 2 && _result.isUMat(),
               (!needswap ? ocl_matchTemplate(_img, _templ, _result, method) : ocl_matchTemplate(_templ, _img, _result, method)))

Variable result is of type cv::Mat so we will never satisfy the condition _result.isUMat(). I'm confused - how should I be using the OpenCL implementation?

edit retag flag offensive close merge delete