internal PhotoCamera(StoreMediaOptions storeOptions) : base(storeOptions) { CameraOperationType = OperationType.Photo; // Factory's instance created to store itself in static field new CaptureStateFactory(RunPreCaptureSequence, CaptureStillPhoto); _imageAvailableHandler = new ImageAvailableHandler(StoreOptions, CameraBackgroundHandler, MediaPickerActivity); CameraParameters = ComputerParametersFactory.CreateCameraParameters(CameraOperationType); }
/* * Initialize the camera device */ public void InitializeCamera(Context context, int previewWidth, int previewHeight, Handler backgroundHandler, ImageReader.IOnImageAvailableListener imageAvailableListener) { if (_initialized) { throw new IllegalStateException( "CameraHandler is already initialized or is initializing"); } _initialized = true; // Discover the camera instance CameraManager manager = (CameraManager)context.GetSystemService(Context.CameraService); string[] camIds = null; try { camIds = manager.GetCameraIdList(); } catch (CameraAccessException e) { Log.Warn(TAG, "Cannot get the list of available cameras", e); } if (camIds == null || camIds.Length < 1) { Log.Debug(TAG, "No cameras found"); return; } Log.Debug(TAG, "Using camera id " + camIds[0]); // Initialize the image processor mImageReader = ImageReader.NewInstance(previewWidth, previewHeight, ImageFormatType.Jpeg, MAX_IMAGES); mImageReader.SetOnImageAvailableListener(imageAvailableListener, backgroundHandler); // Open the camera resource try { manager.OpenCamera(camIds[0], new CameraStateCallBack(this), backgroundHandler); } catch (CameraAccessException cae) { Log.Debug(TAG, "Camera access exception", cae); } }
internal Camera2Controller(PhotoCaptureView photoCaptureView) : base(photoCaptureView) { _captureCallback = new CaptureCallback(this); _stateCallback = new CameraStateCallback(this); _imageAvailableListener = new OnImageAvailableListener(this); _captureStateCallback = new CaptureStateCallback(OnConfigured); }