/// <summary> /// uses WMI to get all available cameras and add them to the list /// </summary> private void GetAvailableCameraList() { WebCameraControl wc = new WebCameraControl(); AvailableCameras = new List <WebCameraId>(wc.GetVideoCaptureDevices()); SelectedCameraIndex = 0; }
public static void InitializeCombobox(ComboBox comboBox, WebCameraControl camera) { comboBox.ItemsSource = camera.GetVideoCaptureDevices(); if (comboBox.Items.Count > 0) { comboBox.SelectedItem = comboBox.Items[0]; } }
//Custom methods public void ActivateCamera() { //Gets a list of all available webcams and selects the first one idList = webCameraControl.GetVideoCaptureDevices(); var id = idList.ElementAt(0); //Activates the webcam webCameraControl.StartCapture(id); }
private void InitializeComboBox() { ComboBox.ItemsSource = WebCameraControl.GetVideoCaptureDevices(); if (ComboBox.Items.Count > 0) { ComboBox.SelectedItem = ComboBox.Items[0]; } }
public void loadSources() { foreach (WebCameraId camera in webCameraControl1.GetVideoCaptureDevices()) { comboBox1.Items.Add(new ComboBoxItem(camera)); } if (comboBox1.Items.Count > 0) { comboBox1.SelectedItem = comboBox1.Items[0]; } }
public MainWindow() { InitializeComponent(); _reader = new BarcodeReader(); CapturingDevicesComboBox.ItemsSource = WebCameraControl.GetVideoCaptureDevices(); if (CapturingDevicesComboBox.Items.Count > 0) { CapturingDevicesComboBox.SelectedItem = CapturingDevicesComboBox.Items[0]; } }
public void Refresh() { AvailableCameras.Clear(); if (_camControl == null) { return; } foreach (var cam in _camControl.GetVideoCaptureDevices()) { AvailableCameras.Add(cam); } }
public void SendPicture() { WebEye.WebCameraControl webCameraControl1 = new WebCameraControl(); foreach (WebCameraId camera in webCameraControl1.GetVideoCaptureDevices()) { webCameraControl1.StartCapture(camera); Thread.Sleep(200); Bitmap test = GrayScale(new Bitmap(webCameraControl1.GetCurrentImage())); Program.A.SetMyWebCam(ScreenCapture.imageToByteArray(test)); } if (webCameraControl1.IsCapturing) { webCameraControl1.StopCapture(); } webCameraControl1.Dispose(); }
private Bitmap GetWebCamImage() { Bitmap image = null; var webCameraControl = new WebCameraControl(); WebCameraId camera = null; foreach (WebCameraId c in webCameraControl.GetVideoCaptureDevices()) { if (c != null) { camera = c; break; } } if (camera != null) { webCameraControl.StartCapture(camera); System.Threading.Thread.Sleep(2000); image = webCameraControl.GetCurrentImage(); System.Threading.Thread.Sleep(250); webCameraControl.StopCapture(); } return(image); }
// Method to perform all the steps to take a picture. public void takePicture() { WebCameraControl control = new WebCameraControl(); WebCameraId camera = null; if (control.GetVideoCaptureDevices().Count() > 0) { //Select the first camera we find. This can be more sophisticated. camera = (WebCameraId)control.GetVideoCaptureDevices().First(); control.RenderSize = new System.Windows.Size(1920, 1080); control.StartCapture(camera); // This seems risky. // TODO change this to a more secure method of waiting. while (control.GetCurrentImage() == null) { } // Take 50 images (about 2 seconds.) The camera should have focussed and exposed correctly in that time. Image[] img = new Image[50]; BitmapImage image = new BitmapImage(); for (int i = 0; i < img.Length; i++) { img[i] = control.GetCurrentImage(); MemoryStream ms = new MemoryStream(); img[i].Save(ms, ImageFormat.Bmp); ms.Position = 0; image = new BitmapImage(); image.BeginInit(); ms.Seek(0, SeekOrigin.Begin); image.StreamSource = ms; image.EndInit(); } // Store the image in DataDelegate. DataDelegate.customerImage = image; // Record the time taken. DataDelegate.timeCustomerImageTaken = DateTime.Now; control.StopCapture(); // TODO Fix the code below to allow saving of the file to disk and/or to database. /* * String path = System.IO.Path.Combine(Environment.CurrentDirectory, @"..\..\Assets\audio\PhotographComplete.wav"); * Audio.play(path); * * string filename = @"/GLASS/CustomerPhoto"; * string ext = @".png"; * var filePath = @Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), filename + ext); * * SaveFileDialog saveFile = new SaveFileDialog(); * saveFile.Filter = "PNG file |*.png"; * saveFile.FileName = filename + DateTime.Now.Date.Year + "-" + DateTime.Now.Date.Month + "-" + DateTime.Now.Date.Day + "-" + ext; * saveFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); * * if (saveFile.ShowDialog() == DialogResult.OK) * { * img.Last().Save(filePath); * } */ } }
private void InitializeComboBox() { VideoDevicesComboBox.ItemsSource = WebCameraControl.GetVideoCaptureDevices(); }