-
-
Notifications
You must be signed in to change notification settings - Fork 56.4k
Implement color conversion from RGB to YUV422 family #24333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… into CvtRGB2YUV422
… into CvtRGB2YUV422
… into CvtRGB2YUV422
|
@opencv-alalek : Thanks for taking a look! I've changed the sample filename to lowercase, and have removed the OpenCL parts from the sample code. I'll be happy to work on a separate sample code in the Do let me know if you have more comments! |
|
It looks like I misunderstood what test data means for performance tests. I've sent in a PR to opencv/extra with the updated sanity check data. With this updated data, the perf tests are able to run successfully on my machine using the command from the presently unsuccessful CI run. Edit: I also realized that I'd missed having the same name for my branch on Would it be possible to retry the CI build with the updated sanity check data? |
|
Please take a look on issues from OpenCL build configuration: https://pullrequest.opencv.org/buildbot/builders/precommit_opencl/builds/100210 |
|
@opencv-alalek Found the problem, it was a wrong step length that never executed on my machine due to the rows per OpenCL work item being set to 1, but did so on the build server. |
|
@asmorkalov @opencv-alalek I took a look at the errors from the recent run. I've pushed a fix for the warning about the double incrementing that appeared in the MacOS builds. For Ubuntu 22.04 and Android, it just says
during the initial setup. Not sure what that is, but let me know if there's anything I can do about it. |
|
We have troubles with one of CI servers. Please ignore the issue right now. OpenCV team works on it. |
|
@asmorkalov @opencv-alalek Thanks for reviewing! I cleaned up the code and made the sample code display the scaled diff as you did. I've also mentioned my source for the coefficients where they appear and adjusted them to more rigorously derived values. As for the results, I'm getting a visually similar scaled diff as above with the new coefficients as well: IIUC, conversion from RGB to YUV422 isn't an invertible transformation on account of using 1 byte less per pixel, so some difference is unavoidable to begin with. Added to that, the values are clipped to 0-255 with finite precision, which is likely causing further losses. Perhaps it'll work better with float images, but I'm not sure if anything can be done at all about integer images. Let me know if you have any suggestions or other comments. |
|
It looks like the
Both of these seem to be unrelated, but let me know if I can check anything in the PR. |
|
FYI, I updated the perf sanity data due to the change in coefficients for good measure, even though it was passing with the previous data. |
|
@asmorkalov Just checking in to see if you're waiting on anything to get done. The builds are all passing so I'm assuming it's good to go. |
Implement color conversion from RGB to YUV422 family opencv#24333 Related PR for extra: opencv/opencv_extra#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
Implement color conversion from RGB to YUV422 family opencv#24333 Related PR for extra: opencv/opencv_extra#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


Related PR for extra: opencv/opencv_extra#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_RGB2YUV422that 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