Namit Juneja
Namit Juneja

Reputation: 498

pymouse not running with opencv in python

enter image description hereIts a simple code that i was testing

When i use cv2.imshow and subsequently waitkey() of opencv the pymouse module stops working and doesnt change mouse's co-ordinates but when i comment out the imshow and waitkey() m.move works properly here is my code and also a screenshot

import cv2
from pymouse import PyMouse

m = PyMouse()

img = cv2.imread("123.jpg")

cv2.imshow("img", img)![enter image description here][2]
cv2.waitKey(0)

m.move(0,0)

print "lastline"

the "lastline" never gets printed

Upvotes: 0

Views: 327

Answers (1)

Ketouem
Ketouem

Reputation: 3857

From the official documentation of OpenCV:

The function waitKey waits for a key event infinitely (when \texttt{delay}\leq 0 ) or for delay milliseconds, when it is positive.

So when you put in your code:

cv2.waitKey(0)

It waits indefinitely for a user input i.e. if you don't type something the following lines won't be executed (that's why when you comment out the line the move action is executed)

Upvotes: 1

Related Questions