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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…