Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hello , I m sorry but its the real program , in my case the code compile ;(.

You can fin a new version of my programm with gpu mat initialization, but it still not working...

/***************/

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; cuda::GpuMat img_Gpu; cuda::GpuMat templ_Gpu; cuda::GpuMat result_Gpu;

char* image_window = "Source Image"; char* result_window = "Result window"; char* patate = "patate";

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"); img_Gpu.upload(img); templ_Gpu.upload(templ);

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

/// Create Trackbar
//char* trackbar_label = "Method: \n 0: SQDIFF \n 1: SQDIFF NORMED \n 2: TM CCORR \n 3: TM CCORR NORMED \n 4: TM COEFF \n 5: TM COEFF NORMED";
//createTrackbar(trackbar_label, image_window, &match_method, max_Trackbar, MatchingMethod);
int bob = img.type();
cout << "img = " << endl << " " << bob << endl << endl;

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, templ, result);
b->match(img_Gpu, templ_Gpu, result_Gpu);
//result_Gpu.download(result);
//imshow(patate, result);


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

//minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc, Mat());
rectangle(img, Point(0 , 100 ), Point(100 ,0), Scalar::all(0), 2, 8, 0);
//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;

}

error message is :

Hello , I m sorry but its the real program , in my case the code compile ;(.

You can fin a new version of my programm with gpu mat initialization, but it still not working...

/***************/

include "opencv2/highgui/highgui.hpp"

/***********************************************/
#include "opencv2/highgui/highgui.hpp"
//#include "opencv2/imgproc/imgproc.hpp"

include "opencv2/cudaimgproc.hpp"

include <iostream>

include <stdio.h>

"opencv2/imgproc/imgproc.hpp" #include "opencv2/cudaimgproc.hpp" #include <iostream> #include <stdio.h> using namespace std; using namespace cv;

cv; /// Global Variables Mat img; Mat templ; Mat result; Mat img2; //cuda::GpuMat img; cuda::GpuMat templ; cuda::GpuMat result; cuda::GpuMat img2; cuda::GpuMat img_Gpu; cuda::GpuMat templ_Gpu; cuda::GpuMat result_Gpu;

result_Gpu; char* image_window = "Source Image"; char* result_window = "Result window"; char* patate = "patate";

"patate"; int match_method; int max_Trackbar = 5;

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

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

templ_Gpu.upload(templ);

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

 /// Create Trackbar
 //char* trackbar_label = "Method: \n 0: SQDIFF \n 1: SQDIFF NORMED \n 2: TM CCORR \n 3: TM CCORR NORMED \n 4: TM COEFF \n 5: TM COEFF NORMED";
 //createTrackbar(trackbar_label, image_window, &match_method, max_Trackbar, MatchingMethod);
 int bob = img.type();
 cout << "img = " << endl << " " << bob << endl << endl;

 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, templ, result);
 b->match(img_Gpu, templ_Gpu, result_Gpu);
 //result_Gpu.download(result);
 //imshow(patate, result);


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

 //minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc, Mat());
 rectangle(img, Point(0 , 100 ), Point(100 ,0), Scalar::all(0), 2, 8, 0);
 //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;
}

}

error message is :: image description

Hello , I m sorry but its the real program , in my case the code compile ;(.

You can fin a new version of my programm with gpu mat initialization, but it still not working...

/***********************************************/
#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;
cuda::GpuMat img_Gpu;
cuda::GpuMat templ_Gpu;
cuda::GpuMat result_Gpu;

char* image_window = "Source Image";
char* result_window = "Result window"; 
char* patate = "patate";

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");
    img_Gpu.upload(img);
    templ_Gpu.upload(templ);

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

    /// Create Trackbar
    //char* trackbar_label = "Method: \n 0: SQDIFF \n 1: SQDIFF NORMED \n 2: TM CCORR \n 3: TM CCORR NORMED \n 4: TM COEFF \n 5: TM COEFF NORMED";
    //createTrackbar(trackbar_label, image_window, &match_method, max_Trackbar, MatchingMethod);
    int bob = img.type();
    cout << "img = " << endl << " " << bob << endl << endl;

    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, templ, result);
    b->match(img_Gpu, templ_Gpu, result_Gpu);
    //result_Gpu.download(result);
    //imshow(patate, result);


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

    //minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc, Mat());
    rectangle(img, Point(0 , 100 ), Point(100 ,0), Scalar::all(0), 2, 8, 0);
    //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;
}

error message is : image description

Bug corrected!