Android 相机连续对焦
我需要在 Android 上实现一个使用相机的应用程序,它需要不断地将焦点保持在物体上。每当用户更改相机位置时,它都应该自动对焦到该位置(非常类似于Google Goggles)。
现在我正在使用以下代码:
camera.requestautofocus(autofocuscallbak);
这效果很好,但它不是连续的......
I need to implement an app on android which uses the camera and it needs to keep the focus continuously on objects. Whenever user changes the camera position, it should autofocus itself for that position (very much like Google Goggles).
Right now I am using the following code:
camera.requestautofocus(autofocuscallbak);
This works well but it's not continuous...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用以下选项: http://developer.android.com /reference/android/hardware/Camera.Parameters.html#FOCUS_MODE_CONTINUOUS_VIDEO
或者您可以查看 Zxing 库http://code.google.com/p/zxing/(条形码扫描仪应用程序),它有一个事件循环构建,接近连续自动对焦。
它在您的设备上比您想要的要重。
也许更好的解决方案是使用加速度计自己编写一个函数,并在手机朝某个方向移动(太多)时触发自动对焦。
You can use the option: http://developer.android.com/reference/android/hardware/Camera.Parameters.html#FOCUS_MODE_CONTINUOUS_VIDEO
Or you can take a look a the Zxing library http://code.google.com/p/zxing/ (barcode scanner app) which has a loop of events build which comes close to continuous autofocus.
It is heavier on your device than you would want to though.
Probably a nicer solution would be to write a function yourself using the accelerometer, and triggering the autofocus when the phone has moved (too much) in a certain direction.