Black ImageAnalysis Use Case (VideoCapture + Preview fine)

48 views
Skip to first unread message
Assigned to charco...@google.com by me

Aubrey Haskett

unread,
Oct 21, 2024, 4:24:25 PMOct 21
to Android CameraX Discussion Group
Hi there CameraX! I see a number of posts in here about black preview screens, but they are old and I see some of those issues were resolved, so I'll post my similar but new problem below:

I am using Preview, VideoCapture, and ImageAnalysis use cases.
  • When using all 3, my Preview and recording resulting from VideoCapture look great, but my ImageAnalysis yields a black screen. 
  • I've noticed that, after I pinch to zoom in (so I call camera?.cameraControl?.setZoomRatio(intendedZoom)), the problem is resolved and ImageAnalysis output looks great. 
  • If I use Preview and VideoCapture only or Preview and ImageAnalysis only, those always work as well, without the pinch to zoom trick. 
  • I originally thought this was a resolution mismatch problem - maybe my device didn't have the right hardware level, but the fact that applying zoom fixes this is odd. 

Any ideas? Here's some info on my config:
  • I am using a Pixel 8 Pro with CameraX library 1.3.0. 
  • I have no use case binding errors and no quality, resolution, or cameraSelector builder errors.
  • I set the Preview and ImageAnalysis use cases' resolution like so (resolution parameter is my own variable, could be 480p or 720p: 
    • val resolutionSelector = ResolutionSelector.Builder().setResolutionStrategy(ResolutionStrategy(Size(resolution.width, resolution.height), ResolutionStrategy.FALLBACK_RULE_CLOSEST_HIGHER_THEN_LOWER)).setAspectRatioStrategy(AspectRatioStrategy(resolution.width / resolution.height, AspectRatioStrategy.FALLBACK_RULE_AUTO)).build()
  • I set the VideoCapture quality like so: 
    • val selector = QualitySelector.from(Quality.FHD,FallbackStrategy.higherQualityOrLowerThan(Quality.SD))
  • I am using the CameraSelector.DEFAULT_BACK_CAMERA
  • My Preview use case does not have an implementation mode strategy set, so it is defaulting to PERFORMANCE (changing to COMPATIBLE doesn't seem to fix issue)
  • My Image Analysis use case is set to use ROTATION_0 and back pressure strategy ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST
Many thanks for continuing to be active in this channel. You are always a big help, whether it be replies to me or others that I can read through. 

Charcoal Chen

unread,
Oct 31, 2024, 10:18:30 PMOct 31
to Android CameraX Discussion Group, aubrey....@gc.com
Thanks for reporting the issue and providing the detailed info.

I have created  https://issuetracker.google.com/issues/376774901 to track this issue. I'll update to the issue after clarifying the root cause.

Reply all
Reply to author
Forward
0 new messages