6

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.

Billda
  • 5,707
  • 2
  • 25
  • 44
  • 2
    This seems like a potential bug, the second set analyzer doesn't seem to receive any frames from the camera. It would be great if you filed a bug for this issue. In the meantime, if you don't want to use a boolean flag, instead of dynamically adding/removing the Analyzer, you can dynamically add/remove the imageAnalysis use case itself. – Husayn Hakeem Mar 14 '20 at 00:11
  • Ok, reported https://issuetracker.google.com/issues/151605317. Thanks :) – Billda Mar 16 '20 at 14:24
  • @Billda, after some hours find your question for the same problem. Have you found another way to solve the problem? – Jon Mar 25 '20 at 07:52
  • 1
    @Jon no, i've ended up with Boolean flag in my analyzer, but you can try the solution that Husayn suggested – Billda Mar 26 '20 at 08:05

1 Answers1

0

Seems like this bug is fixed now, but if anyone still stumbles upon such behavior, make sure you didn't forget to call ImageProxy.close() somewhere.

Eyjafl
  • 1,046
  • 6
  • 14