[英]opencv : Unable to read upper case letters through waitKey
I have a simple switch case as follows inside an infinite while loop, to call functions based on the key pressed by the user.我有一个简单的开关盒,如下所示在无限循环中,根据用户按下的键调用函数。 I am programming in C++ using opencv libraries.我正在使用 opencv 库在 C++ 中编程。 The waitKey function used below is able to read the lower case letters i press on the keyboard.下面使用的 waitKey 函数能够读取我在键盘上按下的小写字母。 I am however unable to read any upper case letters and it still reads and interprets it as the corresponding lower case letter.然而,我无法阅读任何大写字母,它仍然阅读并将其解释为相应的小写字母。 Any help in this regard is appreciated.在这方面的任何帮助表示赞赏。 should i be updating my opencv libraries?我应该更新我的 opencv 库吗? I installed opencv on ubuntu with the help of this post我在这篇文章的帮助下在 ubuntu 上安装了 opencv
os UBUNTU 13.10 opencv version 2.4.8操作系统 UBUNTU 13.10 opencv 2.4.8 版
Pseudo code伪代码
while(1)
{`
char k = waitKey(0);
switch(k) {
case 'a' : ... break;
case 'b' : ... break;
case 'A' : ... break; // UNABLE TO READ A here.
}
}
我在 OpenCV 论坛上发现了一个与您的问题相关的小提示,因为您还没有找到它: http : //answers.opencv.org/question/4266/cvwaitkey-upper-lowercase-difference/
I have the same problem (with opencv-4.x).我有同样的问题(使用 opencv-4.x)。 I think this is due to the fact that I compiled opencv with the cmake option -D WITH_QT=ON
(to enable the zoom scroll on images).我认为这是因为我使用 cmake 选项-D WITH_QT=ON
(以启用图像的缩放滚动)编译了 opencv。 But Qt interprets q and Q as the same keycode (81);但是 Qt 将 q 和 Q 解释为相同的键码(81); the only thing is that it adds a (shift) modifier.唯一的事情是它添加了一个(移位)修饰符。
Let's say you receive a QKeyEvent
event in a C++/Qt program.假设您在 C++/Qt 程序中收到一个QKeyEvent
事件。 Then you get when pressing:然后你按下时得到:
It seems cv::waitKey
or cv::waitKeyEx
, when opencv uses Qt, does not read the modifiers, just the key code, unfortunately...似乎cv::waitKey
或cv::waitKeyEx
,当 opencv 使用 Qt 时,不读取修饰符,只读取关键代码,不幸的是...
So far, the only option I found is to recompile with -D WITH_QT=OFF
.到目前为止,我发现的唯一选择是使用-D WITH_QT=OFF
重新编译。 Then I can discriminate between Q and q (but also left arrow and Shifted left arrow and so on).然后我可以区分 Q 和 q(还有左箭头和左移箭头等等)。 But the trade-off is that I can't scroll the images anymore...但权衡是我不能再滚动图像......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.