Android NDK camera support #19597
Android NDK camera support #19597
Conversation
Well done! Thank you for contribution |
0553543
into
opencv:master
So, should now with this update |
@jumpy88 it will work for any device that is accessible to the Android NDK Camera API (https://developer.android.com/ndk/reference/group/camera)
This link is aimed at device manufacturers who are building the Android OS itself, not general Android app developers. (Also note: Camera2 is a Java API whereas the OpenCV |
@komakai Ops, sorry, I thought Camera2 was an API for developers and it was accessible in Android NDK. My knowledge about Android is still very poor. Ok, I'll give it a try with your code and will post the result. |
Hi, I've just done some experiments with 2e2df44 commit in a Godot Engine proof of concept. It works with built-in cameras but doesn't seem to recognize external USB cameras. The only weird thing is sometimes the visualized frame appears having blue and red channels swapped, but I don't have enough information to open an issue (I don't know if it's due to OpenCV itself or is my fault). You can find the sample code here https://github.com/jumpy88/godot_ocv-camera-reader |
} | ||
return true; | ||
case CV_CAP_PROP_CONVERT_RGB: | ||
convertToRgb = (value != 0); |
alalek
Mar 25, 2021
Contributor
cv::cvtColor(yuv, out, convertToRgb ? cv::COLOR_YUV2RGB_YV12 : cv::COLOR_YUV2BGR_YV12);
BTW, meaning of this property is different (name misleads unfortunately, it is not BGR / RGB switch):
- CV_CAP_PROP_CONVERT_RGB = 1 (default): VideoCapture returns frames as "BGR" 8UC3 cv::Mat.
- CV_CAP_PROP_CONVERT_RGB = 0: VideoCapture returns frames in other formats, like NV12, Y8, etc (format is retrieved and/or sometimes specified through
CAP_PROP_FOURCC
)
cv::cvtColor(yuv, out, convertToRgb ? cv::COLOR_YUV2RGB_YV12 : cv::COLOR_YUV2BGR_YV12);
BTW, meaning of this property is different (name misleads unfortunately, it is not BGR / RGB switch):
- CV_CAP_PROP_CONVERT_RGB = 1 (default): VideoCapture returns frames as "BGR" 8UC3 cv::Mat.
- CV_CAP_PROP_CONVERT_RGB = 0: VideoCapture returns frames in other formats, like NV12, Y8, etc (format is retrieved and/or sometimes specified through
CAP_PROP_FOURCC
)
komakai
Mar 26, 2021
Author
Contributor
@alalek OK thanks for the explanation - will prepare a fix for this when I get a minute.
@alalek OK thanks for the explanation - will prepare a fix for this when I get a minute.
splinterwhatever
Mar 26, 2021
Is there a space in the api to allow for the BGR/RGB switch in addition to the correct convertToRGB behaviour?
cheers, Jeff
Is there a space in the api to allow for the BGR/RGB switch in addition to the correct convertToRGB behaviour?
cheers, Jeff
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
This PR fixes #11952
Add an Android native camera capture backend to the
videoio
module.Based loosely on https://github.com/android/ndk-samples/tree/main/camera
Requires Android native API level 24 or above (in order to access NDK camera APIs)