博客
关于我
Opencv读取视频或调用摄像头
阅读量:477 次
发布时间:2019-03-06

本文共 991 字,大约阅读时间需要 3 分钟。

 一、Opencv读取视频

注意:需要用到这两个库,使用时记得添加-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<<"视频宽度="<
<
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/

你可能感兴趣的文章
mysql系列一
查看>>
MySQL系列之数据类型(Date&Time)
查看>>
MySQL系列之数据类型(Date&Time)
查看>>
Mysql系列之锁机制
查看>>
Mysql系列九:使用zookeeper管理远程Mycat配置文件、Mycat监控、Mycat数据迁移(扩容)...
查看>>
MySql系列:[4200][1140]In aggregated query without GROUP BY, expression #2 of SELECT list contains nona
查看>>
MySQL索引
查看>>
Mysql索引
查看>>
mysql索引
查看>>
mysql索引
查看>>
Mysql索引,索引的优化,如何避免索引失效案例
查看>>
Mysql索引、命令重点介绍
查看>>
mysql索引、索引优化(这一篇包括所有)
查看>>
Mysql索引一篇就够了
查看>>
MySQL索引一篇带你彻底搞懂(一次讲清实现原理加优化实战,面试必问)
查看>>
MySQL索引下沉:提升查询性能的隐藏秘
查看>>
MySql索引为什么使用B+树
查看>>
MySQL索引为什么是B+树
查看>>
WARNING!VisualDDK wizard was unable to find any DDK/WDK installed on your system.
查看>>
MySQL索引介绍及百万数据SQL优化实践总结
查看>>