I have application which is using hardware camera to make some analysis in OpenCV. I am using ImageReader to get frames, and then I am passing them to algorithm. But I would like to get only let's say 1 or 2 frames per second from ImageReader.
I was trying to do it like this:
val imageReaderListener = ImageReader.OnImageAvailableListener { reader ->
reader?.let {
fps++
if (fps > 30) {
val image = it.acquireLatestImage()
//mage calculations
fps = 0
image.close()
}
}
}
But unfortunately when ImageReader max images is set to 1 (I need only latest result to be shown to te user, so I do not need to increase this number), camera picture is getting freezed. So is there any way to decrease FPS going to ImageReader?