1 | initial version |
you can just pass your image to the callback-function, and draw your circle there:
void onmouse(int event, int x, int y, int flags, void* param)
{
if(event==CV_EVENT_LBUTTONDOWN)
{
Mat &img = *((Mat*)(param)); // 1st cast it back, then deref
circle(img,Point(x,y),50,Scalar(0,255,0),1);
}
}
int main()
{
Mat img;
namedWindow("My window", 1);
setMouseCallback("My window", onmouse, &img); // pass address of img here
// ...
}
(some sidenotes:)