本文共 991 字,大约阅读时间需要 3 分钟。
注意:需要用到这两个库,使用时记得添加-lopencv_video -lopencv_videoio
#include#include using namespace cv;using namespace std;void main(){ VideoCapture cap; cap.open("./face.mp4"); if(!cap.isOpened()) return; int width = cap.get(CV_CAP_PROP_FRAME_WIDTH); //帧宽度 int height = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //帧高度 int frameRate = cap.get(CV_CAP_PROP_FPS); //帧率 x frames/s int totalFrames = cap.get(CV_CAP_PROP_FRAME_COUNT); //总帧数 cout<<"视频宽度="< < >frame;//等价于cap.read(frame); if(frame.empty()) break; imshow(" video", frame); if(waitkey(20)> 0) break; } cap.release();}
cv::VideoCapture cap(0); //视频 while(/*cap.read(img)*/1) { ti.reset(); //double t1 = (double)getTickCount(); //t1 = (double)getTickCount() - t1; //time += t1 * 1000 / cv::getTickFrequency(); time += ti.elapsedMilliSeconds(); count ++; if(count % 1000 == 0) { printf("face detection average time = %f.\n", time / count); } }
转载地址:http://nlpdz.baihongyu.com/