0

I'm working with openCV library in Python and I have very strange behaviour:

I have a code like this:

...
img = cv2.imread(imgpath)
key = cv2.waitKey(1)
if key == ord('p'):
    do_something()
else:
    print key, ord('p')
...

When I'm running my code and pressing p button, I can see the following:

1048688 112

It means that integer representation of p button is 1048688, but expected 112.

What is strange yet, this code was working during a few last days, but now it's not working. I haven't any changes in this code.

Any ideas? It it possible that something changed in system?

pivanchy
  • 723
  • 3
  • 15
  • 3
    112 in hex is `0x70`. 1048688 in hex is `0x100070`. [Looks like some extra flags](http://stackoverflow.com/questions/14494101/using-other-keys-for-the-waitkey-function-of-opencv) are in higher order bits. Just mask that out and use the LSB. According to one of the answer in the question I refer to, the thing that changed in your system is that you pressed NumLock. – Dan Mašek May 22 '16 at 20:05
  • @DanMašek, heh...Nice catch with Numlock. It was really unexpected for me. – pivanchy May 22 '16 at 20:16

0 Answers0