/**
   * 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;
  }
Ejemplo n.º 3
0
 /** Activates everything when the surface is created */
 @Override
 public void surfaceCreated(SurfaceHolder holder) {
   mHolder = holder;
   if (mCamera != null) initiateCamera();
 }