简体   繁体   中英

Light sensor emulation with camera

I have already programmed the camera with the camera2 API, but when I execute the onCaptureCompleted or onCaptureProgressed method, the values ​​get null except LENS_FOCAl_LENGTH.

@Override
    public void onCaptureCompleted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, @NonNull TotalCaptureResult result) {
        super.onCaptureCompleted(session, request, result);

        String aperture = String.valueOf(result.get(CaptureResult.LENS_APERTURE));
        String focal_length = String.valueOf(result.get(CaptureResult.LENS_FOCAL_LENGTH));
        String focus_distance = String.valueOf(result.get(CaptureResult.LENS_FOCUS_DISTANCE));
        String exposure_time = String.valueOf(result.get(CaptureResult.SENSOR_EXPOSURE_TIME));
        String frame_duration = String.valueOf(result.get(CaptureResult.SENSOR_EXPOSURE_TIME));
        String sensitivity = String.valueOf(result.get(CaptureResult.SENSOR_SENSITIVITY));

    }

enter image description here

You need to test on other device. According to the documentation ( https://developer.android.com/reference/android/hardware/camera2/CaptureResult ) almost all values "Optional - The value for this key may be null on some devices."

But for example LENS_FOCAL_LENGTH that is not null in your case is "This key is available on all devices." So all values depends on device type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM