“自动对焦” “相机”功能我的 Android 应用程序的模块
几天以来,我一直在为我的应用程序使用 CAMERA 模块。 我定制了完整的相机模块,而不是通过意图调用硬件内置的移动相机。我使用了快门、图片等回调 现在我正在尝试为这款定制相机添加变焦和自动对焦功能。任何人都可以让我知道添加缩放和自动对焦功能的方法以及清单文件中应提及的所需权限。希望我能尽快得到帮助。
I have been working with the CAMERA module for my application since few days.
I have customized the complete camera module instead of invoking the hardware inbuilt mobile camera through an intent. I have used the call backs for shutter, picture etc
Now I am trying to add the ZOOM and AUTO-FOCUS features to this customized camera. Can anybody please let me know the way to add the ZOOM and AUTO-FOCUS features along with the required permissions which should be mentioned in the manifest file..hope i will be helped as soon as possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的一些观察结果。
1)
Camera.autoFocus
是一次性调用,适用于Camera.getParameters.getFocusMode()
是FOCUS-MODE-AUTO
或FOCUS-MODE-MACRO
,其他情况下不需要调用autoFocus
方法。请参阅 API 文档并认真遵循它们。2) 一次性调用,表示该方法不注册
AutoFocusCallback
实例连续接收通知。3) 相反,
FOCUS-MODE-AUTO
甚至不是动态连续对焦持续的。相反,您可能想使用
FOCUS-MODE-EDOF
或FOCUS-MODE-CONTINUOUS-PICTURES
取决于 API 级别和您正在使用和构建的 SDK 版本。
4) 有每一个
实际设备相机可能不支持某些功能的可能性
FOCUS-MODE
常量,例如EDOF
或INFINITE
。始终确保当您创建相机参数时,您会检查
getSupportedFocusModes
并使用适用的常量。5) 呼叫
camera.autoFocus
就在camera.takePicture
之前,会使PictureCallBack
中生成的 jpeg-byte-array 至少为 50%超过其原始尺寸。不显式调用
autoFocus()
可能会有时会导致之前的
autoFocus()
以非常快的速度结束低分辨率可能会导致 jpeg 字节数组长度仅为
10K 字节,导致
BitmapFactory
中的图像位图为空。6) 关于自动对焦权限,请参阅 API 文档。
7)关于
变焦,并不像实现自动对焦那么复杂
特征。取决于屏幕交互,例如滑块或硬件
诸如音量键之类的键,您可以实现一个
ZoomChangeListener
您可以在
Camera
实例注册后立即向Camera
注册从
open(intcameraId)
接收。Couple of observations from my end.
1)
Camera.autoFocus
is a one-time call, applicable whenCamera.getParameters.getFocusMode()
is eitherFOCUS-MODE-AUTO
orFOCUS-MODE-MACRO
, in other cases you don't need to invoke theautoFocus
method. See the API Docs and follow them devotedly.2) By one-time call, it means that this method does not register the
AutoFocusCallback
instance to receive notifications continuously.3) Rather,
FOCUS-MODE-AUTO
isn't even a dynamic and continuous focusconstant. Instead, you might want to use
FOCUS-MODE-EDOF
orFOCUS-MODE-CONTINUOUS-PICTURES
depending on the API Level and theSDK version that you are using and building for.
4) There is every
possibility that the actual Device Camera may not support some
FOCUS-MODE
constants, such asEDOF
orINFINITE
. Always make surewhen you are creating the camera-parameters, you check for
getSupportedFocusModes
and use the applicable constants.5) Calling
camera.autoFocus
just beforecamera.takePicture
can bloat theresulting jpeg-byte-array in the
PictureCallBack
to at least 50%more than it's original size. Not calling
autoFocus()
explicitly maysometimes cause the previous
autoFocus()
to end at a verylow-resolution that may result a jpeg-byte-array length of only a
10K bytes, resulting in a null image bitmap from the
BitmapFactory
.6) Regarding auto-focus permissions, see the API Docs.
7) Regarding
Zoom, it is not as complicated as implementing the Auto-focus
feature. Depending on screen-interaction such as slider, or hardware
keys such as volume-keys, you could implement a
ZoomChangeListener
that you can register with the
Camera
as soon as theCamera
instanceis received from
open(int cameraId)
.对于缩放 (2x):
对于 api 级别 > 5 使用 api,例如 setZoom() 等
用于自动对焦(取自 zxing)
。
For zoom (2x):
For api level > 5 use the api's like setZoom() etc
For autofocussing (taken from zxing)
.