summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin Li <delphij@google.com>2020-08-27 10:16:51 -0700
committerXin Li <delphij@google.com>2020-08-27 10:16:51 -0700
commit47f9a007dd68232c741c81d44f25d6637aa7bd39 (patch)
treecaa3460fd4acb36ddfb30a917a8ba8ccd465a3c8
parent1b84f1f7fce56aae85e58d435b686d946c1f5f07 (diff)
parenta51ffb77720f0fcd5a491d09188b32c55c76db8a (diff)
downloadDevCamera-47f9a007dd68232c741c81d44f25d6637aa7bd39.tar.gz
Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)temp_sam_168057903
Bug: 166295507 Merged-In: I87b80291cb87768fba97613521d68be69d008cab Change-Id: Ie39341cfc7031188ebc580eb751d86225b81ae93
-rw-r--r--src/com/android/devcamera/Api2Camera.java34
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));