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);
where
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;
pp_m.x=x;
pp_m.y=y;
}
}
void mouseWrapper( int event, int x, int y, int flags, void* param )
{
esempio * mainWin = (esempio *)(param);
mainWin->onMouse(event,x,y,flags,0);
}
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:
ui->label_show->setWindowTitle("Test");
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?
Thanks