0
votes

I am developing an app where I want to process each frame from the camera and apply some Image processing algorithms on it. I am getting image feed from ImageReader inside onImageAvailable callback and passing it to my cpp code with JNI interface for further processing. This works fine until I perform heavy operations inside my cpp code, after that it starts adding delay and lag to camera preview. is it possible to process on feed images in parallel so I can achieve real-time results? I am already using a different thread for cameraCaptureSession.

1

1 Answers

1
votes

Increase the maxImage count for your ImageReader, so that you can be processing multiple images at the same time. But in the end, your throughput has to be 30fps in order to not slow down preview; parallel processing only helps if it (say) takes 100 ms to do your processing, but you can run 3 processing threads side-by-side (so a frame completes every 33 ms).

Alternatively, you can skip processing frames if you can't keep up; just check if your processing is still underway, and if it is, release the Image immediately. Of course, that won't help if your only output is the processed frame.