OpenCV set a callback for keyboard event

2019-08-17 17:19发布

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

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

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?

1条回答
放我归山
2楼-- · 2019-08-17 18:18

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.

查看更多
登录 后发表回答