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

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

c++ - OpenCV waitKey() should return -1 but didn't

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...