OpenCV waitKey()应返回-1但不返回-1

时间:2021-05-31 20:23:31

In the doc it says that

在文档中它说

It returns the code of the pressed key or -1 if no key was pressed before the specified time had elapsed.

它返回按下的键的代码,如果在指定的时间过去之前没有按下任何键,则返回-1。

But it returns 255 instead of -1 when no key is pressed on my Ubuntu 14.04 device. Why is that?

但是当我的Ubuntu 14.04设备上没有按下任何键时,它返回255而不是-1。这是为什么?

Code example:

#include <opencv/cv.hpp>#include <iostream>using namespace cv;int main(void) {    Mat image = Mat::zeros(100, 100, CV_8UC3);    char window_name[] = "waitKey() example";    imshow(window_name, image);    const int DELAY = 50;    int c = waitKey(DELAY);    std::cout << c << std::endl;}

1 个解决方案

#1


2  

recently some code modification has made on cv::waitKey() and there is a fix about this issue not merged yet.

最近在cv :: waitKey()上进行了一些代码修改,并且有一个关于此问题的修复尚未合并。

#1


2  

recently some code modification has made on cv::waitKey() and there is a fix about this issue not merged yet.

最近在cv :: waitKey()上进行了一些代码修改,并且有一个关于此问题的修复尚未合并。