cvtColor YUV420 specification bug (Bug #1613)


Added by Robert Abel about 13 years ago. Updated about 13 years ago.


Status:Done Start date:2012-02-21
Priority:Normal Due date:
Assignee:Andrey Kamaev % Done:

0%

Category:imgproc, video
Target version:2.4.0
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

The newly added YUV420i and YUV420sp formats are actually a misnomer. They were added around Revision 6788 by Andrey Kamaev.

However, the implemented formats are actually not YUV420i and YUV420sp, but instead YUV420sp and YVU420sp. The (SP or I) offset/flag, will actually only decide whether the semi-planes following the Y plane are ordered UVUV... or VUVU... The code does not seem to process interlaced YUV420 at all, which would be YUYV etc., so the naming scheme/specification is clearly broken.

A good format reference can be found at MSDN and Texas Instruments. The currently implemented formats in OpenCV are NV21 and NV12 (see V4L2 documentation), which correspond to YUV420sp and YVU420sp, respectively.

YUV420i and YVU420i would be YUYV and YVYU formats (see V4L2 documentation again), respectively. Plain planar YUV420p and YVU420p, i.e. YU12 and YV12 (see V4L2 documentation) -- which is what led me to finding this mistake in the first place -- also don't seem to be supported :/

I'm not sure what the current policy on changing these identifiers is, but IMHO it would be preferrable if YUV420i conversion formats were removed from OpenCV until they are implemented. Or, if regression in the codebase poses a problem, aliasing the conversions using proper names, i.e. YUV420sp and YVU420sp.

Now that I'm thoroughly confused by all the abbreviations, I hope this ticket gets noticed :D


Associated revisions

Revision e426dfc3
Added by Andrey Kamaev about 13 years ago

Fixed #1613: removed YUV420i color conversion constants

Revision 7605426d
Added by Andrey Pavlenko over 11 years ago

Merge pull request #1613 from alalek:ocl_cvtcolor

History

Updated by Andrey Kamaev about 13 years ago

Thanks for reporting!

In general you are correct. But YUV420i is not a YUYV format (which belongs to 422 formats). And no one of provided links shows what it is.

Actually I think that yuv420i does not name any real format. Initially this name come from one of Android devices used for testing of Android port of OpenCV. The device mistakenly reports its frame format as yuv420i while the data is correctly packed as yuv420sp. And the name was eventually propagated to the code base.

The incorrect format naming was already identified some time ago and correct aliases were added to the OpenCV trunk. Now I've completely removed the confusing 420i names. Currently OpenCV trunk provides the following conversions for the packed YUV:

    CV_YUV2RGB_NV12 = 90,
    CV_YUV2BGR_NV12 = 91,    
    CV_YUV2RGB_NV21 = 92,
    CV_YUV2BGR_NV21 = 93,
    CV_YUV420sp2RGB = CV_YUV2RGB_NV21,
    CV_YUV420sp2BGR = CV_YUV2BGR_NV21,

    CV_YUV2RGBA_NV12 = 94,
    CV_YUV2BGRA_NV12 = 95,
    CV_YUV2RGBA_NV21 = 96,
    CV_YUV2BGRA_NV21 = 97,
    CV_YUV420sp2RGBA = CV_YUV2RGBA_NV21,
    CV_YUV420sp2BGRA = CV_YUV2BGRA_NV21,

  • Status changed from Open to Done
  • Target version set to 2.4.0

Also available in: Atom PDF