Ask Your Question

waitkey fails to handle non-English keyboard input

asked 2019-02-27 05:40:11 -0500

ask_opencv gravatar image

I am using opencv to build a camera function and at some point in the Python script, it uses waitKey() to get what key is pressed by the user.

k = cv2.waitKey(1)

# ESC is pressed
if k % 256 == 27:

The problem is that when the keyboard input is switched to Russian or Chinese, and the keys (e.g. q, w, e r, ...etc) are pressed. The program terminates unexpectedly with this error

ASSERT: "false" in file qasciikey.cpp, line 501
Abort trap: 6

How should I handle the keyboard input correctly such that this issue can be eliminated?

Thanks in advance

edit retag flag offensive close merge delete


Can you try with cv.waitKeyEx?

LBerger gravatar imageLBerger ( 2019-02-27 05:43:22 -0500 )edit

it's a known qt related problem. there's a table in qascii.cpp, which does not handle kyrilllic or chinese characters.

if you can, switch your keyboard layout (from some os panel) to english, just for this

berak gravatar imageberak ( 2019-02-27 06:48:45 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2019-02-28 08:36:55 -0500

supra56 gravatar image

updated 2019-02-28 08:37:50 -0500

In my example:

c = cv2.waitKey(0) % 256

        if c == ord('a'):
            print "pressed a"
            print 'you press %s' % chr(c)
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2019-02-27 05:40:11 -0500

Seen: 348 times

Last updated: Feb 28 '19