diff options
| author | android-build-team Robot <android-build-team-robot@google.com> | 2020-01-24 04:10:40 +0000 |
|---|---|---|
| committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-01-24 04:10:40 +0000 |
| commit | bf6c996b4f3447373b4ac199f3ce53bae6c2d3b4 (patch) | |
| tree | b2026295bf0d5aeb5549b44142ad616c2d2d957a | |
| parent | 67ace0c6118e3b4991f8a8419f7c7e614931e8f7 (diff) | |
| parent | d148d3a70242fc8d2975e83946f7b8b2927ab3e7 (diff) | |
| download | platform_packages_apps_DevCamera-android11-release.tar.gz platform_packages_apps_DevCamera-android11-release.tar.bz2 platform_packages_apps_DevCamera-android11-release.zip | |
Snap for 6157842 from d148d3a70242fc8d2975e83946f7b8b2927ab3e7 to rvc-releaseandroid-vts-11.0_r5android-vts-11.0_r4android-vts-11.0_r3android-vts-11.0_r2android-vts-11.0_r1android-security-11.0.0_r1android-platform-11.0.0_r9android-platform-11.0.0_r8android-platform-11.0.0_r7android-platform-11.0.0_r6android-platform-11.0.0_r5android-platform-11.0.0_r4android-platform-11.0.0_r3android-platform-11.0.0_r2android-platform-11.0.0_r1android-cts-11.0_r5android-cts-11.0_r4android-cts-11.0_r3android-cts-11.0_r2android-cts-11.0_r1android-11.0.0_r5android-11.0.0_r4android-11.0.0_r3android-11.0.0_r25android-11.0.0_r2android-11.0.0_r17android-11.0.0_r1android11-tests-releaseandroid11-security-releaseandroid11-s1-releaseandroid11-releaseandroid11-platform-releaseandroid11-gsi
Change-Id: Iacc761505dcae52134129509060aaa3af579c49b
| -rw-r--r-- | src/com/android/devcamera/Api2Camera.java | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/com/android/devcamera/Api2Camera.java b/src/com/android/devcamera/Api2Camera.java index 40b9be6..0ebdc23 100644 --- a/src/com/android/devcamera/Api2Camera.java +++ b/src/com/android/devcamera/Api2Camera.java @@ -770,8 +770,9 @@ public class Api2Camera implements CameraInterface, SurfaceTexture.OnFrameAvaila private void publishFrameData(TotalCaptureResult result) { // Faces. final Face[] faces = result.get(CaptureResult.STATISTICS_FACES); - NormalizedFace[] newFaces = new NormalizedFace[faces.length]; - if (faces.length > 0) { + NormalizedFace[] newFaces = new NormalizedFace[0]; + if (faces != null && faces.length > 0) { + newFaces = new NormalizedFace[faces.length]; int offX = mCameraInfoCache.faceOffsetX(); int offY = mCameraInfoCache.faceOffsetY(); int dX = mCameraInfoCache.activeAreaWidth() - 2 * offX; @@ -800,22 +801,33 @@ public class Api2Camera implements CameraInterface, SurfaceTexture.OnFrameAvaila } // Normalized lens and exposure coordinates. - double rm = Math.log10(result.get(CaptureResult.SENSOR_EXPOSURE_TIME)); - float normExposure = (float) ((rm - SHORT_LOG_EXPOSURE) / (LONG_LOG_EXPOSURE - SHORT_LOG_EXPOSURE)); - float normLensPos = (mCameraInfoCache.getDiopterHi() - result.get(CaptureResult.LENS_FOCUS_DISTANCE)) / (mCameraInfoCache.getDiopterHi() - mCameraInfoCache.getDiopterLow()); + Long exposureTime = result.get(CaptureResult.SENSOR_EXPOSURE_TIME); + float normExposure = 0.0f; + if (exposureTime != null) { + normExposure = (float) ((Math.log10(exposureTime) - SHORT_LOG_EXPOSURE) / (LONG_LOG_EXPOSURE - SHORT_LOG_EXPOSURE)); + } + Float focusDistance = result.get(CaptureResult.LENS_FOCUS_DISTANCE); + float normLensPos = 0.0f; + if (focusDistance != null) { + normLensPos = (mCameraInfoCache.getDiopterHi() - focusDistance) / (mCameraInfoCache.getDiopterHi() - mCameraInfoCache.getDiopterLow()); + } mLastIso = result.get(CaptureResult.SENSOR_SENSITIVITY); // Update frame arrival history. - mFrameTimes.add(result.get(CaptureResult.SENSOR_TIMESTAMP)); - if (mFrameTimes.size() > FPS_CALC_LOOKBACK) { - mFrameTimes.removeFirst(); + Long sensorTimestamp = result.get(CaptureResult.SENSOR_TIMESTAMP); + if (sensorTimestamp != null) { + mFrameTimes.add(sensorTimestamp); + if (mFrameTimes.size() > FPS_CALC_LOOKBACK) { + mFrameTimes.removeFirst(); + } } // Frame drop detector { - float frameDuration = result.get(CaptureResult.SENSOR_FRAME_DURATION); - if (mFrameTimes.size() > 1) { - long dt = result.get(CaptureResult.SENSOR_TIMESTAMP) - mFrameTimes.get(mFrameTimes.size()-2); + Long frameDurationLong = result.get(CaptureResult.SENSOR_FRAME_DURATION); + if (frameDurationLong != null && sensorTimestamp != null && mFrameTimes.size() > 1) { + float frameDuration = frameDurationLong; + long dt = sensorTimestamp - mFrameTimes.get(mFrameTimes.size()-2); if (dt > 3 * frameDuration / 2 && LOG_DROPPED_FRAMES) { float drops = (dt * 1f / frameDuration) - 1f; Log.e(TAG, String.format("dropped %.2f frames", drops)); |
