mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge pull request #24333 from definitelyuncertain:CvtRGB2YUV422
Implement color conversion from RGB to YUV422 family #24333 Related PR for extra: https://github.com/opencv/opencv_extra/pull/1104 Hi, This patch provides CPU and OpenCL implementations of color conversions from RGB/BGR to YUV422 family (such as UYVY and YUY2). These features would come in useful for enabling standard RGB images to be supplied as input to algorithms or networks that make use of images in YUV422 format directly (for example, on resource constrained devices working with camera images captured in YUV422). The code, tests and perf tests are all written following the existing pattern. There is also an example `bin/example_cpp_cvtColor_RGB2YUV422` that loads an image from disk, converts it from BGR to UYVY and then back to BGR, and displays the result as a visual check that the conversion works. The OpenCL performance for the forward conversion implemented here is the same as the existing backward conversion on my hardware. The CPU implementation, unfortunately, isn't very optimized as I am not yet familiar with the SIMD code. Please let me know if I need to fix something or can make other modifications. Thanks! ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
committed by
GitHub
parent
590f150d5e
commit
a1028efdcf
@@ -842,7 +842,41 @@ enum ColorConversionCodes {
|
||||
COLOR_BayerRG2RGBA = COLOR_BayerBG2BGRA, //!< equivalent to BGGR Bayer pattern
|
||||
COLOR_BayerGR2RGBA = COLOR_BayerGB2BGRA, //!< equivalent to GBRG Bayer pattern
|
||||
|
||||
COLOR_COLORCVT_MAX = 143
|
||||
//! RGB to YUV 4:2:2 family
|
||||
|
||||
COLOR_RGB2YUV_UYVY = 143,
|
||||
COLOR_BGR2YUV_UYVY = 144,
|
||||
COLOR_RGB2YUV_Y422 = COLOR_RGB2YUV_UYVY,
|
||||
COLOR_BGR2YUV_Y422 = COLOR_BGR2YUV_UYVY,
|
||||
COLOR_RGB2YUV_UYNV = COLOR_RGB2YUV_UYVY,
|
||||
COLOR_BGR2YUV_UYNV = COLOR_BGR2YUV_UYVY,
|
||||
|
||||
COLOR_RGBA2YUV_UYVY = 145,
|
||||
COLOR_BGRA2YUV_UYVY = 146,
|
||||
COLOR_RGBA2YUV_Y422 = COLOR_RGBA2YUV_UYVY,
|
||||
COLOR_BGRA2YUV_Y422 = COLOR_BGRA2YUV_UYVY,
|
||||
COLOR_RGBA2YUV_UYNV = COLOR_RGBA2YUV_UYVY,
|
||||
COLOR_BGRA2YUV_UYNV = COLOR_BGRA2YUV_UYVY,
|
||||
|
||||
COLOR_RGB2YUV_YUY2 = 147,
|
||||
COLOR_BGR2YUV_YUY2 = 148,
|
||||
COLOR_RGB2YUV_YVYU = 149,
|
||||
COLOR_BGR2YUV_YVYU = 150,
|
||||
COLOR_RGB2YUV_YUYV = COLOR_RGB2YUV_YUY2,
|
||||
COLOR_BGR2YUV_YUYV = COLOR_BGR2YUV_YUY2,
|
||||
COLOR_RGB2YUV_YUNV = COLOR_RGB2YUV_YUY2,
|
||||
COLOR_BGR2YUV_YUNV = COLOR_BGR2YUV_YUY2,
|
||||
|
||||
COLOR_RGBA2YUV_YUY2 = 151,
|
||||
COLOR_BGRA2YUV_YUY2 = 152,
|
||||
COLOR_RGBA2YUV_YVYU = 153,
|
||||
COLOR_BGRA2YUV_YVYU = 154,
|
||||
COLOR_RGBA2YUV_YUYV = COLOR_RGBA2YUV_YUY2,
|
||||
COLOR_BGRA2YUV_YUYV = COLOR_BGRA2YUV_YUY2,
|
||||
COLOR_RGBA2YUV_YUNV = COLOR_RGBA2YUV_YUY2,
|
||||
COLOR_BGRA2YUV_YUNV = COLOR_BGRA2YUV_YUY2,
|
||||
|
||||
COLOR_COLORCVT_MAX = 155
|
||||
};
|
||||
|
||||
//! @addtogroup imgproc_shape
|
||||
|
||||
@@ -224,6 +224,11 @@ CV_EXPORTS void cvtOnePlaneYUVtoBGR(const uchar * src_data, size_t src_step,
|
||||
int width, int height,
|
||||
int dcn, bool swapBlue, int uIdx, int ycn);
|
||||
|
||||
CV_EXPORTS void cvtOnePlaneBGRtoYUV(const uchar * src_data, size_t src_step,
|
||||
uchar * dst_data, size_t dst_step,
|
||||
int width, int height,
|
||||
int scn, bool swapBlue, int uIdx, int ycn);
|
||||
|
||||
CV_EXPORTS void cvtRGBAtoMultipliedRGBA(const uchar * src_data, size_t src_step,
|
||||
uchar * dst_data, size_t dst_step,
|
||||
int width, int height);
|
||||
|
||||
Reference in New Issue
Block a user