public MainWindow() { m_imagePath = ""; InitializeComponent(); m_emotionsQueue = new Queue <CalcScores>(); m_averageEmotion = new CalcScores(); m_player = new WindowsMediaPlayer(); m_player.settings.autoStart = false; Binding binding_1 = new Binding("SelectedValue"); binding_1.Source = VideoDevicesComboBox; WebcamCtrl.SetBinding(Webcam.VideoDeviceProperty, binding_1); m_picturesDefaultPath = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); WebcamCtrl.ImageDirectory = m_picturesDefaultPath; m_picturesDefaultPath += @"\snapshot.jpg"; WebcamCtrl.FrameRate = 30; WebcamCtrl.FrameSize = new System.Drawing.Size(640, 480); var vidDevices = EncoderDevices.FindDevices(EncoderDeviceType.Video); VideoDevicesComboBox.ItemsSource = vidDevices; VideoDevicesComboBox.SelectedIndex = 0; startCapturing(); scan(); }
private void YCoord_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) { if (xInput.Text.Length > 1 && yInput.Text.Length > 1) { WebcamCtrl.StartVideoFeed(xInput.Text, yInput.Text); } }
private void TakeSnapshotButton_Click(object sender, RoutedEventArgs e) { // Take snapshot of webcam video. WebcamCtrl.TakeSnapshot(); m_imagePath = m_picturesDefaultPath; scan(); }
// Called every 5 seconds private void Timer_handle(object sender, EventArgs e) { IWMPControls controls = m_player.controls; WebcamCtrl.TakeSnapshot(); m_imagePath = m_picturesDefaultPath; scan(); // We need to check if the mood needs to be switched if (controls.currentItem != null && controls.currentItem.duration - controls.currentPosition < 10.0) { DetectedResult emotion = getBestValue(m_averageEmotion); Mood mood = emotion.toMood(); if (mood != m_currentMood) { m_currentMood = mood; ResetPlaylist(mood); } } if (controls.currentItem != null && controls.currentItem.duration - controls.currentPosition < 2.0) { Track track = m_songQueue.Dequeue(); String uri = m_videoPath + track.id + ".mp3"; Log("Playing song: " + uri); m_player.URL = uri; controls.play(); m_songQueue.Enqueue(track); // Box with artist and title track.artist and track.sonh } }
private void TakeSnapshotButton_Click(Object sender, RoutedEventArgs e) { // Take snapshot of webcam video FileName = WebcamCtrl.TakeSnapshot(); WebcamCtrl.StopCapturing(); CamGrid.Visibility = Visibility.Collapsed; TransmitGrid.Visibility = Visibility.Visible; TransmitImage.Source = new ImageSourceConverter().ConvertFromString(FileName) as ImageSource; TransmitImage.Visibility = Visibility.Visible; }
private void StartCaptureButton_Click(object sender, RoutedEventArgs e) { // Display webcam video try { WebcamCtrl.StartCapturing(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void StartCaptureButton_Click(object sender, RoutedEventArgs e) { try { // Display webcam video WebcamCtrl.StartPreview(); } catch (Microsoft.Expression.Encoder.SystemErrorException ex) { MessageBox.Show("Device is in use by another application"); } }
private void StartCaptureButton_Click(object sender, RoutedEventArgs e) { try { // Display webcam video WebcamCtrl.StartPreview(); } catch { MessageBox.Show("Device is in use by another application"); } }
private void button_Copy1_Click(object sender, RoutedEventArgs e) { if (!connected) { WebcamCtrl.StartPreview(); button_Copy1.Content = "Disconnect"; } else { WebcamCtrl.StopRecording(); button_Copy1.Content = "Connect"; } }
private void InitializeComboBox() { WebcamCtrl.FrameRate = 30; WebcamCtrl.FrameSize = new System.Drawing.Size(640, 480); Binding binding_1 = new Binding("SelectedValue"); binding_1.Source = VideoDevicesComboBox; WebcamCtrl.SetBinding(Webcam.VideoDeviceProperty, binding_1); var vidDevices = EncoderDevices.FindDevices(EncoderDeviceType.Video); VideoDevicesComboBox.ItemsSource = vidDevices; VideoDevicesComboBox.SelectedIndex = 0; }
private void TakePhoto_button_Click(object sender, RoutedEventArgs e) { Loger.WriteLog(this.GetType() + "-" + TakePhoto_button.Name + "Clicked"); // timer.Stop(); try { // Take snapshot of webcam video. WebcamCtrl.TakeSnapshot(); } catch (Exception ex) { Helper.ShowPopUp("An Error Occurred!! Please check log for errors", "Exception"); Loger.WriteLog(this.GetType() + "-Exception:" + ex.Message + Environment.NewLine + "StackTrace:" + ex.StackTrace); } ConvertImageandDisplay(); }
public Take_Photo() { InitializeComponent(); Loger.WriteLog(this.GetType() + "- InitializeComponent"); timer.Interval = TimeSpan.FromSeconds(1); timer.Tick += timer_Tick; timer.Start(); // Find available a/v devices vida = EncoderDevices.FindDevices(EncoderDeviceType.Video); Binding binding_1 = new Binding("SelectedValue"); binding_1.Source = VideoDevicesComboBox; WebcamCtrl.SetBinding(Webcam.VideoDeviceProperty, binding_1); // Create directory for saving image files string imagePath = @"WebcamSnapshots"; if (!Directory.Exists(imagePath)) { Directory.CreateDirectory(imagePath); } //// Set some properties of the Webcam control WebcamCtrl.ImageDirectory = imagePath; VideoDevicesComboBox.ItemsSource = vida;; VideoDevicesComboBox.SelectedIndex = 0; //start the preview try { // Display webcam video WebcamCtrl.StartPreview(); } catch (Microsoft.Expression.Encoder.SystemErrorException ex) { Helper.ShowPopUp("Device is in use by another application", "Device Busy"); Loger.WriteLog(this.GetType() + "-Exception:" + ex.Message + Environment.NewLine + "StackTrace:" + ex.StackTrace); } }
private void startCapturing() { try { // Display webcam video WebcamCtrl.StartPreview(); } catch (Microsoft.Expression.Encoder.SystemErrorException ex) { MessageBox.Show("Device is in use by another application"); } m_timer = new System.Windows.Forms.Timer(); m_timer.Tick += new EventHandler(Timer_handle); m_timer.Interval = kInterval; m_timer.Start(); m_timer2 = new System.Windows.Forms.Timer(); m_timer2.Tick += (s, e) => { if (m_player == null) { return; } IWMPControls controls = m_player.controls; if (controls == null || controls.currentItem == null) { return; } double pos = controls.currentPosition; double duration = controls.currentItem.duration; if (duration > 0.1) { TheSlider.Value = pos / duration; } }; m_timer2.Interval = 400; m_timer2.Start(); }
private void StartRecieveBtn_Click(object sender, RoutedEventArgs e) { string extension; switch (ReceiveType) { case FileType.Text: extension = ".txt"; break; case FileType.Jpeg: extension = ".jpg"; break; default: extension = ".jpg"; break; } FileName = Sockets.ReceiveData(ServerIP, ServerPort, DestinationPath, WebcamCtrl.TimeStamp(), extension); if (!string.IsNullOrEmpty(FileName)) { if (ReceiveType == FileType.Jpeg) { ReceiveImage.Source = new ImageSourceConverter().ConvertFromString(FileName) as ImageSource; ReceiveImage.Visibility = Visibility.Visible; } else if (ReceiveType == FileType.Text) { DocViewer.Visibility = Visibility.Visible; var paragraph = new Paragraph(); paragraph.Inlines.Add(File.ReadAllText(FileName)); DocViewer.Document = new FlowDocument(paragraph); } } }
private void StopCaptureButton_Click(object sender, RoutedEventArgs e) { // Stop the display of webcam video. WebcamCtrl.StopPreview(); }
private void SaveSnapshotButton_Click(object sender, RoutedEventArgs e) { WebcamCtrl.SaveSnapshot(); }
public MainWindow() { InitializeComponent(); timer.Start(); setUpBaudRates(); var config = new SeriesConfiguration <tempGraph>(); config.Y(model => model.temperature); config.X(model => model.time.ToOADate()); Series = new SeriesCollection(config) { new LineSeries { Values = new ChartValues <tempGraph>() } }; Series.Add(new LineSeries { Values = new ChartValues <tempGraph>() }); Series.Add(new LineSeries { Values = new ChartValues <tempGraph>() }); Series[0].Title = "External Temperature"; Series[1].Title = "Internal Temperature"; Series[2].Title = "Ground Temperature"; XFormatter = val => DateTime.FromOADate(val).ToString("mm.ss"); YFormatter = val => val + " °"; DataContext = this; _timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(1000) }; _timer.Tick += TimerOnTick; _timer.Start(); var config2 = new SeriesConfiguration <pressureGraph>(); config2.Y(model => model.pressure); config2.X(model => model.time.ToOADate()); Series2 = new SeriesCollection(config2) { new LineSeries { Values = new ChartValues <pressureGraph>() } }; Series2.Add(new LineSeries { Values = new ChartValues <pressureGraph>() }); Series2[0].Title = "Barometric Pressure"; Series2[1].Title = "Ground Barometric Pressure"; XFormatter2 = val => DateTime.FromOADate(val).ToString("mm.ss"); YFormatter2 = val => val + "hPa"; DataContext = this; _timer2 = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(1000) }; _timer2.Tick += Timer2OnTick; _timer2.Start(); this.Show(); setUpPossibleInputsForSerialPort(); ///AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA Binding binding_1 = new Binding("SelectedValue"); binding_1.Source = VideoDevicesComboBox; WebcamCtrl.SetBinding(Webcam.VideoDeviceProperty, binding_1); Binding binding_2 = new Binding("SelectedValue"); binding_2.Source = AudioDevicesComboBox; WebcamCtrl.SetBinding(Webcam.AudioDeviceProperty, binding_2); // Create directory for saving video files string videoPath = @"C:\VideoClips"; if (!Directory.Exists(videoPath)) { Directory.CreateDirectory(videoPath); } // Create directory for saving image files string imagePath = @"C:\WebcamSnapshots"; if (!Directory.Exists(imagePath)) { Directory.CreateDirectory(imagePath); } //AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA // Set some properties of the Webcam control WebcamCtrl.VideoDirectory = videoPath; WebcamCtrl.ImageDirectory = imagePath; WebcamCtrl.FrameRate = 72; WebcamCtrl.FrameSize = new System.Drawing.Size(1080, 720); // Find available a/v devices var vidDevices = EncoderDevices.FindDevices(EncoderDeviceType.Video); var audDevices = EncoderDevices.FindDevices(EncoderDeviceType.Audio); VideoDevicesComboBox.ItemsSource = vidDevices; AudioDevicesComboBox.ItemsSource = audDevices; VideoDevicesComboBox.SelectedIndex = 0; AudioDevicesComboBox.SelectedIndex = 0; releaseServo.IsEnabled = false; servoArm.IsEnabled = false; t1.IsEnabled = false; t2.IsEnabled = false; bw.DoWork += Bw_DoWork; bw.RunWorkerCompleted += Bw_RunWorkerCompleted; bw.RunWorkerAsync(); }
private void btnUgasiKameru_Click(object sender, RoutedEventArgs e) { WebcamCtrl.StopCapture(); }
private void StartVideoFeed_Click(object sender, RoutedEventArgs e) { WebcamCtrl.StartVideoFeed(xInput.Text, yInput.Text); }
private void StopCaptureButton_Click(Object sender, RoutedEventArgs e) { WebcamCtrl.StopCapturing(); }
private void StopVideoFeed_Click(object sender, RoutedEventArgs e) { WebcamCtrl.StopVideoFeed(); }
private void StopRecordingButton_Click(object sender, RoutedEventArgs e) { // Stop recording of webcam video to harddisk. WebcamCtrl.StopRecording(); }
private void TakeSnapshotButton_Click(object sender, RoutedEventArgs e) { // Take snapshot of webcam video. WebcamCtrl.TakeSnapshot(); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { WebcamCtrl.StopVideoFeed(); }