Skip to content

This changes enable the feature of saving images to the phone gallery. #483

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 11, 2023
Merged

Conversation

Sergio-
Copy link
Contributor

@Sergio- Sergio- commented Jan 11, 2023

Hi @axxel Good day.
Here's a new pull request to enable the image saving to gallery on the Android Demo App. I've tried to reduce it as much as possible keeping the original code intact as much as possible. Best regards.

// Re-enable camera controls
it.isEnabled = true
}
}

private fun takePhoto() {
val imageCapture = imageCapture ?: return
Copy link
Collaborator

Choose a reason for hiding this comment

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

The whole PR looks very nice. Thanks a lot! Just one question: what is this line supposed to mean? You introduce a local variable with the same name and same value as the outer scope one? Is this supposed to simply check if imageCapture is null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @axxel Good day.
Yes. This is to avoid application to crash in case of user clicks the button without it being completeb initialized.
Reference: https://medium.com/swlh/how-to-create-a-simple-camera-app-using-android-camerax-library-7367778498e0
Best regards.

@axxel axxel merged commit 93034ca into zxing-cpp:master Jan 11, 2023
@axxel
Copy link
Collaborator

axxel commented Jan 11, 2023

After merging and testing your new feature I noticed that the image captured has a completely different resolution (and potentially orientation and aspect ratio) compared to the one in the ImageAnalysis path of the program. That is actually no surprise at all and surely what people normaly would be interested in (highest quality foto). In our use-case this is not the most useful data, though. What would be most useful is simply a 'save to file' copy of a single frame just as the zxing-cpp backend saw it. That is most useful for later debugging the image on a PC.

I tried to quickly adjust the ImageCapture parameters to mimic the behavior of the ImageAnalysis path but it is not as straight forward as I'd hoped. Maybe the easiest was to achieve what I want would be to find some "save this image buffer as a JPG" code and then have the takeFoto button simply set a flag such that the next frame inside the analys path gets saved to storage.

Since you were working on this just now, maybe you know what the quickest way to get to that result is?

@Sergio-
Copy link
Contributor Author

Sergio- commented Jan 11, 2023

Hi @axxel I see what you're saying. Let me study the code a little more and see if we can come up with some way to do it.... I'll keep you posted. Thank you.

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.

2 participants