Esempio n. 1
0
        protected virtual void OnTapped(UITouch touch)
        {
            var devicePoint = previewLayer.CaptureDevicePointOfInterestForPoint(touch.LocationInView(this));

            //FocusWithMode(AVCaptureFocusMode.AutoFocus, AVCaptureExposureMode.AutoExpose, devicePoint, true);

            Console.WriteLine("Tapped {0}", devicePoint);
            Tapped?.Invoke(this, new EventArgs());
        }
Esempio n. 2
0
        void focus(PointF point)
        {
            PointF convertedFocusPoint = previewLayer.CaptureDevicePointOfInterestForPoint(point);

            sessionManager.AutoFocus(convertedFocusPoint);
        }
Esempio n. 3
0
        void FocusAndExposeTap(UIGestureRecognizer gestureRecognizer)
        {
            var devicePoint = VideoPreviewLayer.CaptureDevicePointOfInterestForPoint(gestureRecognizer.LocationInView(gestureRecognizer.View));

            FocusWithMode(AVCaptureFocusMode.AutoFocus, AVCaptureExposureMode.AutoExpose, devicePoint, true);
        }
Esempio n. 4
0
        // ReSharper disable once UnusedMember.Local
        private void PreviewWasTapped(UIGestureRecognizer recognizer, UITouch touch)
        {
            var touchLocation = touch.LocationInView(touch.View);
            var taps          = touch.TapCount;

            if (taps > 1)
            {
                TurnOffFlashAndSetContinuousAutoMode(_device);
            }
            else
            {
                if (_cameraModule.IsTapToFocusEnabled)
                {
                    var focusPoint = new CGPoint();

                    if (_previousValidOrientation == UIDeviceOrientation.Portrait)
                    {
                        var translatedPoint = _avCaptureVideoPreviewLayer.CaptureDevicePointOfInterestForPoint(touchLocation);
                        focusPoint.X = translatedPoint.Y;
                        focusPoint.Y = translatedPoint.X;

                        focusPoint.X = 1 - focusPoint.X;
                    }
                    else if (_previousValidOrientation == UIDeviceOrientation.LandscapeLeft)
                    {
                        focusPoint = _avCaptureVideoPreviewLayer.CaptureDevicePointOfInterestForPoint(touchLocation);
                    }
                    else if (_previousValidOrientation == UIDeviceOrientation.LandscapeRight)
                    {
                        var translatedPoint = _avCaptureVideoPreviewLayer.CaptureDevicePointOfInterestForPoint(touchLocation);

                        focusPoint.X = 1 - translatedPoint.X;
                        focusPoint.Y = 1 - translatedPoint.Y;
                    }

                    if (focusPoint.Y < 0)
                    {
                        focusPoint.Y = 0;
                    }

                    if (focusPoint.Y > 1)
                    {
                        focusPoint.Y = 1;
                    }

                    _device.LockForConfiguration(out var error);
                    if (error != null)
                    {
                        return;
                    }

                    if (_device.FocusPointOfInterestSupported &&
                        _device.IsFocusModeSupported(AVCaptureFocusMode.AutoFocus))
                    {
                        _device.FocusPointOfInterest = focusPoint;
                        _device.FocusMode            = AVCaptureFocusMode.AutoFocus;
                    }
                    if (_device.ExposurePointOfInterestSupported &&
                        _device.IsExposureModeSupported(AVCaptureExposureMode.AutoExpose))
                    {
                        _device.ExposurePointOfInterest = touchLocation;
                        _device.ExposureMode            = AVCaptureExposureMode.AutoExpose;
                    }
                    if (_device.IsWhiteBalanceModeSupported(AVCaptureWhiteBalanceMode.AutoWhiteBalance))
                    {
                        _device.WhiteBalanceMode = AVCaptureWhiteBalanceMode.AutoWhiteBalance; //not sure about this
                    }

                    _device.UnlockForConfiguration();
                }
            }
        }