diff options
Diffstat (limited to 'src/org/codeaurora/snapcam/filter/ClearSightImageProcessor.java')
-rwxr-xr-x[-rw-r--r--] | src/org/codeaurora/snapcam/filter/ClearSightImageProcessor.java | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/src/org/codeaurora/snapcam/filter/ClearSightImageProcessor.java b/src/org/codeaurora/snapcam/filter/ClearSightImageProcessor.java index 595df8122..944bf0800 100644..100755 --- a/src/org/codeaurora/snapcam/filter/ClearSightImageProcessor.java +++ b/src/org/codeaurora/snapcam/filter/ClearSightImageProcessor.java @@ -52,6 +52,7 @@ import android.hardware.camera2.CameraDevice; import android.hardware.camera2.CameraManager; import android.hardware.camera2.CaptureFailure; import android.hardware.camera2.CaptureRequest; +import android.hardware.camera2.CaptureResult; import android.hardware.camera2.TotalCaptureResult; import android.hardware.camera2.params.InputConfiguration; import android.hardware.camera2.params.StreamConfigurationMap; @@ -623,18 +624,26 @@ public class ClearSightImageProcessor { ReprocessableImage bayer = mBayerFrames.peek(); ReprocessableImage mono = mMonoFrames.peek(); + long bayerTsSOF = bayer.mCaptureResult.get(CaptureResult.SENSOR_TIMESTAMP); + long bayerTsEOF = bayerTsSOF + bayer.mCaptureResult.get( + CaptureResult.SENSOR_EXPOSURE_TIME); + long monoTsSOF = mono.mCaptureResult.get(CaptureResult.SENSOR_TIMESTAMP); + long monoTsEOF = monoTsSOF + mono.mCaptureResult.get( + CaptureResult.SENSOR_EXPOSURE_TIME); + + Log.d(TAG, - "checkForValidFramePair - bayer ts: " - + bayer.mImage.getTimestamp() + " mono ts: " - + mono.mImage.getTimestamp()); + "checkForValidFramePair - bayer ts SOF: " + + bayerTsSOF + ", EOF: " + bayerTsEOF + + ", mono ts SOF: " + monoTsSOF + ", EOF: " + monoTsEOF); Log.d(TAG, - "checkForValidFramePair - difference: " - + Math.abs(bayer.mImage.getTimestamp() - - mono.mImage.getTimestamp())); + "checkForValidFramePair - difference SOF: " + + Math.abs(bayerTsSOF - monoTsSOF) + + ", EOF: " + Math.abs(bayerTsEOF - monoTsEOF)); // if timestamps are within threshold, keep frames - if (Math.abs(bayer.mImage.getTimestamp() - - mono.mImage.getTimestamp()) > mTimestampThresholdNs) { - if(bayer.mImage.getTimestamp() > mono.mImage.getTimestamp()) { + if ((Math.abs(bayerTsSOF - monoTsSOF) > mTimestampThresholdNs) && + (Math.abs(bayerTsEOF - monoTsEOF) > mTimestampThresholdNs)) { + if(bayerTsSOF > monoTsSOF) { Log.d(TAG, "checkForValidFramePair - toss mono"); // no match, toss mono = mMonoFrames.poll(); @@ -903,6 +912,12 @@ public class ClearSightImageProcessor { mImageEncodeHandler.obtainMessage(MSG_START_CAPTURE).sendToTarget(); short encodeRequest = 0; + /* In same case, timeout will reset ClearSightNativeEngine object, so fields + in the object is not initial, need to return and skip process. + */ + if (ClearSightNativeEngine.getInstance().getReferenceImage(true) == null) { + return; + } long csTs = ClearSightNativeEngine.getInstance().getReferenceImage(true).getTimestamp(); CaptureRequest.Builder csRequest = createEncodeReprocRequest( ClearSightNativeEngine.getInstance().getReferenceResult(true), CAM_TYPE_BAYER); @@ -1028,6 +1043,8 @@ public class ClearSightImageProcessor { }, null); } catch (CameraAccessException e) { e.printStackTrace(); + } catch (IllegalStateException e1) { + e1.printStackTrace(); } } } |