-
-
Notifications
You must be signed in to change notification settings - Fork 151
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
Octo4a 2.1.0 - Camera service refactor #496
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is a refactor of the CameraService. It fixes many issues and hopefully adds few. This should decrease CPU usage and increase reliability.
I'm not convinced if my camera is even autofocusing or if it's just being shaken around by the printer... but this is the closest I've been able to get to 'fixed focus'
Clearing the Preview surface provider before unbinding the use case seems to fix most of the issues.
Setting the state triggers a callback which uses the cameraControl, so should probably set it first.
I don't know why. New versions of CameraX it does nothing, old versions of CameraX it closes the image, which is manually done immediately after the call anyway. But it seems to be stopping my camera from going into an error state by calling it...
I really hate this thing. It works great on my cheap, but new, BluView4 phone, but I *will* get this stupid thing to work on my Galaxy S5. The camera on my Galaxy S5 will crash and require a full phone reboot if an 'enableTorch' call is called while an imageCapture with flashmode on attempts to take a picture... so now I'm manually turning on the flash for ImageCapture. This can sometimes mess with image focus or exposure, as when FlashMode was set on the ImageCapture object the phone would go through its AutoExposure/AutoFocus routine before snapping a picture. Turning the flash on for a bit before the capture call seems to help for some reason but isn't perfect. I don't know why it helps at all because the camera shouldn't be 'seeing' anything different as long as the flash is on before the camera, but it seems to help. I found that when ImageCapture has flash mode on that calling enableTorch on the CameraControl returned from binding ImageCapture would cause the ImageCapture to take a snapshot (this is what was crashing my camera: calling enableTorch(false) would *trigger* ImageCapture to take a picture, which would try to control the flash and crash). So now when a use case references the flash it passes along its CameraControl (instead of grabbing the first non-null CameraControl in the list). With the change to make ImageCapture use manual flash this shouldn't really have any affect.
Previously enableTorch(true) would only be called on the first refcnt. However, sometimes ImageCapture will decide to turn off the flash, which would require all streams to close to get refcnt down to 0 so that it could go back up to 1 again to turn back on. By always calling enableTorch, even when it should already be on, it will allow a new use case to turn the torch back on (although it must be a new use case, eg a snapshot. Just opening up new streams without closing existing streams will just share the same use case and the flash will still be off...)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Includes changes from #489, with some minor fixes. On top of that, support for manually setting the focus length has been implemented.