Example #1
0
        // Creates a prompt asking the user which video device to use (webcam, usb camera, etc...)
        public void PromptVideoSource()
        {
            // If their is no video source
            if (videoSourcePlayer == null)
            {
                // Create the video source player and add it to the form
                videoSourcePlayer = new VideoSourcePlayer();

                this.Controls.Add(videoSourcePlayer);

                // Properties to add the video source player to the form
                videoSourcePlayer.Dock        = DockStyle.Fill;
                videoSourcePlayer.Location    = new Point(0, 0);
                videoSourcePlayer.BorderColor = Color.Transparent;
                videoSourcePlayer.BringToFront();

                // Add the new frame callback to the source player
                videoSourcePlayer.NewFrame += videoSourcePlayer_NewFrame;

                // Force to keep the original source aspect ratio
                videoSourcePlayer.KeepAspectRatio = true;
            }

            // Create the dialog box
            VideoCaptureDeviceForm videoDialogForm = new VideoCaptureDeviceForm();

            // If the dialog exited correctly, open the video source
            if (videoDialogForm.ShowDialog(this) == DialogResult.OK)
            {
                // create video source
                VideoCaptureDevice videoSource = videoDialogForm.VideoDevice;

                // open the video device
                OpenVideoSource(videoSource);
            }
        }