當前位置: 首頁>>代碼示例>>Java>>正文


Java CameraCharacteristics.getKeys方法代碼示例

本文整理匯總了Java中android.hardware.camera2.CameraCharacteristics.getKeys方法的典型用法代碼示例。如果您正苦於以下問題:Java CameraCharacteristics.getKeys方法的具體用法?Java CameraCharacteristics.getKeys怎麽用?Java CameraCharacteristics.getKeys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.hardware.camera2.CameraCharacteristics的用法示例。


在下文中一共展示了CameraCharacteristics.getKeys方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: formatCameraCharacteristics

import android.hardware.camera2.CameraCharacteristics; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private String formatCameraCharacteristics(CameraCharacteristics info) {
    String infoText;
    if (info != null) {
        StringBuilder infoBuilder = new StringBuilder(
                "Camera characteristics:\n\n");

        for (CameraCharacteristics.Key<?> key : info.getKeys()) {
            infoBuilder.append(String.format(Locale.US, "%s:  ",
                    key.getName()));

            Object val = info.get(key);
            if (val.getClass().isArray()) {
                // Iterate an array-type value
                // Assumes camera characteristics won't have arrays of arrays as values
                int len = Array.getLength(val);
                infoBuilder.append("[ ");
                for (int i = 0; i < len; i++) {
                    infoBuilder.append(String.format(Locale.US, "%s%s",
                            Array.get(val, i), (i + 1 == len) ? ""
                                    : ", "));
                }
                infoBuilder.append(" ]\n\n");
            } else {
                // Single value
                infoBuilder.append(String.format(Locale.US, "%s\n\n",
                        val.toString()));
            }
        }
        infoText = infoBuilder.toString();
    } else {
        infoText = "No info";
    }
    return infoText;
}
 
開發者ID:QuixomTech,項目名稱:DeviceInfo,代碼行數:36,代碼來源:OSFragment.java

示例2: setUpCameraOutputs

import android.hardware.camera2.CameraCharacteristics; //導入方法依賴的package包/類
/**
 * Sets up member variables related to camera.
 */
private void setUpCameraOutputs(int width, int height) throws CameraAccessException {
    MLog.d(TAG, "setUpCameraOutputs");

    String[] cameras = mCameraManager.getCameraIdList();

    for (int i = 0; i < cameras.length; i++) {
        MLog.d(TAG, "camera " + cameras[i]);
    }

    String cameraId = cameras[0];
    CameraCharacteristics characteristics = mCameraManager.getCameraCharacteristics(cameraId);
    List<CameraCharacteristics.Key<?>> keys = characteristics.getKeys();
    for (int i = 0; i < keys.size(); i++) {
        Object val = characteristics.get(keys.get(i));
        MLog.d(TAG, "characteristic " + keys.get(i) + " " + val);
    }

    // is it facingcamera
    Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING);
    StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);

    // For still image captures, we use the largest available size.
    Size largest = Collections.max(Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)), new CompareSizesByArea());
    mImageReader = ImageReader.newInstance(largest.getWidth(), largest.getHeight(), ImageFormat.JPEG, /*maxImages*/2);
    mImageReader.setOnImageAvailableListener(mOnImageAvailableListener, null);

    // Danger, W.R.! Attempting to use too large a preview size could  exceed the camera
    // bus' bandwidth limitation, resulting in gorgeous previews but the storage of
    // garbage capture data.
    int rotatedPreviewWidth = 500;
    int rotatedPreviewHeight = 500;
    int maxPreviewWidth = 500;
    int maxPreviewHeight = 500;
    mPreviewSize = chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class),
            rotatedPreviewWidth, rotatedPreviewHeight, maxPreviewWidth,
            maxPreviewHeight, largest);

    //TODO mTextureView.setAspectRatio(mPreviewSize.getWidth(), mPreviewSize.getHeight());

    mCameraId = cameraId;
}
 
開發者ID:victordiaz,項目名稱:phonk,代碼行數:45,代碼來源:CameraNew2.java


注:本文中的android.hardware.camera2.CameraCharacteristics.getKeys方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。