In OpenCV I want to return the point position like Point(x,y) to the main() function that I click on the image in the mouse callback function . Is there anyway other than se
No, this isn't possible, since the on_mouse()
is a callback function. Here is the opencv documentation of it.
So, "global" variables are the only way to solve this problem. Alternatively, if you're looking for a nicer solution, you can create a wrapper class in which you have the namedWindow
and the MouseCallback
and a private member variable, which is manipulated when mouse callback function is called.