ToFCamera
ToFScanner: Camera2-based Time-of-Flight depth sensor scanner
Designed for Zebra TC73/TC78 devices with hardware ToF sensors (Camera ID: 2). Can operate independently of ARCore for pure Camera2 depth capture.
FIXES IMPLEMENTED FOR CONSTANT 8192mm DEPTH VALUES:
ROOT CAUSE FOUND: Sensor exposure time was 0ns - IR emitter was not activating!
FIX 1: Enable AUTO_EXPOSURE mode (THE CRITICAL FIX!) - Previous code disabled AE mode (CONTROL_AE_MODE_OFF) → 0ns exposure → no IR - Now enables AE mode (CONTROL_AE_MODE_ON) → camera controls IR emitter timing - Fallback: Manual exposure mode with explicit 20ms exposure + ISO 400 - Location: createCameraPreviewSession() - USE_AUTO_EXPOSURE flag
FIX 2: Configurable capture templates for experimentation - Started with TEMPLATE_PREVIEW (default for continuous streaming) - Can try TEMPLATE_RECORD or TEMPLATE_VIDEO_RECORD if needed - Location: CURRENT_TEMPLATE constant in companion object
FIX 3: Zero-exposure detection and diagnostics - Detects if exposure is still 0ns after enabling AE - Provides clear error message with troubleshooting steps - Suggests next templates/modes to try - Location: CaptureCallback.onCaptureCompleted()
FIX 4: Comprehensive sensor diagnostics - Logs all camera capabilities, control modes, AF/AE availability - Monitors capture results for exposure time, ISO, frame duration - Tracks capture success/failure rates - Location: startSession() and CaptureCallback
FIX 5: Stuck-depth-value detection (8192mm histogram analysis) - Detects when >90% of pixels have the same value - Provides actionable error messages - Location: processDepthImage()
EXPECTED RESULT: With AE mode enabled, exposure time should be non-zero (typically 10-30ms) and ToF sensor should return varying depth values instead of constant 8192mm.
If exposure is STILL zero after this fix:
Try changing CURRENT_TEMPLATE to CameraDevice.TEMPLATE_RECORD
Try USE_AUTO_EXPOSURE = false with manual exposure
Contact Zebra support - may require vendor-specific Camera2 parameters
Functions
Get the latest depth image from the ToF sensor. This is used by ARCoreScanner to create FrameData with matched RGB colors. Caller must close the image after use.
Get ToF camera intrinsics for use with FrameData creation
Start ToF scanning session. This initializes EMDK first to enable the ToF sensor, then opens the camera.