How to Get Raw Preview Data from Camera Object at Least 15 Frames Per Second in Android

Drop Frames from the camera preview

No, you cannot intervene in frames on preview surface. You could do some tricks if you use TextureSurface for preview, but if you need very low frame rate, you can simply draw the frames (preferably, to an OpenGL texture) yourself. You will get the YUV frames in onPreveiewFrame() callback, and pass them for display when you want. You can use a shader to display the YUV frames without waisting CPU to convert them to RGB.

Usually, we want to skip preview frames because we want to run some CV algorithms on the frames, and often we want to display the frames modified by such CV processing, e.g. with bounding boxes of detected objects. Even if you have the coordinates of the box aside, and want to display the preview frame 'as is', using your own renderer has the advantage that there will be no time lag between the picture and the overlay.

How do we get the preview frame using CameraX?

You will use ImageAnalysis. The preview frames will be passed to your Analyzer in YUV_420_888 format.

If necessary, you can request non-blocking analysis mode. I would recommend to set a Handler for your Analyzer, so that the camera callbacks not arrive on the UI thread.



Related Topics



Leave a reply



Submit