Android CameraX - dynamically attach ImageAnalysis.Analyzer

Viewed 740

I have implemented my own subclass of ImageAnalysis.Analyzer and it works as expected. Now I want to "attach/detach" this analyzer to the ImageAnalysis class dynamically (based on some user actions). From the ImageAnalysis API it looks like it is possible, there is setAnalyzer method and also clearAnalyzer method. However, this works correctly only on the first setAnalyzer call. If I call then clearAnalyzer and setAnalyzer again, analyze method is not called.

In the documentation of clearAnalyzer method is

Removes a previously set analyzer.

This will stop data from streaming to the ImageAnalysis.

so it looks like its working maybe correctly as expected? That it will stop data streaming to ImageAnalysis. But is it possible to clear/set analyzer the way I want? I dont want to add some enabled boolean flags to my analyzer, there is threading issues, image queue issues and the solution with set/clear would be the cleanest I think.

0 Answers
Related