Beispiel #1
0
        public Camera2View(Activity context) : base(context)
        {
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270);
            ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180);

            stateCallback          = new CameraStateCallback(this);
            surfaceTextureListener = new CameraSurfaceTextureListener(this);

            textureView = new TextureView(context);
            textureView.SurfaceTextureListener = surfaceTextureListener;

            AddView(textureView);

            GetCameraIds();

            if (backCameraId != null)
            {
                GetBackSizes();
            }

            if (frontCameraId != null)
            {
                GetFrontSizes();
            }

            PrintCameraAvailabilityInfo();
        }
 public CameraFeedRenderer(Context context) : base(context)
 {
     cameraManager             = (CameraManager)Context.GetSystemService(Context.CameraService);
     windowManager             = Context.GetSystemService(Context.WindowService).JavaCast <IWindowManager>();
     StateCallback             = new CameraStateCallback(this);
     SessionCallback           = new CameraCaptureSessionCallback(this);
     CaptureListener           = new CameraCaptureListener(this);
     CameraImageReaderListener = new CameraImageListener(this);
     OrientationEventListener  = new CameraPageOrientationEventListener(this, Context, global::Android.Hardware.SensorDelay.Normal);
 }
Beispiel #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            surfaceTextureView = FindViewById <AutoFitTextureView>(Resource.Id.surface);
            switchCameraButton = FindViewById <ImageButton>(Resource.Id.reverse_camera_button);
            takePictureButton  = FindViewById <Button>(Resource.Id.take_picture_button);
            recordVideoButton  = FindViewById <Button>(Resource.Id.record_video_button);

            cameraStateCallback = new CameraStateCallback
            {
                Opened       = OnOpened,
                Disconnected = OnDisconnected,
                Error        = OnError,
            };
            captureStateSessionCallback = new CaptureStateSessionCallback
            {
                Configured = OnPreviewSessionConfigured,
            };
            videoSessionStateCallback = new CaptureStateSessionCallback
            {
                Configured = OnVideoSessionConfigured,
            };
            cameraCaptureCallback = new CameraCaptureCallback
            {
                CaptureCompleted  = (session, request, result) => ProcessImageCapture(result),
                CaptureProgressed = (session, request, result) => ProcessImageCapture(result),
            };
            manager                  = GetSystemService(CameraService) as CameraManager;
            windowManager            = GetSystemService(WindowService).JavaCast <IWindowManager>();
            onImageAvailableListener = new ImageAvailableListener
            {
                ImageAvailable = HandleImageCaptured,
            };
            orientations.Append((int)SurfaceOrientation.Rotation0, 90);
            orientations.Append((int)SurfaceOrientation.Rotation90, 0);
            orientations.Append((int)SurfaceOrientation.Rotation180, 270);
            orientations.Append((int)SurfaceOrientation.Rotation270, 180);
        }