OpenCV设置键盘事件的回调 [英] OpenCV set a callback for keyboard event

查看:721
本文介绍了OpenCV设置键盘事件的回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在OSX和Ubuntu系统上使用C ++中的openCV.

I am using openCV in C++ on OSX and Ubuntu systems.

我想要setMouseCallback的等效功能,但对于键盘事件(按键).

I would like an equivalent function of setMouseCallback but for keyboard events (key pressed).

对于我在openCV中看到的方法,是使用waitKey(),但实际上它不能用作回调,因为它会停止等待指定事件的正常流程.

For what I have seen the way to do it in openCV is to use waitKey() but actually it does not work as a callback because stops the normal flow waiting for the event specified.

问题是我正在从网络摄像头中流式传输视频,因此此解决方案对我不利.

The problem is that I am streaming a video from the webcam so this solution is no good for me.

是否有适当的功能为鼠标事件设置回调键盘事件?

Is there any proper function to set a callback for keyboard events as is possible for mouse events?

推荐答案

OpenCV不能提供非常强大的UI层,尤其是在访问输入设备方面.至少在针对标准依赖项进行编译时才是这种情况.您可能要考虑使用 VTK编译OpenCV(或单独使用VTK) ,它提供了更多的I/O控制.或者,更简单地说,使用功能更强大的输入库,该输入库可以访问原始设备数据,例如 Gainput ,我已经成功地将它们的GUI方法提供给没有I/O层的库使用.

OpenCV does not provide a very robust UI layer, especially with respect to access to input devices. This is at least the case when it is compiled against the standard dependencies. You may want to look into compiling OpenCV with VTK (or use VTK on its own), which provides more I/O control. Or, more simply, use a more powerful input library that has access to the raw device data, like Gainput, which I have successfully used with libraries that provide NO I/O layer with their GUI methods.

这篇关于OpenCV设置键盘事件的回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆