Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to use templatematching cuda 7.5 and opencv 3.1

Hi, I try to use template matching in c++ but it doesn't work. when I use this program, an error occur image description

/***********************************************/
#include "opencv2/highgui/highgui.hpp"
//#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/cudaimgproc.hpp"
#include <iostream>
#include <stdio.h>

using namespace std;
using namespace cv;

/// Global Variables
Mat img; Mat templ; Mat result; Mat img2;
//cuda::GpuMat img; cuda::GpuMat templ; cuda::GpuMat result; cuda::GpuMat img2;
char* image_window = "Source Image";
char* result_window = "Result window";

int match_method;
int max_Trackbar = 5;

/// Function Headers
void MatchingMethod(int, void*);

/** @function main */
int main(int argc, char** argv)
{
    /// Load image and template
    img = imread("../data/lena.jpg");
    templ = imread("../data/eye.jpg");

    /// Create windows
    namedWindow(image_window, CV_WINDOW_AUTOSIZE);
    namedWindow(result_window, CV_WINDOW_AUTOSIZE);

    imshow(image_window, img);

     //cuda::TemplateMatching *b;
    cv::Ptr<cv::cuda::TemplateMatching> b;
    b = cuda::createTemplateMatching(CV_32F, CV_TM_CCORR);// , Size(0, 0));
    b->match(img_Gpu, templ_Gpu, result_Gpu);//<--- this line create a bug



    //double minVal; double maxVal; Point minLoc; Point maxLoc;
    //Point matchLoc;

    //minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc, Mat());
    //rectangle(result, matchLoc, Point(matchLoc.x + templ.cols, matchLoc.y + templ.rows), Scalar::all(0), 2, 8, 0);



    imshow(result_window, img);

    waitKey(0);
    return 0;
}

Can you help me?

thank you

CONF-->GTX980M 16G RAM W10 VS2013