lundi 20 avril 2015

c++ QT and OpenCV. setMouseCallBack in QLabel?

I'm using the function setMouseCallback to extract the information about pixel coordinates at every mouse event. The program I created works perfectly if I use openCV windows. Precisely:

image is cv::Mat;

cv::namedWindow("Original", WINDOW_NORMAL);
cv::imshow("Original", image);

cv::setMouseCallback("Original", mouseWrapper, NULL);


void esempio::onMouse(int event, int x, int y, int flags, void *param)
// Code to read the mouse event in the identification of a point
    if (event == CV_EVENT_LBUTTONDOWN)
            std::cout << "1: " << x << "," << y << std::endl;

void mouseWrapper( int event, int x, int y, int flags, void* param )
    esempio * mainWin = (esempio *)(param);

Now, I would like to use the same code in a QLabel created in my interface. I tried to use the function setWindowTitle to change the name of the QLabel in this way:

cv::setMouseCallback("Test", mouseWrapper, NULL); 

but this approach seems not adequate.

How can I indicate to the function setMouseCallback to work on the desired QLabel?


Aucun commentaire:

Enregistrer un commentaire