-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Pressing the ´ key in cv::waitKey causes crash across languages and CV versions #21401
Copy link
Copy link
Closed
Closed
Copy link
Description
System information (version)
- OpenCV => 4.5.5/4.3.0/master
- Operating System / Platform => macOS Monterey 12.0.1 ARM (but likely others)
- Compiler => Xcode/Clang or Python
- Keyboard layout => QWERTZ German
Detailed description
cv::waitKey crashes in cocoa_window.mm:621 at returnCode = [[event characters] characterAtIndex:0]; since the string can be empty after pressing the ´ key on a german QWERTZ keyboard:
(lldb) print [event characters]
(__NSCFConstantString *) $0 = 0x00000001e7128ac0 ""
I think this is because the first keypress does "nothing" and a character only appears after pressing the same key twice/another key. This is because it is used to generate characters like á by combining a and ´ and thus actually "committing" the character has to be delayed until the next keypress. I am sure there are a bunch of other examples in other languages, or with other keyboards that I don't know of.
Steps to reproduce
// Can reproduce this on all C++ programs that have a cv::waitKey in them:
cv::Mat mat(100, 100, CV_8UC1);
cv::imshow("test", mat);
cv::waitKey(0);
// pressing ´ crashes the program, as described aboveAlso in Python:
import numpy
import cv2
cv2.imshow("test", numpy.zeros((10,10)))
cv2.waitKey(0)
# now press ´ -> [__NSCFConstantString characterAtIndex:]: Range or index out of bounds
# and python instance is terminatedIssue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues,
forum.opencv.org, Stack Overflow, etc and have not found solution - I updated to latest OpenCV version and the issue is still there
- There is reproducer code and related data files: videos, images, onnx, etc
Reactions are currently unavailable