I am writing a code for eye tracker using OS X / X Code / OpenCV 2.2. As part of the Eye Tracker training process, I am using cvSetMouseCallback to capture the data as per f
try to remove this line:
cvSetMouseCallback( "video", my_mouse_callback, (void*) img);
from the loop and place it immediately after:
cvNamedWindow( "video", 1 );
Regards !
I can see that this is an old post, but for people looking for help in the future: I had a similar problem using opencv (in python) and this answer helped me out. In short, the flags value returned from right clicking did not match the value returned from CV_EVENT_RBUTTONDOWN; printing the flags value that you get when you right click and comparing it to the flags value stored in CV_EVENT_RBUTTONDOWN to see if they're the same may help.