您的位置:首页 > 运维架构

OPENCV学习笔记1-9_视频读取

2018-01-21 19:44 441 查看
#include <iostream>
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;
int main( int argc, char** argv )
{
/* VideoCapture cap(0);               //open the default camera */
VideoCapture cap( "test.flv" );
if ( !cap.isOpened() )
{
cerr << "Can not open a camera or file." << endl;
return(-1);
}
Mat edges;
namedWindow( "edges", 1 );
namedWindow( "frame", 1 );
for (;; )
{
Mat frame;
cap >> frame;                     //get a new frame from cap
if ( frame.empty() )
break;
imshow( "frame", frame );
cvtColor( frame, edges, CV_BGR2GRAY );
Canny( edges, edges, 0, 30, 3 );
imshow( "edges", edges );
if ( waitKey( 30 ) >= 0 )
break;
}
/* the camera will be deinitialized automatically in VideoCapture destructor */
return(0);
}




 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: