-
我的
OpenCV
学习笔记(
< br>12
):
VideoCapture
类
分类:
opencv
2012-05-03 09:51
23139
人阅读
评论
(27)
收藏
举报
delayfilterfloat
网络
c
这次通过一个读取视频的综合例子来介绍
VideoCapture
类的一些基本操作:
[cpp]
view
plaincopy
1.
#include
2.
#include
3.
#include
4.
#include
5.
6.
using
namespace
std;
7.
using
namespace
cv;
8.
9.
int
main()
10.
{
11.
//
打开视频文件:其实就是建立一个
VideoCapt
ure
结构
12.
VideoCapture capture(
);
13.
//
检测是否正常打开
:
成功打开时,
isOpened
返回
ture
14.
if
(!ed())
15.
cout<<
// <
<
16.
//
获取整个帧数
17.
long
totalFrameNumber =
(CV_CAP_PROP_FRAME_COUNT);
18.
cout<<
整个视频共
<
帧
<
19.
20.
21.
设置开始帧
()
22.
long
frameToStart = 300;
23.
( CV_CAP_PROP_POS_FRAMES,frameToStart);
24.
cout<<
从第
帧开始读
<
25.
26.
27.
//
设置结束帧
28.
int
frameToStop = 400;
29.
30.
if
(frameToStop <
frameToStart)
31.
{
32.
cout<<
结束帧小于开始帧,程序错误,即将退出!
<
33.
return
-1;