Ask Your Question
0

waitkey fails to handle non-English keyboard input

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

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:
    break

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

Comments

Can you try with cv.waitKeyEx?

LBerger gravatar imageLBerger ( 2019-02-27 05:43:22 -0600 )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 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

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

supra56 gravatar image

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

In my example:

c = cv2.waitKey(0) % 256

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

Question Tools

1 follower

Stats

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

Seen: 647 times

Last updated: Feb 28 '19