Skip to content
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

Add support for HEIC_ULTRAHDR #282

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

epeevs
Copy link
Contributor

@epeevs epeevs commented Mar 11, 2025

No description provided.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @epeevs, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request adds support for the HEIC_ULTRAHDR image format in the camera2 sample application. The changes include updating the compileSdkPreview and targetSdkPreview to "Baklava", adding a new class Camera2HeicUltraHDRCapture that extends Camera2UltraHDRCapture and overrides the ULTRAHDR_FORMAT to ImageFormat.HEIC_ULTRAHDR. The pull request also modifies Camera2UltraHDRCapture to be an open class, and updates the file creation logic to save images as .heic when using the HEIC_ULTRAHDR format. Additionally, the pull request removes EXIF metadata saving and sets the JPEG orientation in the capture request.

Highlights

  • HEIC_ULTRAHDR Support: Adds support for the HEIC_ULTRAHDR image format in the camera2 sample application.
  • API Level Update: Updates compileSdkPreview and targetSdkPreview to "Baklava" (Android 14).
  • File Creation Logic: Modifies the file creation logic to save images as .heic when using the HEIC_ULTRAHDR format.
  • Base Class Modification: Changes Camera2UltraHDRCapture to an open class to allow extension for specific UltraHDR formats.

Changelog

Click here to see the changelog
  • app/build.gradle.kts
    • Updated compileSdk to compileSdkPreview = "Baklava".
  • gradle.properties
    • Added android.suppressUnsupportedCompileSdk=35 to suppress compile SDK warnings.
  • samples/camera/camera2/build.gradle.kts
    • Added compileSdkPreview = "Baklava" and targetSdkPreview = "Baklava".
  • samples/camera/camera2/src/main/java/com/example/platform/camera/imagecapture/Camera2HeicUltraHDRCapture.kt
    • Created new class Camera2HeicUltraHDRCapture extending Camera2UltraHDRCapture.
    • Overrode ULTRAHDR_FORMAT to ImageFormat.HEIC_ULTRAHDR.
  • samples/camera/camera2/src/main/java/com/example/platform/camera/imagecapture/Camera2UltraHDRCapture.kt
    • Changed class to open class Camera2UltraHDRCapture.
    • Added protected open val ULTRAHDR_FORMAT = ImageFormat.JPEG_R.
    • Replaced hardcoded ImageFormat.JPEG_R with ULTRAHDR_FORMAT when creating the ImageReader.
    • Removed EXIF metadata saving.
    • Added request.set(CaptureRequest.JPEG_ORIENTATION, relativeOrientation.value ?: 0) to set JPEG orientation.
    • Modified createFile to use .heic extension for HEIC_ULTRAHDR format.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


The camera's eye, a digital soul,
Capturing moments, making them whole.
From JPEG's grace to HEIC's might,
UltraHDR shines, a dazzling light.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request introduces support for HEIC_ULTRAHDR in the camera2 sample. The changes involve updating build configurations to use the Baklava preview SDK and adding a new class for capturing HEIC Ultra HDR images. Overall, the changes seem reasonable, but there are a few areas that could be improved.

Summary of Findings

  • Target SDK Preview: The targetSdkPreview should be carefully considered as it might introduce compatibility issues if the preview SDK is not available on the device. Ensure proper fallback mechanisms are in place.
  • API Level Check: The code uses @RequiresApi to ensure the new functionality is only used on devices running Android Baklava or higher. This is good, but ensure that the app gracefully handles cases where the API is not available.
  • File Extension Handling: The file extension handling logic in createFile could be simplified and made more robust by using when statement instead of if statement.

Merge Readiness

The pull request introduces necessary changes to support HEIC_ULTRAHDR. However, before merging, it's crucial to ensure that the targetSdkPreview is handled gracefully and that the API level checks are robust. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. Given the medium severity comments, I recommend addressing them before merging.

Comment on lines +36 to +39
compileSdkPreview = "Baklava"
defaultConfig {
targetSdkPreview = "Baklava"
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding a comment explaining why compileSdkPreview and targetSdkPreview are being used. This can help future developers understand the purpose of these settings and avoid accidental removal or modification.

Also, ensure that using a preview SDK doesn't introduce unexpected behavior or compatibility issues on older devices. It might be useful to add a check to ensure that the app gracefully handles cases where the preview SDK is not available.

import android.os.Build
import androidx.annotation.RequiresApi

@RequiresApi(Build.VERSION_CODES.BAKLAVA)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The @RequiresApi annotation is good for ensuring that this class is only used on devices running Android Baklava or higher. However, consider adding a fallback mechanism or a check at runtime to handle cases where the API is not available. This could involve disabling the HEIC_ULTRAHDR capture option or providing a message to the user.

@@ -76,14 +74,16 @@ import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
import kotlin.coroutines.suspendCoroutine

@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
class Camera2UltraHDRCapture : Fragment() {
@RequiresApi(Build.VERSION_CODES.BAKLAVA)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to the Camera2HeicUltraHDRCapture.kt file, ensure that the app gracefully handles cases where the API level is not met. Consider providing a fallback mechanism or a user-friendly message.

Comment on lines +327 to 329
// Save the result to disk
val output = saveResult(result)
Log.d(TAG, "Image saved: ${output.absolutePath}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The EXIF metadata update is removed. Is this intentional? If so, please add a comment explaining why the EXIF metadata update is no longer needed for UltraHDR images. If it was unintentional, please re-add the EXIF metadata update logic.

…ra/imagecapture/Camera2UltraHDRCapture.kt

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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.

1 participant