android 擷取網路攝影機像素

來源:互聯網
上載者:User

擷取Camera執行個體,在2.3之前可以用靜態方法Camera camera = Camera.open();,如果手機帶前後置的網路攝影機,那2.3之前sdk擷取到的執行個體為後置的主網路攝影機,自拍擷取不到。

擷取Parameters parameters = camera.getParameters(); parameters裡有個方法getSupportedPictureSizes(),擷取到所有支援的圖片像素。迴圈取最大的width和height(最大值一般是List的第一個元素,嫌麻煩可以直接get(0))。

width*height就為網路攝影機的像素!例如500百萬像素!

2.3以上sdk可以用Camera.getNumberOfCameras()擷取網路攝影機數,(有的手機是三個網路攝影機,前置一個,後置雙網路攝影機,但是這裡取出來的數值仍然是2)。Camera.open(int cameraId)擷取指數網路攝影機執行個體。

    public int getCameraId(int type) {        int numberOfCameras = Camera.getNumberOfCameras();        CameraInfo cameraInfo = new CameraInfo();        for (int i = 0; i < numberOfCameras; i++) {            Camera.getCameraInfo(i, cameraInfo);            if (cameraInfo.facing == type) {                return i;            }        }        return 2;    }

其中int type為public static final int CAMERA_FACING_BACK = 0; public static final int CAMERA_FACING_FRONT = 1;

取出前網路攝影機或者後網路攝影機,按上面的方法計算網路攝影機的像素!注意:一般計算出來的數值都比網上標明的要小,廠商又誇大自家商品了= =!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.