Draw Bounding Boxes and Capture Video

192 views
Skip to first unread message

Petrus Caelestinus

unread,
Jul 4, 2023, 5:48:17 AM7/4/23
to Android CameraX Discussion Group
Hi. I use image analysis use case to detect objects and get the bounding boxes. Is it possible to draw the bounding box and capture the video?

Android CameraX Discussion Group

unread,
Jul 5, 2023, 4:15:30 AM7/5/23
to Android CameraX Discussion Group, petruspr...@gmail.com
Hello,

This discussion thread may answer your question. Please let us know if you need further information. Thanks!

- Julie

Xi Zhang (张熹)

unread,
Jul 5, 2023, 2:43:48 PM7/5/23
to Android CameraX Discussion Group, petruspr...@gmail.com
Thank you Julie for providing the link. 

The linked example is for rendering a static Bitmap.  Rendering a dynamic image on top of VideoCapture based on ImageAnalysis results is more complicated. You will need to buffer up the video frames, wait for ImageAnalysis to finish, then generate an image (the bounding box)  and blend it with the buffered videoframe. We understand that this is a common feature request. I plan to work on it in the near future but there is no ETA.

For now there isn't really a silver bullet. If you would like to try it yourself, the right way is using OpenGL. You can use CameraX's internal OpenGL renderer as your starting point. I understand that this might be challenging if you are not experienced with OpenGL.  Alternatively, there is a workaround that you can convert the ImageAnalysis frame to Bitmap, draw on top of it, and then write it to MediaCodec Surface. This is very inefficient and requires you to implement some of the VideoCapture logic. 

--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/3e17e56a-eef2-4b62-9697-d880be0d354cn%40android.com.
Reply all
Reply to author
Forward
0 new messages