Is it possible to set/update the cursor coordinates from within OpenCV mouse events? I have a virtual keyboard and I am trying to make it such that whenever the cursor hovers over a button, it is locked at the mid-point of the button.
My current mouse callback function:
def on_mouse(self, event, x, y, flags, param):
global x1, y1
if event == cv2.EVENT_MOUSEMOVE:
x1, y1 = x, y
for button in self.button_list:
if button.is_hovered_over(x1, y1):
# set the cursor coordinates here
>>> foo.on_mouse
<bound method Foo.on_mouse of <__main__.Foo object at 0x00000251DE3B6DF0>>
keyboard = QWERTYKeyboard.QWERTYKeyboard() implies that keyboard.on_mouse is a method of a class. we donāt know if OPās def on_mouse belongs to that class.