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

How to zoom Camera? #3

Closed
Pinkal7600 opened this issue May 9, 2019 · 4 comments
Closed

How to zoom Camera? #3

Pinkal7600 opened this issue May 9, 2019 · 4 comments

Comments

@Pinkal7600
Copy link

I have tried to zoom camera with below code. Please check and correct me where I am wrong.

First I get a Preview from CameraX and tried to perform zoom using Preview like below.

   var config = CameraX.getDefaultUseCaseConfig(PreviewConfig::class.java, lensFacing)
   var preview = Preview(config)
   preview.zoom(zoom)

After preview.zoom() I just bind again with CameraX and get some error and it's not working.

   CameraX.bindToLifecycle(this, preview, imageCapture, videoCapture)

When the above code was not working, I also tried with CameraX.unbindAll() first and then I call CameraX.bindToLifecycle(). But face some error again and not get succeed.

Please provide an answer on below question or add some description in Wiki or Readme file related to the below question.

  1. How we can zoom camera?
  2. How to get max zoom from CameraX?

And also if possible please provide how to manage flash with CameraX?

Thank you!

@owahltinez
Copy link
Contributor

This issue is unrelated to the sample, for issues related to the library please use StackOverflow using the android-camerax tag or the relevant component in Android's issue tracker.

To answer your question, take a look at https://developer.android.com/reference/androidx/camera/core/Preview.html#zoom(android.graphics.Rect). The Rect passed as a parameter should correspond to what you would set for Camera2's crop region parameter.

@owahltinez
Copy link
Contributor

Please see the CameraControl class which will implement methods for zoom

@ktchernov
Copy link

@owahltinez the Preview#zoom documentation does not answer either of the two questions, which would be quite common.

The Android issue tracker is for logging bugs, not for asking questions.

It would be good for the official sample project to demonstrate what is quite common functionality, which is not otherwise sufficiently covered in the documentation.

@Pinkal7600
Copy link
Author

Pinkal7600 commented Jan 28, 2020

Zoom API is now available from CameraX Team.
Please check my answer for more details.
StackOverflow: https://stackoverflow.com/a/59855737/7235539

Thanks to CameraX Team.

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

No branches or pull requests

3 participants