Android CameraBridgeViewBase - deliverAndDrawFrame insights

asked 2019-05-22 04:39:45 -0500

david.serrano gravatar image

updated 2019-05-22 04:51:40 -0500

Hi all,

I have a question regarding the protected void deliverAndDrawFrame(CvCameraViewFrame frame) method available in CameraBridgeViewBase. I've tried to use it in the way exemplified by JavaCamera2View but that entire class doesn't seem to work.

Having a look at the internals, it seems that before providing the frame, we need to convert the Image provided by the Camera2 API into a YUV_420 Mat and then pass it to the frame method. Doing this in the manner shown in the example CameraView crashes the app on all phones i've tried that have a Camera2 Support level of LEGACY or higher...

My question is, if internally in the BridgeViewBase the frame gets converted into a Bitmap, wouldn't it be easier to provide that initially from the Image object? Or a byte[] that contains the data, so the conversion between formats only needs to happen once?

I've got those methods implemented in a custom version of CameraBridgeViewBase and they seem to work like a charm, my only issue at the moment is that the class needs to have implicit knowledge of how to build a Camera2Frame, but I'm working on resolving that.

Is there anything I'm missing here that's super obvious as to why this methodology has not been followed? Or should i once the implicit knowledge issue has been solved, submit a PR?

Thanks in advance for any answers :)

edit retag flag offensive close merge delete