当前位置: 首页>>代码示例>>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;未经允许,请勿转载。