/** Releases the camera in case of pause or exit */ public void releaseCamera() { if (mCamera != null) { mCamera.release(); if (mPreview != null) { mPreview.mCamera = null; } mCamera = null; } }
/** * Sets the active camera * * @param CameraNumber index of the camera from the available cameras * @return RES_OK */ public int setActiveCamera(int CameraNumber) { if (mNumCameras > 1) { if (mCurrentCameraIndex != CameraNumber) { mCurrentCameraIndex = CameraNumber; mCamera.release(); mPreview.mCamera = null; mCamera = Camera.open(CameraNumber); mPreview.mCameraIndex = mCurrentCameraIndex; mCamera.setParameters(getCurrentParameters()); } } return MAAPI_consts.MA_CAMERA_RES_OK; }
/** * Sets the MoSyncCameraPreview object to be controlled * * @param preview an object of MoSyncCameraPreview that has already been initialized */ public void setPreview(MoSyncCameraPreview preview) { acquireCamera(); mPreview = preview; if (mPreview.mCamera == null) { mPreview.mCamera = mCamera; mPreview.initiateCamera(); mPreview.mCameraIndex = mCurrentCameraIndex; setPreviewCallback(); Camera.Parameters parameters = getCurrentParameters(); Camera.Size size = parameters.getPreviewSize(); mImageBuffer = new byte[size.width * size.height * 4]; } }
/** Starts the preview */ public int cameraStart() { acquireCamera(); try { if (mPreview.mCamera == null) { mPreview.mCamera = mCamera; mPreview.initiateCamera(); mPreview.mCameraIndex = mCurrentCameraIndex; setPreviewCallback(); } mCamera.startPreview(); } catch (Exception e) { SYSLOG(e.getMessage()); return MAAPI_consts.MA_CAMERA_RES_FAILED; } return MAAPI_consts.MA_CAMERA_RES_OK; }