Reputation: 188
I am relatively new to OpenCV and I am trying to work on virtual mouse. I figured out how to detect different colors and filter them out. I couldn't find how to make mouse click when specific color is detected. Here my sample code:
if (b == 1){
if (x >= 0 && y >= 0 && PosX >= 0 && PosY >= 0)
//Here is the function to left clicking the mouse
}
I figured out how to move the mouse. I used SetCursorPos(x,y)
. I would appreciate any help. Thank you in advance!
Upvotes: 2
Views: 9848
Reputation: 17265
The mouse click event comes with the x,y of the mouse position. Use these coordinates for accessing the image.
Take a look at SetMouseCallback()
.
Here's an example of how to use it.
Upvotes: 5