Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
535dc1e8
O
Opencv
项目概览
Greenplum
/
Opencv
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
535dc1e8
编写于
5月 29, 2015
作者:
V
Vadim Pisarevsky
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3998 from msandler:master
上级
24dea1c6
8e82bed4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
57 addition
and
9 deletion
+57
-9
modules/videoio/src/cap_libv4l.cpp
modules/videoio/src/cap_libv4l.cpp
+57
-9
未找到文件。
modules/videoio/src/cap_libv4l.cpp
浏览文件 @
535dc1e8
...
...
@@ -190,6 +190,10 @@ make & enjoy!
- PlayStation 3 Eye
- Logitech C920
- Odroid USB-CAM 720P
17th patch: May 9, 2015, Matt Sandler
added supported for CV_CAP_PROP_POS_MSEC, CV_CAP_PROP_POS_FRAMES, CV_CAP_PROP_FPS
*/
/*M///////////////////////////////////////////////////////////////////////////////////////
...
...
@@ -333,6 +337,11 @@ typedef struct CvCaptureCAM_V4L
enum
v4l2_buf_type
type
;
struct
v4l2_queryctrl
queryctrl
;
struct
timeval
timestamp
;
/** value set the buffer of V4L*/
int
sequence
;
/* V4L2 control variables */
v4l2_ctrl_range
**
v4l2_ctrl_ranges
;
int
v4l2_ctrl_count
;
...
...
@@ -1124,6 +1133,11 @@ static int read_frame_v4l2(CvCaptureCAM_V4L* capture) {
if
(
-
1
==
xioctl
(
capture
->
deviceHandle
,
VIDIOC_QBUF
,
&
buf
))
perror
(
"VIDIOC_QBUF"
);
//set timestamp in capture struct to be timestamp of most recent frame
/** where timestamps refer to the instant the field or frame was received by the driver, not the capture time*/
capture
->
timestamp
=
buf
.
timestamp
;
//printf( "timestamp update done \n");
capture
->
sequence
=
buf
.
sequence
;
return
1
;
}
...
...
@@ -1237,16 +1251,16 @@ static int icvGrabFrameCAM_V4L(CvCaptureCAM_V4L* capture) {
}
else
{
capture
->
mmaps
[
capture
->
bufferIndex
].
frame
=
capture
->
bufferIndex
;
capture
->
mmaps
[
capture
->
bufferIndex
].
width
=
capture
->
captureWindow
.
width
;
capture
->
mmaps
[
capture
->
bufferIndex
].
height
=
capture
->
captureWindow
.
height
;
capture
->
mmaps
[
capture
->
bufferIndex
].
format
=
capture
->
imageProperties
.
palette
;
capture
->
mmaps
[
capture
->
bufferIndex
].
frame
=
capture
->
bufferIndex
;
capture
->
mmaps
[
capture
->
bufferIndex
].
width
=
capture
->
captureWindow
.
width
;
capture
->
mmaps
[
capture
->
bufferIndex
].
height
=
capture
->
captureWindow
.
height
;
capture
->
mmaps
[
capture
->
bufferIndex
].
format
=
capture
->
imageProperties
.
palette
;
if
(
v4l1_ioctl
(
capture
->
deviceHandle
,
VIDIOCMCAPTURE
,
&
capture
->
mmaps
[
capture
->
bufferIndex
])
==
-
1
)
{
/* capture is on the way, so just exit */
return
1
;
}
if
(
v4l1_ioctl
(
capture
->
deviceHandle
,
VIDIOCMCAPTURE
,
&
capture
->
mmaps
[
capture
->
bufferIndex
])
==
-
1
)
{
/* capture is on the way, so just exit */
return
1
;
}
++
capture
->
bufferIndex
;
if
(
capture
->
bufferIndex
==
capture
->
memoryBuffer
.
frames
)
{
...
...
@@ -1362,6 +1376,36 @@ static double icvGetPropertyCAM_V4L (CvCaptureCAM_V4L* capture,
}
}
return
(
property_id
==
CV_CAP_PROP_FRAME_WIDTH
)
?
capture
->
form
.
fmt
.
pix
.
width
:
capture
->
form
.
fmt
.
pix
.
height
;
case
CV_CAP_PROP_POS_MSEC
:
if
(
capture
->
FirstCapture
)
{
return
0
;
}
else
{
//would be maximally numerically stable to cast to convert as bits, but would also be counterintuitive to decode
return
1000
*
capture
->
timestamp
.
tv_sec
+
((
double
)
capture
->
timestamp
.
tv_usec
)
/
1000
;
}
break
;
case
CV_CAP_PROP_POS_FRAMES
:
return
capture
->
sequence
;
break
;
case
CV_CAP_PROP_FPS
:
{
struct
v4l2_streamparm
sp
;
memset
(
&
sp
,
0
,
sizeof
(
struct
v4l2_streamparm
));
sp
.
type
=
V4L2_BUF_TYPE_VIDEO_CAPTURE
;
if
(
xioctl
(
capture
->
deviceHandle
,
VIDIOC_G_PARM
,
&
sp
)
<
0
){
fprintf
(
stderr
,
"VIDEOIO ERROR: V4L: Unable to get camera FPS
\n
"
);
return
(
double
)
-
1
;
}
// this is the captureable, not per say what you'll get..
double
framesPerSec
=
sp
.
parm
.
capture
.
timeperframe
.
denominator
/
(
double
)
sp
.
parm
.
capture
.
timeperframe
.
numerator
;
return
framesPerSec
;
}
break
;
case
CV_CAP_PROP_MODE
:
return
capture
->
mode
;
break
;
...
...
@@ -1507,13 +1551,17 @@ static int icvSetVideoSize( CvCaptureCAM_V4L* capture, int w, int h) {
xioctl
(
capture
->
deviceHandle
,
VIDIOC_S_FMT
,
&
capture
->
form
);
/* try to set framerate to 30 fps */
struct
v4l2_streamparm
setfps
;
memset
(
&
setfps
,
0
,
sizeof
(
struct
v4l2_streamparm
));
setfps
.
type
=
V4L2_BUF_TYPE_VIDEO_CAPTURE
;
setfps
.
parm
.
capture
.
timeperframe
.
numerator
=
1
;
setfps
.
parm
.
capture
.
timeperframe
.
denominator
=
30
;
xioctl
(
capture
->
deviceHandle
,
VIDIOC_S_PARM
,
&
setfps
);
/* we need to re-initialize some things, like buffers, because the size has
* changed */
capture
->
FirstCapture
=
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录