(Camera2 API) Can I run 2 ImageReader instances of different configs at the same time?

314 Views Asked by At

I am modifying (Java) the TF Lite sample app for object detection. It has a live video feed that shows boxes around common objects. It takes in ImageReader frames at 640*480.

I want to use these bounds to crop the items, but I want to crop them from a high-quality image. I think the 5T is capable of 4K.

So, is it possible to run 2 instances of ImageReader, one low-quality video feed (used by TF Lite), and one for capturing full-quality still images? I also can't pin the 2nd one to any Surface for user preview, pic has to be captured in the background.

In this medium article (https://link.medium.com/2oaIYoY58db) it says "Due to hardware constraints, only a single configuration can be active in the camera sensor at any given time; this is called the active configuration."

I'm new to android here, so couldn't make much sense of this.

Thanks for your time!

PS: as far as I know, this isn't possible with CameraX, yet.

1

There are 1 best solutions below

3
On

As the cited article explains, you can use a lower-resolution preview stream and periodically capture higher-rez still images. Depending on hardware, this 'switch' may take time, or be really quick.

In your case, I would run a preview capture session at maximum resolution, and shrink (resize) the frames to feed into TFLite when necessary.