开发者

Android Camera continuous focus

开发者 https://www.devze.com 2023-03-02 08:39 出处:网络
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 开发者

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 开发者_C百科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...


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号