Android camera2照片质量低

时间:2018-01-17 18:35:58

标签: java android android-camera2

我正在制作应用程序以某种方式拍照,我实现了顺序功能,但照片质量很差而且没有聚焦,我怎么能改进?提前谢谢。

if (null == cameraDevice) {
        Log.e(TAG, "cameraDevice is null");
        return;
    }
    final CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraDevice.getId());
    StreamConfigurationMap streamConfigurationMap = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);


    assert streamConfigurationMap != null;
    Size largest = Collections.max(Arrays.asList(streamConfigurationMap.getOutputSizes(ImageFormat.JPEG)), new CompareSizesByArea());
    final ImageReader reader= ImageReader.newInstance(largest.getWidth(), largest.getHeight(), ImageFormat.JPEG, /*maxImages*/2);


    final List<Surface> outputSurfaces = new ArrayList<>();
    outputSurfaces.add(reader.getSurface());
    final CaptureRequest.Builder captureBuilder = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
    captureBuilder.addTarget(reader.getSurface());
    captureBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);
    captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, getOrientation());
    reader.setOnImageAvailableListener(onImageAvailableListener, null);

1 个答案:

答案 0 :(得分:0)

无法保证支持的输出大小列表的第一个元素是最佳的。您必须选择适合您的尺寸。如果getOutputSizes()返回 null ,则不应尝试为1280x720创建ImageReader。