Ejemplo n.º 1
0
        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 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;
        }
        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);
            }
        }
Ejemplo n.º 4
0
        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();
        }