private void MainForm_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.P) // If key 'p' is pressed. { Execute(); } if (e.KeyCode == Keys.End) // End camera streams. { CameraView1.SignalToStop(); CameraView1.WaitForStop(); CameraView2.SignalToStop(); CameraView2.WaitForStop(); Executed = false; } if (e.KeyCode == Keys.V) { _3DView view = new _3DView(); view.Show(); } }
/// <summary> /// Open detected local camera. /// </summary> private void OpenCamera2() { // Show camera selection form. CameraSelector cameraSelection = new CameraSelector(); if (cameraSelection.ShowDialog(this) == DialogResult.OK) { // Create video source from selected camera. VideoCaptureDevice theCamera = new VideoCaptureDevice(cameraSelection.SelectedCamera); // Close previous video source. CameraView2.SignalToStop(); CameraView2.WaitForStop(); // Choose video resolution. theCamera.VideoResolution = theCamera.VideoCapabilities[cameraSelection.SelectedOption]; // Set the new video source. CameraView2.VideoSource = theCamera; CameraView2.Start(); OptionsControl.ShowDialog(); CameraReady = true; } }