Parallel Processing with camera2 api android and opencvcamera2

半腔热情 提交于 2020-01-06 05:47:30

问题


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:


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.



来源:https://stackoverflow.com/questions/51666353/parallel-processing-with-camera2-api-android-and-opencvcamera2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!