private void PrepareBracketsWithCompletionHandler(Action <bool, NSError> completion)
        {
            switch (bracketModeControl.SelectedSegment)
            {
            case 0:
                Console.WriteLine("Configuring auto-exposure brackets...");
                bracketSettings = ExposureBrackets;
                break;

            case 1:
                Console.WriteLine("Configuring duration/ISO brackets...");
                bracketSettings = DurationISOBrackets;
                break;
            }

            CMVideoDimensions dimesnions = captureDevice.ActiveFormat.HighResolutionStillImageDimensions;
            var dimensions = new CGSize(dimesnions.Width, dimesnions.Height);

            if (imageStripes != null)
            {
                imageStripes.Dispose();
            }

            imageStripes = new StripedImage(dimensions, (int)dimensions.Width / 12, (int)bracketSettings.Count);
            Console.WriteLine("Warming brackets: {0}", bracketSettings.Count);
            AVCaptureConnection connection = stillImageOutput.ConnectionFromMediaType(AVMediaType.Video);

            stillImageOutput.PrepareToCaptureStillImageBracket(connection, bracketSettings.ToArray(), (success, error) => {
                completion(success, error);
            });
        }
Exemplo n.º 2
0
 public override void VideoView(TVIVideoView view, CMVideoDimensions dimensions)
 {
     OnDimensionsDidChange(new DimensionsDidChangeEventArgs(view, dimensions));
 }
Exemplo n.º 3
0
 public DimensionsDidChangeEventArgs(TVIVideoView view, CMVideoDimensions dimensions)
 {
     View       = view;
     Dimensions = dimensions;
 }
Exemplo n.º 4
0
        protected virtual void SetupAVCapture()
        {
            AVCaptureDeviceInput deviceInput;

            // Select a video device, make an input
            var videoDevice = AVCaptureDeviceDiscoverySession.Create(
                new AVCaptureDeviceType[] { AVCaptureDeviceType.BuiltInWideAngleCamera },
                AVMediaType.Video,
                AVCaptureDevicePosition.Back
                ).Devices.FirstOrDefault();

            deviceInput = new AVCaptureDeviceInput(videoDevice, out NSError error);
            if (error != null)
            {
                Console.WriteLine($"Could not create video device input: {error.LocalizedDescription}");
                return;
            }

            session.BeginConfiguration();
            session.SessionPreset = AVCaptureSession.Preset640x480; // Model image size is smaller

            // Add a video input
            if (!session.CanAddInput(deviceInput))
            {
                Console.WriteLine("Could not add video device input to the session");
                session.CommitConfiguration();
                return;
            }
            session.AddInput(deviceInput);

            if (session.CanAddOutput(videoDataOutput))
            {
                session.AddOutput(videoDataOutput);
                // Add a video data ouptut
                videoDataOutput.AlwaysDiscardsLateVideoFrames = true;
                videoDataOutput.WeakVideoSettings             = new NSDictionary(CVPixelBuffer.PixelFormatTypeKey, CVPixelFormatType.CV420YpCbCr8BiPlanarFullRange);
                videoDataOutput.SetSampleBufferDelegateQueue(this, videoDataOutputQueue);
            }
            else
            {
                Console.WriteLine("Could not add video data output to the session");
                session.CommitConfiguration();
                return;
            }

            var captureConnection = videoDataOutput.ConnectionFromMediaType(AVMediaType.Video);

            // Always process the frames
            captureConnection.Enabled = true;
            videoDevice.LockForConfiguration(out NSError error2);
            if (error2 == null)
            {
                var formatDescription        = videoDevice.ActiveFormat.FormatDescription as CMVideoFormatDescription;
                CMVideoDimensions dimensions = formatDescription.Dimensions;
                bufferSize.Width  = dimensions.Width;
                bufferSize.Height = dimensions.Height;
                videoDevice.UnlockForConfiguration();
            }
            else
            {
                Console.WriteLine($"{error2.LocalizedDescription}");
            }
            session.CommitConfiguration();
            previewLayer = AVCaptureVideoPreviewLayer.FromSession(session);
            previewLayer.VideoGravity = AVLayerVideoGravity.ResizeAspectFill;
            rootLayer          = previewView.Layer;
            previewLayer.Frame = rootLayer.Bounds;
            rootLayer.AddSublayer(previewLayer);
        }