CARVIEW |
Navigation Menu
-
-
Notifications
You must be signed in to change notification settings - Fork 56.2k
AndroidMediaNdkCapture pixel format enhancement #26656
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
…R,BGRA,RGB,RGBA,GRAY) The output pixel format can now be selected by the user. It defaults to RGB in order to maintain compatibility with previous versions of the library. This should fix opencv#26616.
…rty from AndroidMediaNdkCapture Unsupported or unavailable properties should return -1.
…l format AndroidMediaNdkVideoWriter also defaults to BGR. So let's be consistent.
videoWidth(0), videoHeight(0), | ||
videoFrameCount(0), | ||
frameStride(0), frameWidth(0), frameHeight(0), | ||
colorFormat(COLOR_FormatUnknown), fourCC(FOURCC_BGR), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attention: default output become BGR for Android too.
@warped-rudi Thanks a lot for the contribution. The BGR->RGB is breaking change. I'll will discuss it with core team and return back. We also have NativeView class based on VideoCapture. Please add color space setter there to prevent wrong colors. |
I think the cause of the problem is the following: From this code here I gather, that the intention is to produce BGR. The reason why we get something like RGB instead is, that the source format is not NV21, but NV12. This is backed by line 514. AndroidMediaNdkVideoWriter basically uses the same hardware accelerator and it's quite unlikely, that different formats get used for encoding and decoding. |
I can't find this class. Where is it? |
/cc @komakai |
O.K. I see. But this code uses a camera, which means that it instantiates 'AndroidCameraCapture' instead of 'AndroidMediaNdkCapture'. Thus it's unaffected by this change set. However, with #26627 in place, line 184 can be changed to directly capture BGR4 avoiding the conversion step in line 187. If you modify the code to read from a file instead from a camera, then you will see the bug reported in #26616 and the effect of this patch. |
Please also take a look on https://github.com/opencv/opencv/blob/4.x/samples/android/video-recorder/src/org/opencv/samples/recorder/RecorderActivity.java. Looks like we need to set proper output fourcc and drop cvtColor before imwrite. |
My understanding is that that video capturers should output frames in BGR format, so it appears there is a bug in my original implementation for Android. |
@asmorkalov : The recorder sample is affected. I will have look at it on weekend... |
…ced by opencv#26627 This avoids an intermediate color space conversion. Also fix some typos.
Avoid double initialization of the camera object after opencv#26627 is in place.
AndroidMediaNdkCapture pixel format enhancement opencv#26656 ### 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 - [ ] The PR is proposed to the proper branch - [ x] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
AndroidMediaNdkCapture pixel format enhancement opencv#26656 ### 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 - [ ] The PR is proposed to the proper branch - [ x] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.