Getting error for set mouse callback
Hi, I am trying to use mouse callback function to crop out the rectangular area by clicking twice on the image. Below is code and error message. It will great, if anyone help here. Thanks
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;
vector<Point>pt;
Mat RectifiedImage;
int main()
{
// read the video frame.......
Mat RectifiedImage= frame;
imshow("Rectified Image", RectifiedImage);
setMouseCallback("Rectified Image", onMouse, &pt);
Mat ROI;
while (true)
{
if (pt.size() <= 2)
{
int x = pt[0].x;
int y = pt[0].y;
int x1 = pt[1].x;
int y1 = pt[1].y;
ROI = RectifiedImage(Rect(x, y, x1 - x, y1 - y));
return false;
}
}
imshow("image", ROI);
}
waitKey(0);
return 0;
}
static void onMouse(int event, int i, int j, int flags, void* param)
{
Mat &RectifiedImage = *((Mat*)param);
Point p;
if (event == EVENT_LBUTTONDOWN)
{
p = { i,j };
pt.push_back(p);
cout << i << j << endl;
}
}
please try to format your code properly.
Hi berak, done