简体   繁体   English

如何使用带有浮点数的android camera2 API缩放Camera

[英]How to zoom Camera using android camera2 api with a float numbers

I developed a custom camera using camera2 api , i make zoom in and zoom out feature like this. 我使用camera2 api开发了自定义相机,并进行了像这样的放大和缩小功能。

Camera.Parameters params = mCamera.getParameters();
int value = params.getMaxZoom();
params.setZoom(value);

It works for me, but how can I zoom camera by float number like 2.4f ? 它对我有用,但是如何按2.4f之类的浮点数缩放相机?

Can any one help me, please? 有人可以帮我吗?

https://developer.android.com/reference/android/hardware/Camera.Parameters.html#getMaxZoom() https://developer.android.com/reference/android/hardware/Camera.Parameters.html#getMaxZoom()

Sets current zoom value. 设置当前缩放值。 If the camera is zoomed (value > 0), the actual picture size may be smaller than picture size setting. 如果相机变焦(值> 0),则实际照片尺寸可能小于照片尺寸设置。

https://developer.android.com/reference/android/hardware/Camera.Parameters.html#setZoom(int) https://developer.android.com/reference/android/hardware/Camera.Parameters.html#setZoom(int)

setZoom takes an Integer (whole number) so you can't set the zoom to a float. setZoom采用整数(整数),因此无法将缩放设置为浮动。


The newest Android CameraX api's can Zoom using a Rect: https://developer.android.com/reference/androidx/camera/core/Preview.html#zoom(android.graphics.Rect) (but under the hood it relies on Camera2 so I wouldn't hold out much hope for hardware float zoom. 最新的Android CameraX API可以使用Rect进行缩放: https : //developer.android.com/reference/androidx/camera/core/Preview.html#zoom (android.graphics.Rect (但实际上,它依赖于Camera2)因此我对硬件浮动变焦不会寄予太大希望。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM