Android JavaCameraView Image Format NV21 and Conversion to RGB assuming NV12: (Bugfix #3553)
Description
Reviewing the source code of JavaCameraView.java (https://github.com/Itseez/opencv/blob/master/modules/java/generator/src/java/android%2BJavaCameraView.java
) for Android there seems to be a mismatch in the color conversion format.
On line 145 the image format is captured using NV21: params.setPreviewFormat(ImageFormat.NV21);
On line 291 the image is converted assuming it is captured using NV12 : Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2BGR_NV12, 4);
Is this correct?
Imgproc.cvtColor(mYuvFrameData, mRgba, Imgproc.COLOR_YUV2BGR_NV12, 4);
Associated revisions
Bug #3553 JavaCameraView frame format and cvtColor format inconsistency fixed.
History
Updated by Kirill Kornyakov about 11 years ago
Alexander, could you please check it?
- Assignee set to Alexander Smorkalov
- Category set to android
- Target version set to 2.4.9
Updated by Kirill Kornyakov about 11 years ago
- Status changed from New to Open
Updated by Kirill Kornyakov about 11 years ago
- Tracker changed from Bug to Bugfix
Updated by Alexander Smorkalov about 11 years ago
This inconsistency in color spaces is not issue actually. Java uses big-endian byte order. Native code on ARM uses little-endian byte order. NV12 and NV21 differs in order U and V component. So usage of NV12 conversion compensates byte order issue. So we do not need to do change conversion type, but may be add check and uses different conversions (http://developer.android.com/reference/java/nio/ByteOrder.html). Also comments in code will be usefull too.
Updated by Alexander Smorkalov about 11 years ago
- Pull request set to https://github.com/Itseez/opencv/pull/2413
- Difficulty set to Easy
Updated by Alexander Smorkalov almost 11 years ago
I made a mistake in the previous statement. byte order in yuv frame does not depend on Java virtual mashine. It looks like OpenCV uses invalid color conversion. It looks the same but still invlid. The new pull request fixes the issue.
- Pull request changed from https://github.com/Itseez/opencv/pull/2413 to https://github.com/Itseez/opencv/pull/2542
Updated by Alexander Smorkalov almost 11 years ago
- Status changed from Open to Done