mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 21:20:18 +08:00
videoio: added YUV420 format (UV order) support to v4l capture
This commit is contained in:
parent
2dbb5871e0
commit
a2daf0c83c
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user