自己寫了一個(gè)Camera的程序,只有主動(dòng)調(diào)用autofous的時(shí)候才會(huì)進(jìn)行自動(dòng)對(duì)焦,我手機(jī)的Camera支持的對(duì)焦模式只有auto和macro, 但是我看我手機(jī)系統(tǒng)自帶的相機(jī)在拍照移動(dòng)時(shí)會(huì)進(jìn)行自動(dòng)對(duì)焦,想知道這是如何實(shí)現(xiàn)的?難道是判斷手機(jī)的rotation嗎?可是如果方向不變只是距離改變的時(shí)候系統(tǒng)相機(jī)也會(huì)進(jìn)行自動(dòng)對(duì)焦,這是如何做到的呢?因?yàn)閺腃amera支持的對(duì)焦模式里看應(yīng)該沒(méi)有支持連續(xù)對(duì)焦模式。
人生最曼妙的風(fēng)景,竟是內(nèi)心的淡定與從容!
The camera zoom is optical zoom, and the program only does post-processing. The system camera relies on the underlying driver, which can achieve more refined processing. The Camera API open at the application layer is not the entire camera control API, so there is a difference. In addition, the Camera API is not mobile related.
I have seen the source code of zxing (although it is very old code, it can still be used). It uses AsyncTask to continuously cycle focus. Although there are parameters for continuous focus in the API, it requires mobile phone support. After trying it, the effect is not very good. For reference only, please refer to it.
https://github.com/zxing/zxing/blob/master/android/src/com/google/zxing/client/android/camera/AutoFocusManager.java
Attached is a demo of camera2
https://github.com/googlesamples/android-Camera2Basic