adding image analyzer

331 views
Skip to first unread message

martin seal

unread,
Jan 12, 2020, 5:15:38 AM1/12/20
to Android CameraX Discussion Group
Tutorials ive seen add an image analysis analyzer to the bind lifecycle method, it seems we cant add this anymore as the analyzer isnt a camera core use case? however the image analysis is a use case but passing this to the bind lifecycle method causes the camera (preview view) to refresh over and over, (dialog under emulator press X to move camera repeatedly flashes) have i got this wrong?


imageAnalysis = getImageAnalysis();

analyzer = getImageAnalyzer();

Log.d(TAG, "set image analyzer");
imageAnalysis.setAnalyzer(imageAnalyzerExecutor, analyzer);

// Apply declared configs to CameraX using the same lifecycle owner
cameraProvider.bindToLifecycle(this, cameraSelector, preview, imageCapture, imageAnalysis);


@SuppressLint("UnsafeExperimentalUsageError")
@NotNull
private ImageAnalysis.Analyzer getImageAnalyzer() {
return image -> {
//analyze image with tensor flow here
Log.d(TAG,"try to analyze image");
};
}

@NotNull
private ImageAnalysis getImageAnalysis() {
return new ImageAnalysis.Builder()
.setTargetAspectRatio(AspectRatio.RATIO_4_3)
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
.build();
}

Scott Nien

unread,
Jan 12, 2020, 9:15:22 PM1/12/20
to martin seal, Android CameraX Discussion Group
What happens when you try to use ImageAnalysis ?   ImageAnalysis is still a use case in camerax-core.   
but please note that starting from Camera-Core Version 1.0.0-alpha07,   apps have to close the Image(image.close()) in apps' Analyzer implementation otherwise the analyzer will not work properly. 

--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/04312aa0-fd8e-458b-ab69-54e1730ec66a%40android.com.

martin seal

unread,
Jan 13, 2020, 1:16:19 AM1/13/20
to Android CameraX Discussion Group
Thanks for your reply yes I'm calling image.close, (I know I haven't added it in this snippet) when I add the image analysis I get the behaviour I've described above so the UI becomes almost unresponsive and the message below the emulator (hold X to rotate camera) flashes constantly like the preview view is being constantly refreshed or redrawn

Scott Nien

unread,
Jan 13, 2020, 2:20:00 AM1/13/20
to martin seal, Android CameraX Discussion Group
I think this is probably a bug of the emulator.  Can you try to run on real devices and see if there are still issues ?

On Mon, Jan 13, 2020 at 2:16 PM 'martin seal' via Android CameraX Discussion Group <camerax-d...@android.com> wrote:
Thanks for your reply yes I'm calling image.close, (I know I haven't added it in this snippet) when I add the image analysis I get the behaviour I've described above so the UI becomes almost unresponsive and the message below the emulator (hold X to rotate camera) flashes constantly like the preview view is being constantly refreshed or redrawn

--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.

martin seal

unread,
Jan 13, 2020, 3:23:12 AM1/13/20
to Android CameraX Discussion Group, martins...@googlemail.com
tried on a real device and your right it seems ok, camera doesnt seem to be refreshed (tell by the focusing) and the analyzer is printing like it should, and the ui seems responsive, strange but many thanks


On Monday, January 13, 2020 at 7:20:00 AM UTC, Scott Nien wrote:
I think this is probably a bug of the emulator.  Can you try to run on real devices and see if there are still issues ?

On Mon, Jan 13, 2020 at 2:16 PM 'martin seal' via Android CameraX Discussion Group <camerax-d...@android.com> wrote:
Thanks for your reply yes I'm calling image.close, (I know I haven't added it in this snippet) when I add the image analysis I get the behaviour I've described above so the UI becomes almost unresponsive and the message below the emulator (hold X to rotate camera) flashes constantly like the preview view is being constantly refreshed or redrawn

--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-developers+unsub...@android.com.

Scott Nien

unread,
Jan 30, 2020, 10:00:52 PM1/30/20
to martin seal, Android CameraX Discussion Group
Hi Martin, 
I 've created an issue on public tracker and CC'ed you. 
https://issuetracker.google.com/148640346  

The issue is kind of misleading that developers could think ImageAnalysis is not working properly . 

Scott

On Mon, Jan 13, 2020 at 4:23 PM 'martin seal' via Android CameraX Discussion Group <camerax-d...@android.com> wrote:
tried on a real device and your right it seems ok, camera doesnt seem to be refreshed (tell by the focusing) and the analyzer is printing like it should, and the ui seems responsive, strange but many thanks

On Monday, January 13, 2020 at 7:20:00 AM UTC, Scott Nien wrote:
I think this is probably a bug of the emulator.  Can you try to run on real devices and see if there are still issues ?

On Mon, Jan 13, 2020 at 2:16 PM 'martin seal' via Android CameraX Discussion Group <camerax-d...@android.com> wrote:
Thanks for your reply yes I'm calling image.close, (I know I haven't added it in this snippet) when I add the image analysis I get the behaviour I've described above so the UI becomes almost unresponsive and the message below the emulator (hold X to rotate camera) flashes constantly like the preview view is being constantly refreshed or redrawn

--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.

--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/e1b5ce25-6ea6-483e-85a3-a2ec51722cf5%40android.com.
Reply all
Reply to author
Forward
0 new messages