Skip to content

Add Capture Latency Estiamte Indicator for Extension #601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2025

Conversation

jsaund
Copy link
Contributor

@jsaund jsaund commented Jan 8, 2025

  • camera extension can query for the realtime capture latency estimate
  • display this as a hint to the user how long to hold still for

- camera extension can query for the realtime capture latency estimate
- display this as a hint to the user how long to hold still for
@madebymozart
Copy link
Contributor

Looks Good

@jsaund jsaund merged commit e691ae0 into android:main Jan 28, 2025
1 of 2 checks passed
@yrezgui
Copy link

yrezgui commented Mar 21, 2025

/gemini summarize

Copy link

Summary of Changes

This pull request introduces a capture latency estimate indicator for the camera extension in the CameraXExtensions app. The extension queries for the real-time capture latency estimate and displays it as a hint to the user, indicating how long they should hold still for optimal image capture. The changes involve modifying the MainActivity.kt, CameraUiState.kt, CameraExtensionsScreen.kt, CameraExtensionsViewModel.kt, CameraPreviewScreenViewState.kt, activity_main.xml, and strings.xml files.

Highlights

  • Capture Latency Estimate: The pull request adds the ability for the camera extension to query for the real-time capture latency estimate.
  • User Interface Hint: The capture latency estimate is displayed as a hint to the user, informing them how long to hold still.
  • UI Integration: A new TextView (latencyEstimateIndicator) is added to the layout to display the latency estimate, with associated logic to show/hide it based on the estimated latency.
  • Camera State Management: The CameraUiState is updated to include the realtimeCaptureLatencyEstimate, and the CameraState enum is extended with PREVIEW_ACTIVE.
  • Realtime Latency Observation: A coroutine job is started when the preview is active to observe and update the realtime latency estimate.

Changelog

Click here to see the changelog
  • CameraXExtensions/app/src/main/java/com/example/android/cameraxextensions/MainActivity.kt
    • Imported ImageCaptureLatencyEstimate from androidx.camera.core.
    • Added CAPTURE_LATENCY_INDICATOR_THRESHOLD_MS constant.
    • Added logging for camera state changes.
    • Implemented logic to show/hide the latency estimate indicator based on the realtimeCaptureLatencyEstimate.
    • Updated the UI state when the camera preview is active to show or hide the latency indicator based on the latency estimate.
  • CameraXExtensions/app/src/main/java/com/example/android/cameraxextensions/model/CameraUiState.kt
    • Imported ImageCaptureLatencyEstimate from androidx.camera.core.
    • Added realtimeCaptureLatencyEstimate property to CameraUiState.
    • Added PREVIEW_ACTIVE state to the CameraState enum.
  • CameraXExtensions/app/src/main/java/com/example/android/cameraxextensions/ui/CameraExtensionsScreen.kt
    • Imported TimeUnit and roundToInt.
    • Added latencyEstimateIndicator TextView.
    • Implemented showLatencyEstimate and hideLatencyEstimate functions to control the visibility and text of the latency indicator.
    • Updated the bindState function to show/hide the latency indicator based on the latencyEstimateIndicatorViewState.
  • CameraXExtensions/app/src/main/java/com/example/android/cameraxextensions/viewmodel/CameraExtensionsViewModel.kt
    • Imported Job, delay, isActive, asFlow, and CoroutineScope.
    • Added REALTIME_LATENCY_UPDATE_INTERVAL_MILLIS constant.
    • Added realtimeLatencyEstimateJob to manage the latency observation coroutine.
    • Implemented observeRealtimeLatencyEstimate to periodically update the latency estimate.
    • Updated startPreview to start the latency observation job when the preview is active.
    • Updated stopPreview and switchCamera to cancel the latency observation job.
    • Updated capturePhoto to cancel the latency observation job.
    • Implemented updateRealtimeCaptureLatencyEstimate to fetch and update the latency estimate in the UI state.
  • CameraXExtensions/app/src/main/java/com/example/android/cameraxextensions/viewstate/CameraPreviewScreenViewState.kt
    • Added LatencyEstimateIndicatorViewState data class.
    • Added latencyEstimateIndicatorViewState property to CameraPreviewScreenViewState.
    • Added showLatencyEstimateIndicator and hideLatencyEstimateIndicator functions to update the latencyEstimateIndicatorViewState.
  • CameraXExtensions/app/src/main/res/layout/activity_main.xml
    • Added latencyEstimateIndicator TextView to the layout.
  • CameraXExtensions/app/src/main/res/values/strings.xml
    • Added latency_estimate string resource.
  • build.gradle
    • Updated gradle version from 8.1.1 to 8.7.3

Activity

  • madebymozart left a review with 'Looks Good'
  • yrezgui requested a summary from gemini-code-assist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants