Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
54afb85d
O
Opencv
项目概览
Greenplum
/
Opencv
大约 1 年 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
54afb85d
编写于
5月 14, 2013
作者:
V
Vadim Pisarevsky
提交者:
OpenCV Buildbot
5月 14, 2013
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #823 from pickle27:starter_image_sequence
上级
14c50d2f
69c626e7
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
38 addition
and
33 deletion
+38
-33
modules/highgui/doc/reading_and_writing_images_and_video.rst
modules/highgui/doc/reading_and_writing_images_and_video.rst
+4
-4
samples/cpp/starter_video.cpp
samples/cpp/starter_video.cpp
+34
-29
未找到文件。
modules/highgui/doc/reading_and_writing_images_and_video.rst
浏览文件 @
54afb85d
...
@@ -191,8 +191,8 @@ VideoCapture
...
@@ -191,8 +191,8 @@ VideoCapture
------------
------------
.. ocv:class:: VideoCapture
.. ocv:class:: VideoCapture
Class for video capturing from video files or cameras.
Class for video capturing from video files
, image sequences
or cameras.
The class provides C++ API for capturing video from cameras or for reading video files. Here is how the class can be used: ::
The class provides C++ API for capturing video from cameras or for reading video files
and image sequences
. Here is how the class can be used: ::
#include "opencv2/opencv.hpp"
#include "opencv2/opencv.hpp"
...
@@ -241,7 +241,7 @@ VideoCapture constructors.
...
@@ -241,7 +241,7 @@ VideoCapture constructors.
.. ocv:cfunction:: CvCapture* cvCaptureFromCAM( int device )
.. ocv:cfunction:: CvCapture* cvCaptureFromCAM( int device )
.. ocv:cfunction:: CvCapture* cvCaptureFromFile( const char* filename )
.. ocv:cfunction:: CvCapture* cvCaptureFromFile( const char* filename )
:param filename: name of the opened video file
:param filename: name of the opened video file
(eg. video.avi) or image sequence (eg. img%02d.jpg)
:param device: id of the opened video capturing device (i.e. a camera index). If there is a single camera connected, just pass 0.
:param device: id of the opened video capturing device (i.e. a camera index). If there is a single camera connected, just pass 0.
...
@@ -258,7 +258,7 @@ Open video file or a capturing device for video capturing
...
@@ -258,7 +258,7 @@ Open video file or a capturing device for video capturing
.. ocv:pyfunction:: cv2.VideoCapture.open(filename) -> retval
.. ocv:pyfunction:: cv2.VideoCapture.open(filename) -> retval
.. ocv:pyfunction:: cv2.VideoCapture.open(device) -> retval
.. ocv:pyfunction:: cv2.VideoCapture.open(device) -> retval
:param filename: name of the opened video file
:param filename: name of the opened video file
(eg. video.avi) or image sequence (eg. img%02d.jpg)
:param device: id of the opened video capturing device (i.e. a camera index).
:param device: id of the opened video capturing device (i.e. a camera index).
...
...
samples/cpp/starter_video.cpp
浏览文件 @
54afb85d
...
@@ -4,31 +4,34 @@
...
@@ -4,31 +4,34 @@
* Created on: Nov 23, 2010
* Created on: Nov 23, 2010
* Author: Ethan Rublee
* Author: Ethan Rublee
*
*
* A starter sample for using opencv, get a video stream and display the images
* Modified on: April 17, 2013
* Author: Kevin Hughes
*
* A starter sample for using OpenCV VideoCapture with capture devices, video files or image sequences
* easy as CV_PI right?
* easy as CV_PI right?
*/
*/
#include "opencv2/highgui/highgui.hpp"
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <iostream>
#include <vector>
#include <stdio.h>
#include <stdio.h>
using
namespace
cv
;
using
namespace
cv
;
using
namespace
std
;
using
namespace
std
;
//hide the local functions in an anon namespace
//hide the local functions in an anon namespace
namespace
{
namespace
{
void
help
(
char
**
av
)
{
void
help
(
char
**
av
)
{
cout
<<
"
\n
This program justs gets you started reading images from video
\n
"
cout
<<
"The program captures frames from a video file, image sequence (01.jpg, 02.jpg ... 10.jpg) or camera connected to your computer."
<<
endl
"Usage:
\n
./"
<<
av
[
0
]
<<
" <video device number>
\n
"
<<
"Usage:
\n
"
<<
av
[
0
]
<<
" <video file, image sequence or device number>"
<<
endl
<<
"q,Q,esc -- quit
\n
"
<<
"q,Q,esc -- quit"
<<
endl
<<
"space -- save frame
\n\n
"
<<
"space -- save frame"
<<
endl
<<
endl
<<
"
\t
This is a starter sample, to get you up and going in a copy pasta fashion
\n
"
<<
"
\t
To capture from a camera pass the device number. To find the device number, try ls /dev/video*"
<<
endl
<<
"
\t
The program captures frames from a camera connected to your computer.
\n
"
<<
"
\t
example: "
<<
av
[
0
]
<<
" 0"
<<
endl
<<
"
\t
To find the video device number, try ls /dev/video*
\n
"
<<
"
\t
You may also pass a video file instead of a device number"
<<
endl
<<
"
\t
You may also pass a video file, like my_vide.avi instead of a device number"
<<
"
\t
example: "
<<
av
[
0
]
<<
" video.avi"
<<
endl
<<
endl
;
<<
"
\t
You can also pass the path to an image sequence and OpenCV will treat the sequence just like a video."
<<
endl
<<
"
\t
example: "
<<
av
[
0
]
<<
" right%%02d.jpg"
<<
endl
;
}
}
int
process
(
VideoCapture
&
capture
)
{
int
process
(
VideoCapture
&
capture
)
{
...
@@ -38,12 +41,15 @@ namespace {
...
@@ -38,12 +41,15 @@ namespace {
cout
<<
"press space to save a picture. q or esc to quit"
<<
endl
;
cout
<<
"press space to save a picture. q or esc to quit"
<<
endl
;
namedWindow
(
window_name
,
WINDOW_KEEPRATIO
);
//resizable window;
namedWindow
(
window_name
,
WINDOW_KEEPRATIO
);
//resizable window;
Mat
frame
;
Mat
frame
;
for
(;;)
{
for
(;;)
{
capture
>>
frame
;
capture
>>
frame
;
if
(
frame
.
empty
())
if
(
frame
.
empty
())
break
;
break
;
imshow
(
window_name
,
frame
);
imshow
(
window_name
,
frame
);
char
key
=
(
char
)
waitKey
(
5
);
//delay N millis, usually long enough to display and capture input
char
key
=
(
char
)
waitKey
(
30
);
//delay N millis, usually long enough to display and capture input
switch
(
key
)
{
switch
(
key
)
{
case
'q'
:
case
'q'
:
case
'Q'
:
case
'Q'
:
...
@@ -60,7 +66,6 @@ namespace {
...
@@ -60,7 +66,6 @@ namespace {
}
}
return
0
;
return
0
;
}
}
}
}
int
main
(
int
ac
,
char
**
av
)
{
int
main
(
int
ac
,
char
**
av
)
{
...
@@ -70,11 +75,11 @@ int main(int ac, char** av) {
...
@@ -70,11 +75,11 @@ int main(int ac, char** av) {
return
1
;
return
1
;
}
}
std
::
string
arg
=
av
[
1
];
std
::
string
arg
=
av
[
1
];
VideoCapture
capture
(
arg
);
//try to open string, this will attempt to open it as a video file
VideoCapture
capture
(
arg
);
//try to open string, this will attempt to open it as a video file
or image sequence
if
(
!
capture
.
isOpened
())
//if this fails, try to open as a video camera, through the use of an integer param
if
(
!
capture
.
isOpened
())
//if this fails, try to open as a video camera, through the use of an integer param
capture
.
open
(
atoi
(
arg
.
c_str
()));
capture
.
open
(
atoi
(
arg
.
c_str
()));
if
(
!
capture
.
isOpened
())
{
if
(
!
capture
.
isOpened
())
{
cerr
<<
"Failed to open
a video device or video fil
e!
\n
"
<<
endl
;
cerr
<<
"Failed to open
the video device, video file or image sequenc
e!
\n
"
<<
endl
;
help
(
av
);
help
(
av
);
return
1
;
return
1
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录