Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

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

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;
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...