/// <summary> /// Closes a camera and release resources. /// </summary> private void closeCamera() { try { mCameraOpenCloseLock.acquire(); if (null != mSCameraSession) { mSCameraSession.close(); mSCameraSession = null; } if (null != mSCameraDevice) { mSCameraDevice.close(); mSCameraDevice = null; } mSCameraManager = null; mSCamera = null; } catch (InterruptedException e) { Log.e(TAG, "Interrupted while trying to lock camera closing.", e); } finally { mCameraOpenCloseLock.release(); } }
public override void onConfigured(SCameraCaptureSession sCameraCaptureSession) { outerInstance.mSCameraSession = sCameraCaptureSession; // Configures an ImageWriter outerInstance.mReprocessWriter = ImageWriter.newInstance(outerInstance.mSCameraSession.InputSurface, 2); outerInstance.mReprocessWriter.setOnImageReleasedListener(new OnImageReleasedListenerAnonymousInnerClassHelper(this), outerInstance.mBackgroundHandler); outerInstance.startPreview(); }
public override void onCaptureCompleted(SCameraCaptureSession session, SCaptureRequest request, STotalCaptureResult result) { try { outerInstance.mCaptureResultQueue.put(result); } catch (InterruptedException e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } }
public override void onCaptureCompleted(SCameraCaptureSession session, SCaptureRequest request, STotalCaptureResult result) { // Depends on the current state and capture result, app will take next action. switch (outerInstance.State) { case IDLE: case PREVIEW: case CLOSING: // do nothing break; } }
public override void onCaptureCompleted(SCameraCaptureSession session, SCaptureRequest request, STotalCaptureResult result) { // Depends on the current state and capture result, app will take next action. switch (outerInstance.mState) { case com.samsung.android.sdk.camera.sample.cases.Sample_Panorama.CAMERA_STATE.IDLE: case com.samsung.android.sdk.camera.sample.cases.Sample_Panorama.CAMERA_STATE.PREVIEW: case com.samsung.android.sdk.camera.sample.cases.Sample_Panorama.CAMERA_STATE.TAKE_PICTURE: // do nothing break; // If AF is triggered and AF_STATE indicates AF process is finished, app will lock AE/AWB case com.samsung.android.sdk.camera.sample.cases.Sample_Panorama.CAMERA_STATE.WAIT_AF: { if (outerInstance.isAFTriggered) { int?afState = result.get(SCaptureResult.CONTROL_AF_STATE); if (null == afState || SCaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED == afState || SCaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED == afState) { // in this way, app will compatible with legacy device outerInstance.lockAEAWB(); outerInstance.isAFTriggered = false; } } break; } // If AE/AWB is locked and AE_STATE/AWB_STATE indicates lock is completed, app will take a picture. case com.samsung.android.sdk.camera.sample.cases.Sample_Panorama.CAMERA_STATE.WAIT_AEAWB_LOCK: { if (outerInstance.isAEAWBLocked) { int?aeState = result.get(SCaptureResult.CONTROL_AE_STATE); int?awbState = result.get(SCaptureResult.CONTROL_AWB_STATE); if (null == aeState || null == awbState || (SCaptureResult.CONTROL_AE_STATE_LOCKED == aeState && (SCaptureResult.CONTROL_AWB_STATE_LOCKED == awbState || SCaptureResult.CONTROL_AWB_STATE_CONVERGED == awbState))) { // in this way, app will compatible with legacy device outerInstance.startTakePicture(); outerInstance.isAEAWBLocked = false; } } break; } } }
public override void onCaptureCompleted(SCameraCaptureSession session, SCaptureRequest request, STotalCaptureResult result) { try { outerInstance.mCaptureResultQueue.put(result); } catch (InterruptedException e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } if (outerInstance.State == CAMERA_STATE.CLOSING) { return; } outerInstance.unlockAF(); }
/// <summary> /// Closes a camera and release resources. /// </summary> private void closeCamera() { lock (this) { try { mCameraOpenCloseLock.acquire(); if (mSCameraSession != null) { mSCameraSession.close(); mSCameraSession = null; } if (mSCameraDevice != null) { mSCameraDevice.close(); mSCameraDevice = null; } mSCameraManager = null; } catch (InterruptedException e) { Log.e(TAG, "Interrupted while trying to lock camera closing.", e); } finally { mCameraOpenCloseLock.release(); } } }
public override void onConfigureFailed(SCameraCaptureSession sCameraCaptureSession) { outerInstance.showAlertDialog("Fail to create camera capture session.", true); }
public override void onCaptureCompleted(SCameraCaptureSession session, SCaptureRequest request, STotalCaptureResult result) { // Depends on the current state and capture result, app will take next action. switch (outerInstance.State) { case IDLE: case PREVIEW: case CLOSING: // do nothing break; case TAKE_HDR_PICTURE: if (mResultListener != null) { mResultListener.checkPresetResult(result); } break; case WAIT_AF: { if (outerInstance.isAFTriggered) { int? afState = result.get(SCaptureResult.CONTROL_AF_STATE); // Check if AF is finished. If finished, take hdr picture. if (null == afState || SCaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED == afState || SCaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED == afState) { outerInstance.isAFTriggered = false; outerInstance.lockAE(); } } break; } case WAIT_AE_LOCK: { if (result.get(SCaptureResult.CONTROL_AE_STATE) != null && result.get(SCaptureResult.CONTROL_AE_STATE) == SCaptureResult.CONTROL_AE_STATE_LOCKED) { outerInstance.takeHdrPicture(); } break; } } }
/// <summary> /// This method is called when a capture sequence finishes. In here, It means captureBurst is finished and mInputImageList is filled with images. /// </summary> public override void onCaptureSequenceCompleted(SCameraCaptureSession session, int sequenceId, long frameNumber) { if (outerInstance.State == CAMERA_STATE.CLOSING) { return; } // Request low light processor to produce output image using input image list. outerInstance.mProcessor.requestMultiProcess(outerInstance.mInputImageList); }
public override void onCaptureFailed(SCameraCaptureSession session, SCaptureRequest request, SCaptureFailure failure) { if (outerInstance.State == CAMERA_STATE.CLOSING) { return; } outerInstance.showAlertDialog("JPEG Capture failed.", false); outerInstance.unlockAF(); }
public override void onCaptureCompleted(SCameraCaptureSession session, SCaptureRequest request, STotalCaptureResult result) { outerInstance.mRequestTriggered = true; }
public override void onCaptureCompleted(SCameraCaptureSession session, SCaptureRequest request, STotalCaptureResult result) { // Depends on the current state and capture result, app will take next action. switch (outerInstance.State) { case IDLE: case PREVIEW: case CLOSING: // do nothing break; case TAKE_DOF_PICTURE: if (mResultListener != null) { mResultListener.checkPresetResult(result); } break; } }
public override void onCaptureCompleted(SCameraCaptureSession session, SCaptureRequest request, STotalCaptureResult result) { if (outerInstance.outerInstance.State == CAMERA_STATE.CLOSING) { return; } outerInstance.outerInstance.mSessionCaptureCallback.ResultListener = outerInstance; outerInstance.isAFTriggered = true; }
public override void onCaptureCompleted(SCameraCaptureSession session, SCaptureRequest request, STotalCaptureResult result) { if (outerInstance.State == CAMERA_STATE.CLOSING) { return; } if (mResultListener != null) { mResultListener.checkCaptureResult(result); } }
public override void onCaptureCompleted(SCameraCaptureSession session, SCaptureRequest request, STotalCaptureResult result) { if (outerInstance.State == CAMERA_STATE.CLOSING) { return; } outerInstance.State = CAMERA_STATE.PREVIEW; }
public override void onCaptureCompleted(SCameraCaptureSession session, SCaptureRequest request, STotalCaptureResult result) { outerInstance.mState = CAMERA_STATE.PREVIEW; }
public override void onCaptureSequenceAborted(SCameraCaptureSession session, int sequenceId) { if (outerInstance.State == CAMERA_STATE.CLOSING) { return; } outerInstance.showAlertDialog("Fail to capture input JPEG image(s).", false); outerInstance.clearInputImages(); outerInstance.unlockAF(); }
public override void onCaptureCompleted(SCameraCaptureSession session, SCaptureRequest request, STotalCaptureResult result) { // Remove comment, if you want to check request/result from console log. // dumpCaptureResultToLog(result); // dumpCaptureRequestToLog(request); // Depends on the current state and capture result, app will take next action. switch (outerInstance.State) { case IDLE: case TAKE_PICTURE: case CLOSING: // do nothing break; case PREVIEW: if (result.get(SCaptureResult.STATISTICS_FACES) != null) { outerInstance.processFace(result.get(SCaptureResult.STATISTICS_FACES), result.get(SCaptureResult.SCALER_CROP_REGION)); } break; // If AF is triggered and AF_STATE indicates AF process is finished, app will trigger AE pre-capture. case WAIT_AF: { if (outerInstance.isAFTriggered) { int afState = result.get(SCaptureResult.CONTROL_AF_STATE); // Check if AF is finished. if (SCaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED == afState || SCaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED == afState) { // If AE mode is off or device is legacy device then skip AE pre-capture. if (result.get(SCaptureResult.CONTROL_AE_MODE) != SCaptureResult.CONTROL_AE_MODE_OFF && outerInstance.mCharacteristics.get(SCameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL) != SCameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY) { outerInstance.triggerAE(); } else { outerInstance.takePicture(); } outerInstance.isAFTriggered = false; } } break; } // If AE is triggered and AE_STATE indicates AE pre-capture process is finished, app will take a picture. case WAIT_AE: { if (outerInstance.isAETriggered) { int? aeState = result.get(SCaptureResult.CONTROL_AE_STATE); if (null == aeState || SCaptureResult.CONTROL_AE_STATE_CONVERGED == aeState || SCaptureResult.CONTROL_AE_STATE_FLASH_REQUIRED == aeState || SCaptureResult.CONTROL_AE_STATE_LOCKED == aeState) { // Legacy device might have null AE_STATE. However, this should not be happened as we skip triggerAE() for legacy device outerInstance.takePicture(); outerInstance.isAETriggered = false; } } break; } } }