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
7d7767ba
Commit
7d7767ba
authored
Aug 04, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12134 from mshabunin:add-yuv420-v4l
parents
183cfd3a
a2daf0c8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
cap_v4l.cpp
modules/videoio/src/cap_v4l.cpp
+8
-3
No files found.
modules/videoio/src/cap_v4l.cpp
View file @
7d7767ba
...
...
@@ -431,6 +431,7 @@ static int autosetup_capture_mode_v4l2(CvCaptureCAM_V4L* capture) {
V4L2_PIX_FMT_BGR24
,
V4L2_PIX_FMT_RGB24
,
V4L2_PIX_FMT_YVU420
,
V4L2_PIX_FMT_YUV420
,
V4L2_PIX_FMT_YUV411P
,
V4L2_PIX_FMT_YUYV
,
V4L2_PIX_FMT_UYVY
,
...
...
@@ -531,6 +532,7 @@ static int v4l2_set_fps(CvCaptureCAM_V4L* capture) {
static
int
v4l2_num_channels
(
__u32
palette
)
{
switch
(
palette
)
{
case
V4L2_PIX_FMT_YVU420
:
case
V4L2_PIX_FMT_YUV420
:
case
V4L2_PIX_FMT_MJPEG
:
case
V4L2_PIX_FMT_JPEG
:
case
V4L2_PIX_FMT_Y16
:
...
...
@@ -560,6 +562,7 @@ static void v4l2_create_frame(CvCaptureCAM_V4L *capture) {
size
=
CvSize
(
capture
->
buffers
[
capture
->
bufferIndex
].
length
,
1
);
break
;
case
V4L2_PIX_FMT_YVU420
:
case
V4L2_PIX_FMT_YUV420
:
size
.
height
=
size
.
height
*
3
/
2
;
// "1.5" channels
break
;
case
V4L2_PIX_FMT_Y16
:
...
...
@@ -1019,10 +1022,10 @@ move_411_block(int yTL, int yTR, int yBL, int yBR, int u, int v,
/* Converts from planar YUV420P to RGB24. */
static
inline
void
yuv420p_to_rgb24
(
int
width
,
int
height
,
uchar
*
src
,
uchar
*
dst
)
yuv420p_to_rgb24
(
int
width
,
int
height
,
uchar
*
src
,
uchar
*
dst
,
bool
isYUV
)
{
cvtColor
(
Mat
(
height
*
3
/
2
,
width
,
CV_8U
,
src
),
Mat
(
height
,
width
,
CV_8UC3
,
dst
),
COLOR_YUV2BGR_YV12
);
isYUV
?
COLOR_YUV2BGR_IYUV
:
COLOR_YUV2BGR_YV12
);
}
// Consider a YUV411P image of 8x2 pixels.
...
...
@@ -1481,10 +1484,12 @@ static IplImage* icvRetrieveFrameCAM_V4L( CvCaptureCAM_V4L* capture, int) {
break
;
case
V4L2_PIX_FMT_YVU420
:
case
V4L2_PIX_FMT_YUV420
:
yuv420p_to_rgb24
(
capture
->
form
.
fmt
.
pix
.
width
,
capture
->
form
.
fmt
.
pix
.
height
,
(
unsigned
char
*
)(
capture
->
buffers
[
capture
->
bufferIndex
].
start
),
(
unsigned
char
*
)
capture
->
frame
.
imageData
);
(
unsigned
char
*
)
capture
->
frame
.
imageData
,
capture
->
palette
==
V4L2_PIX_FMT_YUV420
);
break
;
case
V4L2_PIX_FMT_YUV411P
:
...
...
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