Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
8db1a731
Commit
8db1a731
authored
Apr 02, 2013
by
dave
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added v4l2 support for getting capture property CV_CAP_PROP_POS_MSEC
parent
87bb7ff5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
cap_v4l.cpp
modules/highgui/src/cap_v4l.cpp
+20
-0
No files found.
modules/highgui/src/cap_v4l.cpp
View file @
8db1a731
...
...
@@ -154,6 +154,11 @@ the symptoms were damaged image and 'Corrupt JPEG data: premature end of data se
- USE_TEMP_BUFFER fixes the main problem (improper buffer management) and
prevents bad images in the first place
11th patch: April 2, 2013, Forrest Reiling forrest.reiling@gmail.com
Added v4l2 support for getting capture property CV_CAP_PROP_POS_MSEC.
Returns the millisecond timestamp of the last frame grabbed or 0 if no frames have been grabbed
Used to successfully synchonize 2 Logitech C310 USB webcams to within 16 ms of one another
make & enjoy!
...
...
@@ -320,6 +325,8 @@ typedef struct CvCaptureCAM_V4L
struct
v4l2_queryctrl
queryctrl
;
struct
v4l2_querymenu
querymenu
;
struct
timeval
timestamp
;
/* V4L2 control variables */
int
v4l2_brightness
,
v4l2_brightness_min
,
v4l2_brightness_max
;
int
v4l2_contrast
,
v4l2_contrast_min
,
v4l2_contrast_max
;
...
...
@@ -836,6 +843,9 @@ static int _capture_V4L2 (CvCaptureCAM_V4L *capture, char *deviceName)
capture
->
v4l2_gain_max
=
0
;
capture
->
v4l2_exposure_max
=
0
;
capture
->
timestamp
.
tv_sec
=
0
;
capture
->
timestamp
.
tv_usec
=
0
;
/* Scan V4L2 controls */
v4l2_scan_controls
(
capture
);
...
...
@@ -1221,6 +1231,9 @@ static int read_frame_v4l2(CvCaptureCAM_V4L* capture) {
if
(
-
1
==
ioctl
(
capture
->
deviceHandle
,
VIDIOC_QBUF
,
&
buf
))
perror
(
"VIDIOC_QBUF"
);
//set timestamp in capture struct to be timestamp of most recent frame
capture
->
timestamp
=
buf
.
timestamp
;
return
1
;
}
...
...
@@ -2308,6 +2321,13 @@ static double icvGetPropertyCAM_V4L (CvCaptureCAM_V4L* capture,
/* initialize the control structure */
switch
(
property_id
)
{
case
CV_CAP_PROP_POS_MSEC
:
if
(
capture
->
FirstCapture
)
{
return
0
;
}
else
{
return
1000
*
capture
->
timestamp
.
tv_sec
+
((
double
)
capture
->
timestamp
.
tv_usec
)
/
1000
;
}
break
;
case
CV_CAP_PROP_BRIGHTNESS
:
capture
->
control
.
id
=
V4L2_CID_BRIGHTNESS
;
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment