Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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)

share|improve this answer
    
oh okay. don't know how i missed such a trivial thing....anyways thanks for your help –  Namit Juneja Aug 3 '14 at 15:38
    
No biggie, don't forget to accept the answer if it has helped you :) –  Ketouem Aug 3 '14 at 19:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.