开发者

Android Camera autofocus when user holds camera still

开发者 https://www.devze.com 2023-04-03 17:49 出处:网络
I\'m sure most of you have used an android phone before and taken a picture. Whenever the user changes the mobile phone\'s position and holds it steady, the camera focusses automatically. I\'m having

I'm sure most of you have used an android phone before and taken a picture. Whenever the user changes the mobile phone's position and holds it steady, the camera focusses automatically. I'm having a hard tim开发者_JAVA技巧e replicating this in my app. The autofocus() method is being called only once when the application is being launched. I have been searching for a solution these past 3 days and while reading the google documentation I stumbled upon the sensor method calls (such as when the user tilts the mobile forwards or backwards). I could use this API to achieve what I need but it sounds too dirty and too complicated. I'm sure there's another way around it.

All examples on the internet which I have found only focus when the user presses the screen or a button. I have also gone through several questions on SO to hopefully find what I am looking for but I was unsuccessful. I have seen this question and that String is not compatible with my phone. For some reason the only focussing modes which I can use is fixed and auto.

I was hoping someone here would shed some light on the subject because I am at a loss.

Thankyou very much for your time.


Since API 14 you can set this parameter

http://developer.android.com/reference/android/hardware/Camera.Parameters.html#FOCUS_MODE_CONTINUOUS_PICTURE


Yes, camera.autoFocus(callback) is a one-time function. You will need to call it in a loop to have it autofocus continuously. Preferably you would have a motion detection via accelerometer or compass to detect when camera is moved.

0

精彩评论

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