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
4701b22e
Commit
4701b22e
authored
Mar 03, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3607 from soyersoyer:yuyv_pixfmt
parents
dcff28b7
d84d3a51
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
12 deletions
+21
-12
videoio.hpp
modules/videoio/include/opencv2/videoio.hpp
+2
-1
videoio_c.h
modules/videoio/include/opencv2/videoio/videoio_c.h
+2
-1
cap_libv4l.cpp
modules/videoio/src/cap_libv4l.cpp
+17
-10
No files found.
modules/videoio/include/opencv2/videoio.hpp
View file @
4701b22e
...
...
@@ -136,7 +136,8 @@ enum { CAP_PROP_POS_MSEC =0,
// Currently, these are supported through the libv4l interface only.
enum
{
CAP_MODE_BGR
=
0
,
// BGR24 (default)
CAP_MODE_RGB
=
1
,
// RGB24
CAP_MODE_GRAY
=
2
// Y8
CAP_MODE_GRAY
=
2
,
// Y8
CAP_MODE_YUYV
=
3
// YUYV
};
...
...
modules/videoio/include/opencv2/videoio/videoio_c.h
View file @
4701b22e
...
...
@@ -299,7 +299,8 @@ enum
{
CV_CAP_MODE_BGR
=
0
,
// BGR24 (default)
CV_CAP_MODE_RGB
=
1
,
// RGB24
CV_CAP_MODE_GRAY
=
2
// Y8
CV_CAP_MODE_GRAY
=
2
,
// Y8
CV_CAP_MODE_YUYV
=
3
// YUYV
};
enum
...
...
modules/videoio/src/cap_libv4l.cpp
View file @
4701b22e
...
...
@@ -646,6 +646,8 @@ static inline int channels_for_mode(int mode)
switch
(
mode
)
{
case
CV_CAP_MODE_GRAY
:
return
1
;
case
CV_CAP_MODE_YUYV
:
return
2
;
default:
return
3
;
}
...
...
@@ -713,31 +715,26 @@ static int _capture_V4L2 (CvCaptureCAM_V4L *capture, char *deviceName)
/* libv4l will convert from any format to V4L2_PIX_FMT_BGR24,
V4L2_PIX_FMT_RGV24, or V4L2_PIX_FMT_YUV420 */
unsigned
int
requestedPixelFormat
;
int
width
;
int
height
;
switch
(
capture
->
mode
)
{
case
CV_CAP_MODE_RGB
:
requestedPixelFormat
=
V4L2_PIX_FMT_RGB24
;
width
=
capture
->
width
;
height
=
capture
->
height
;
break
;
case
CV_CAP_MODE_GRAY
:
requestedPixelFormat
=
V4L2_PIX_FMT_YUV420
;
width
=
capture
->
width
;
height
=
capture
->
height
;
break
;
case
CV_CAP_MODE_YUYV
:
requestedPixelFormat
=
V4L2_PIX_FMT_YUYV
;
break
;
default:
requestedPixelFormat
=
V4L2_PIX_FMT_BGR24
;
width
=
capture
->
width
;
height
=
capture
->
height
;
break
;
}
CLEAR
(
capture
->
form
);
capture
->
form
.
type
=
V4L2_BUF_TYPE_VIDEO_CAPTURE
;
capture
->
form
.
fmt
.
pix
.
pixelformat
=
requestedPixelFormat
;
capture
->
form
.
fmt
.
pix
.
field
=
V4L2_FIELD_ANY
;
capture
->
form
.
fmt
.
pix
.
width
=
width
;
capture
->
form
.
fmt
.
pix
.
height
=
height
;
capture
->
form
.
fmt
.
pix
.
width
=
capture
->
width
;
capture
->
form
.
fmt
.
pix
.
height
=
capture
->
height
;
if
(
-
1
==
xioctl
(
capture
->
deviceHandle
,
VIDIOC_S_FMT
,
&
capture
->
form
))
{
fprintf
(
stderr
,
"VIDEOIO ERROR: libv4l unable to ioctl S_FMT
\n
"
);
...
...
@@ -949,6 +946,10 @@ static int _capture_V4L (CvCaptureCAM_V4L *capture, char *deviceName)
requestedVideoPalette
=
VIDEO_PALETTE_YUV420
;
depth
=
8
;
break
;
case
CV_CAP_MODE_YUYV
:
requestedVideoPalette
=
VIDEO_PALETTE_YUYV
;
depth
=
16
;
break
;
default:
requestedVideoPalette
=
VIDEO_PALETTE_RGB24
;
depth
=
24
;
...
...
@@ -1319,6 +1320,7 @@ static IplImage* icvRetrieveFrameCAM_V4L( CvCaptureCAM_V4L* capture, int) {
switch
(
capture
->
imageProperties
.
palette
)
{
case
VIDEO_PALETTE_RGB24
:
case
VIDEO_PALETTE_YUV420
:
case
VIDEO_PALETTE_YUYV
:
memcpy
((
char
*
)
capture
->
frame
.
imageData
,
(
char
*
)(
capture
->
memoryMap
+
capture
->
memoryBuffer
.
offsets
[
capture
->
bufferIndex
]),
capture
->
frame
.
imageSize
);
...
...
@@ -1464,6 +1466,10 @@ static int icvSetVideoSize( CvCaptureCAM_V4L* capture, int w, int h) {
cropHeight
=
h
*
8
;
cropWidth
=
w
*
8
;
break
;
case
CV_CAP_MODE_YUYV
:
cropHeight
=
h
*
16
;
cropWidth
=
w
*
16
;
break
;
default:
cropHeight
=
h
*
24
;
cropWidth
=
w
*
24
;
...
...
@@ -1719,6 +1725,7 @@ static int icvSetPropertyCAM_V4L(CvCaptureCAM_V4L* capture, int property_id, dou
case
CV_CAP_MODE_BGR
:
case
CV_CAP_MODE_RGB
:
case
CV_CAP_MODE_GRAY
:
case
CV_CAP_MODE_YUYV
:
capture
->
mode
=
mode
;
/* recreate the capture buffer for the same output resolution
but a different pixel format */
...
...
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