#include <opencv2/opencv.hpp>
using namespace cv;
int keyvalue = 0;
int main() {
VideoCapture capture("/home/*/*.mp4"); //改成文件路径
while(1){
Mat frame;
capture >> frame;
imshow("final",frame);
keyvalue = waitKey(30);
if (keyvalue == 113||keyvalue == 81)
break;
else if(keyvalue == 32)
waitKey(0);
}
return 0;
}
waitKey函数是一个等待键盘事件的函数,参数值delay<=0时等待时间无限长,delay为正整数n时至少等待n毫秒的时间才结束。在等待的期间按下任意按键时函数结束,返回按键的键值(ascii码),等待时间结束仍未按下按键则返回-1。
Q的键值为81,q为113