I\'m creating a tool to capture every frame from preview using cameraX (for face recognition purpose)
I found that using ImageAnalysis was the way to go.
Unt
You can also find the implementation in the official CameraX sample app: CameraFragment.kt.
The part which you need is this:
// Executor field
private lateinit var analysisExecutor: Executor
// in onCreate()
analysisExecutor = Executors.newSingleThreadExecutor()
// after initializing imageAnalysis
imageAnalysis.setAnalyzer(analysisExecutor, ImageAnalysis.Analyzer {
// TODO analyze
})
If you're wondering whether to use Executors.newSingleThreadExecutor(), Executors.newFixedThreadPool(n) or something else, take a look at the Executors documentation.