Esempio n. 1
0
		public override void WindowControllerDidLoadNib (NSWindowController windowController)
		{
			base.WindowControllerDidLoadNib (windowController);

			// A reference to the window controller must be kept on the managed side
			// to keep the object from being GC'd so that the delegates below resolve.
			// Don't remove unless the framework is updated to track the reference.
			this.windowController = windowController;

			NSError err;
			
			windowController.Window.WillClose += delegate {
				if (captureSession != null)
					captureSession.StopRunning ();
				var dev = captureInput.Device;
				if (dev.IsOpen)
					dev.Close ();
			};
			
			// Create a movie, and store the information in memory on an NSMutableData
			movie = new QTMovie (new NSMutableData (1), out err);
			if (movie == null){
				NSAlert.WithError (err).RunModal ();
				return;
			}
			movieView.Movie = movie;
			
			// Find video device
			captureSession = new QTCaptureSession ();
			var device = QTCaptureDevice.GetDefaultInputDevice (QTMediaType.Video);
			if (!device.Open (out err)){
				NSAlert.WithError (err).RunModal ();
				return;
			}
			
			// Add device input
			captureInput = new QTCaptureDeviceInput (device);
			if (!captureSession.AddInput (captureInput, out err)){
				NSAlert.WithError (err).RunModal ();
				return;
			}
			
			// Create decompressor for video output, to get raw frames
			decompressedVideo = new QTCaptureDecompressedVideoOutput ();
			decompressedVideo.DidOutputVideoFrame += delegate(object sender, QTCaptureVideoFrameEventArgs e) {
				lock (this){
					currentImage = e.VideoFrame;
				}
			};
			if (!captureSession.AddOutput (decompressedVideo, out err)){
				NSAlert.WithError (err).RunModal ();
				return;
			}
			
			// Activate preview
			captureView.CaptureSession = captureSession;
			
			// Start running.
			captureSession.StartRunning ();
		}
Esempio n. 2
0
        public override void WindowControllerDidLoadNib(NSWindowController windowController)
        {
            NSError err;

            // Create a movie, and store the information in memory on an NSMutableData
            movie = new QTMovie(new NSMutableData(1), out err);
            if (movie == null)
            {
                NSAlert.WithError(err).RunModal();
                return;
            }

            movieView.Movie = movie;

            // Find video device
            captureSession = new QTCaptureSession();
            var device = QTCaptureDevice.GetDefaultInputDevice(QTMediaType.Video);

            if (device == null)
            {
                new NSAlert {
                    MessageText = "You do not have a camera connected."
                }.BeginSheet(windowController.Window);
                return;
            }
            else if (!device.Open(out err))
            {
                NSAlert.WithError(err).BeginSheet(windowController.Window);
                return;
            }

            // Add device input
            captureInput = new QTCaptureDeviceInput(device);
            if (!captureSession.AddInput(captureInput, out err))
            {
                NSAlert.WithError(err).BeginSheet(windowController.Window);
                return;
            }

            // Create decompressor for video output, to get raw frames
            decompressedVideo = new QTCaptureDecompressedVideoOutput();
            decompressedVideo.DidOutputVideoFrame += delegate(object sender, QTCaptureVideoFrameEventArgs e) {
                lock (this) {
                    currentImage = e.VideoFrame;
                }
            };
            if (!captureSession.AddOutput(decompressedVideo, out err))
            {
                NSAlert.WithError(err).BeginSheet(windowController.Window);
                return;
            }

            // Activate preview
            captureView.CaptureSession = captureSession;

            // Start running.
            captureSession.StartRunning();
        }
Esempio n. 3
0
		public override void WindowControllerDidLoadNib (NSWindowController windowController)
		{
			NSError err;

			// Create a movie, and store the information in memory on an NSMutableData
			movie = new QTMovie (new NSMutableData (1), out err);
			if (movie == null) {
				NSAlert.WithError (err).RunModal ();
				return;
			}

			movieView.Movie = movie;

			// Find video device
			captureSession = new QTCaptureSession ();
			var device = QTCaptureDevice.GetDefaultInputDevice (QTMediaType.Video);
			if (device == null) {
				new NSAlert { MessageText = "You do not have a camera connected." }.BeginSheet (windowController.Window);
				return;
			} else if (!device.Open (out err)) {
				NSAlert.WithError (err).BeginSheet (windowController.Window);
				return;
			}

			// Add device input
			captureInput = new QTCaptureDeviceInput (device);
			if (!captureSession.AddInput (captureInput, out err)) {
				NSAlert.WithError (err).BeginSheet (windowController.Window);
				return;
			}

			// Create decompressor for video output, to get raw frames
			decompressedVideo = new QTCaptureDecompressedVideoOutput ();
			decompressedVideo.DidOutputVideoFrame += delegate(object sender, QTCaptureVideoFrameEventArgs e) {
				lock (this) {
					currentImage = e.VideoFrame;
				}
			};
			if (!captureSession.AddOutput (decompressedVideo, out err)) {
				NSAlert.WithError (err).BeginSheet (windowController.Window);
				return;
			}

			// Activate preview
			captureView.CaptureSession = captureSession;

			// Start running.
			captureSession.StartRunning ();
		}
        public override void WindowControllerDidLoadNib(NSWindowController windowController)
        {
            base.WindowControllerDidLoadNib(windowController);

            // A reference to the window controller must be kept on the managed side
            // to keep the object from being GC'd so that the delegates below resolve.
            // Don't remove unless the framework is updated to track the reference.
            this.windowController = windowController;

            NSError err;

            windowController.Window.WillClose += delegate {
                if (captureSession != null)
                {
                    captureSession.StopRunning();
                }
                var dev = captureInput.Device;
                if (dev.IsOpen)
                {
                    dev.Close();
                }
            };

            // Create a movie, and store the information in memory on an NSMutableData
            movie = new QTMovie(new NSMutableData(1), out err);
            if (movie == null)
            {
                NSAlert.WithError(err).RunModal();
                return;
            }
            movieView.Movie = movie;

            // Find video device
            captureSession = new QTCaptureSession();
            var device = QTCaptureDevice.GetDefaultInputDevice(QTMediaType.Video);

            if (!device.Open(out err))
            {
                NSAlert.WithError(err).RunModal();
                return;
            }

            // Add device input
            captureInput = new QTCaptureDeviceInput(device);
            if (!captureSession.AddInput(captureInput, out err))
            {
                NSAlert.WithError(err).RunModal();
                return;
            }

            // Create decompressor for video output, to get raw frames
            decompressedVideo = new QTCaptureDecompressedVideoOutput();
            decompressedVideo.DidOutputVideoFrame += delegate(object sender, QTCaptureVideoFrameEventArgs e) {
                lock (this){
                    currentImage = e.VideoFrame;
                }
            };
            if (!captureSession.AddOutput(decompressedVideo, out err))
            {
                NSAlert.WithError(err).RunModal();
                return;
            }

            // Activate preview
            captureView.CaptureSession = captureSession;

            // Start running.
            captureSession.StartRunning();
        }