-
Notifications
You must be signed in to change notification settings - Fork 348
Add support for HEIC_ULTRAHDR #310
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
Hello team,
Gemini here, providing a summary of this pull request authored by @epeevs. The primary goal of this PR is to introduce support for capturing images in the HEIC UltraHDR format within the sample application, leveraging the Camera2 API. This builds upon the existing UltraHDR capture sample by making it more generic and adding a specific implementation for HEIC.
The changes involve adding a new sample entry in the demo list, creating a new class specifically for HEIC UltraHDR capture that extends the existing UltraHDR sample class, and modifying the base UltraHDR sample class to be more flexible regarding the output format and handle orientation correctly for HEIC images using Camera2 controls rather than ExifInterface
. The project's SDK versions have also been updated to accommodate the new API constants.
Highlights
- New Sample Added: A new sample demo entry, "HEIC UltraHDR Image Capture", has been added to the main sample list. This new sample specifically demonstrates capturing images in the HEIC UltraHDR format using Camera2.
- HEIC UltraHDR Implementation: A new class,
Camera2HeicUltraHDRCapture
, is introduced. This class extends the existingCamera2UltraHDRCapture
and overrides the image format toImageFormat.HEIC_ULTRAHDR
. This sample requires Android 15 (Baklava) or higher. - Base UltraHDR Sample Refactoring: The base
Camera2UltraHDRCapture
class has been refactored to beopen
and use a protectedULTRAHDR_FORMAT
property, allowing subclasses (like the new HEIC one) to specify the desired format. It defaults toImageFormat.JPEG_R
for backward compatibility with the original UltraHDR sample. - Orientation Handling for HEIC: The method for handling image orientation has been updated. The use of
ExifInterface
for setting orientation metadata is removed, as it's not suitable for HEIC. Instead, the Camera2 control path (CaptureRequest.JPEG_ORIENTATION
) is used, which is the recommended approach for various formats, including HEIC. - SDK Version Update: The
compileSdk
andtargetSdk
versions for the camera2 sample module have been updated from 35 to 36.
Changelog
Click here to see the changelog
- app/src/main/java/com/example/platform/app/SampleDemo.kt
- Imported the new
Camera2HeicUltraHDRCapture
class (line 27). - Added a new
ComposableSampleDemo
entry for "HEIC UltraHDR Image Capture" withid
"ultrahdr-heic-image-capture", linking toCamera2HeicUltraHDRCapture
and settingminSdk
toBAKLAVA
(lines 213-221).
- Imported the new
- samples/camera/camera2/build.gradle.kts
- Updated
compileSdk
from 35 to 36 (line 25). - Updated
targetSdk
from 35 to 36 (line 29).
- Updated
- samples/camera/camera2/src/main/java/com/example/platform/camera/imagecapture/Camera2HeicUltraHDRCapture.kt
- Added a new file defining
Camera2HeicUltraHDRCapture
(lines 1-26). - This class extends
Camera2UltraHDRCapture
and overridesULTRAHDR_FORMAT
toImageFormat.HEIC_ULTRAHDR
(line 25). - Annotated the class with
@RequiresApi(Build.VERSION_CODES.BAKLAVA)
(line 23).
- Added a new file defining
- samples/camera/camera2/src/main/java/com/example/platform/camera/imagecapture/Camera2UltraHDRCapture.kt
- Removed the import for
ExifInterface
(line 51). - Removed the
@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
annotation and made the classopen
(line 78). - Introduced a protected open property
ULTRAHDR_FORMAT
defaulting toImageFormat.JPEG_R
(line 85). - Used
ULTRAHDR_FORMAT
instead of hardcodedImageFormat.JPEG_R
when setting up theImageReader
(lines 306, 312). - Removed the code that used
ExifInterface
to save orientation metadata (lines 330-333). - Added a comment explaining the change in orientation handling for HEIC (lines 327-329).
- Used
ULTRAHDR_FORMAT
instead of hardcodedImageFormat.JPEG_R
in thecanEncodeUltraHDR
check (line 356). - Added
request.set(CaptureRequest.JPEG_ORIENTATION, relativeOrientation.value ?: 0)
to the capture request to handle orientation via Camera2 controls (line 500). - Modified the
createFile
function to accept the image format and use the appropriate file extension (.jpg
or.heic
) (lines 637-643). - Updated the call to
createFile
to pass theULTRAHDR_FORMAT
(line 586).
- Removed the import for
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.
New format arrives,
HEIC UltraHDR takes flight,
Camera sees the light.
Footnotes
-
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. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request effectively introduces support for HEIC UltraHDR image capture. The approach of extending the existing Camera2UltraHDRCapture
class is sound, and the necessary API changes (like using CaptureRequest.JPEG_ORIENTATION
instead of EXIF manipulation for HEIC) are correctly implemented. The SDK version updates and new sample demo registration are also appropriate.
Overall, the changes are well-done and enhance the camera sample capabilities. I have one suggestion for improving the robustness of the file creation logic for future extensions.
Summary of Findings
- File Extension Handling in
createFile
: ThecreateFile
method determines file extensions based on the image format. The currentelse
case defaults to.heic
, which is fine for this PR but could be problematic if other non-HEIC UltraHDR formats are supported in the future via subclassing. A more explicit handling of known formats and a clearer strategy for unknown ones would improve robustness. (Commented with medium severity) - Copyright Year: The new file
samples/camera/camera2/src/main/java/com/example/platform/camera/imagecapture/Camera2HeicUltraHDRCapture.kt
has a copyright year of 2025. Typically, this is the year of creation (e.g., 2024) or matches the project's existing files (e.g.,Camera2UltraHDRCapture.kt
uses 2023). Please verify if 2025 is intentional or a typo. (Not commented due to review settings: low severity) - KDoc Documentation: Consider adding KDoc comments to the new class
Camera2HeicUltraHDRCapture
and its overriddenULTRAHDR_FORMAT
property. Also, the newlyopen
base classCamera2UltraHDRCapture
and itsULTRAHDR_FORMAT
property could benefit from KDocs explaining their roles and extensibility. This would improve code clarity and maintainability. (Not commented due to review settings: low severity)
Merge Readiness
The pull request is in good shape and introduces a valuable feature. I recommend addressing the medium-severity comment regarding file extension handling in createFile
to enhance future maintainability. Once that's considered, the PR should be ready for merging. As an AI reviewer, I am not authorized to approve pull requests; please ensure further review and approval from authorized team members.
No description provided.