比如我設置2,它一秒不會只捕獲2幀數據的,從日誌記錄來看,相當糟糕,不會是預期的2幀,於是我查找文檔,發現這個方法已經廢除了。
在api level9時加入了一個方法setPreviewFpsRange (int min, int max)
預覽幀數從min到max,這個值再*1000.
這個方法已經在高版本的sdk中取代了舊的setPreviewFrameRate。
如何知道攝像頭的預覽範圍呢?我原以爲從1到n,其實不然。
getSupportedPreviewFpsRange()這個方法就可以顯示出你的手機攝像頭支持的範圍。
- List<int[]> range=parameters.getSupportedPreviewFpsRange();
- Log.d(TAG, "range:"+range.size());
- for(int j=0;j
- int[] r=range.get(j);
- for(int k=0;k
- Log.d(TAG, TAG+r[k]);
- }
- }
如i9000會是7-30而不是1-30.。。
所以在Camera.PreviewCallback回調中,onPreviewFrame會得到的幀數就不會小於7了。
我還一直以爲預覽幀數是2,看到的畫面還是很流暢。。。
- 文檔裏還有這麼一段話:
- Gets the supported preview fps (frame-per-second) ranges. Each range contains a minimum fps and maximum fps. If minimum fps equals to maximum fps, the camera outputs frames in fixed frame rate. If not, the camera outputs frames in auto frame rate. The actual frame rate fluctuates between the minimum and the maximum. The values are multiplied by 1000 and represented in integers. For example, if frame rate is 26.623 frames per second, the value is 26623.
- 如果最大值與最小值是一樣的,就是以這個值輸出預覽,如果不同,則會以這個區間自動輸出。
- 看上去,預覽幀數還是不可控制的啊