private void TakeSnapshotButton_Click(object sender, RoutedEventArgs e)
 {
     // Take snapshot of webcam video.
     WebcamViewer.TakeSnapshot();
     FilePath = (WebcamViewer.TakeSnapshot());
     TransferFileName();
 }
Exemple #2
0
        public void stopRecording()
        {
            DeviceInteractionHost dr   = Session.dataRecorder;
            Test      currentTest      = Session.currentTest;
            Recording currentRecording = Session.currentRecording;

            dr.stopRecording();
            WebcamViewer.StopRecording();
            endts = _mainWindow.stopwatch.ElapsedMilliseconds;

            Session.currentRecording.fixations         = dr.getCleanFixations();
            Session.currentRecording.saccades          = dr.getSaccades(Session.currentRecording.fixations);
            Session.currentRecording.videoQpcStartTime = startts;
            Session.currentRecording.videoQpcEndTime   = endts;

            String fixationpath = dr.getCleanFixationPath();

            //write fixations
            foreach (Fixation f in Session.currentRecording.fixations)
            {
                dr.writeCleanFixationsToFile(fixationpath, f);
            }

            ////set highest test
            if (currentTest.index > user.highestTestIndex)
            {
                user.highestTestIndex = currentTest.index;
            }


            string[] video   = Directory.GetFiles(WebcamViewer.VideoDirectory, "*.wmv");
            String   dirdata = System.IO.Path.GetFileName(currentRecording.dataDir);

            File.Move(video[0], currentRecording.dataDir + "//" + dirdata + "_U" + ustartts + "_VIDEO_" + "_Q" + startts + "_Q" + endts + ".wmv");
        }
Exemple #3
0
 private void TakeSnapshotButton_Click(object sender, RoutedEventArgs e)
 {
     // Take snapshot of webcam video.
     WebcamViewer.SnapshotFormat = ImageFormat.Bmp;
     WebcamViewer.TakeSnapshot("SnapshotP");
     PreviewBMP.Children.Clear();
     PreviewBMP.Children.Add(new Preview());
 }
        private void TakeSnapshotButton_Click(object sender, RoutedEventArgs e)
        {
            //Take snapshot of webcam video.
            WebcamViewer.TakeSnapshot();
            FilePath = (WebcamViewer.TakeSnapshot());
            var ImageToDb = new ImageToDb(FilePath);

            ImageToDb.Show();
        }
Exemple #5
0
        private void StopCaptureButton_Click(object sender, RoutedEventArgs e)
        {
            WebcamViewer.Width  = 400;
            WebcamViewer.Height = 400;

            // Stop the display of webcam video.
            WebcamViewer.StopPreview();
            TakePhotoBtn.IsEnabled  = false;
            StopCameraBtn.IsEnabled = false;
        }
 public void StartCaptureButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         WebcamViewer.StartPreview();
     }
     catch (Microsoft.Expression.Encoder.SystemErrorException ex)
     {
         MessageBox.Show("Device is in use by another application");
     }
 }
Exemple #7
0
        public void startRecording()
        {
            Session.currentTest.addNewRecording(user);
            Session.dataRecorder.setRecordingPaths(false);
            Session.dataRecorder.startRecording();
            WebcamViewer.StartRecording();
            startts  = _mainWindow.stopwatch.ElapsedMilliseconds;
            ustartts = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

            //recordingStarted();
        }
Exemple #8
0
 private void StopPreview()
 {
     try
     {
         WebcamViewer.StopPreview();
     }
     catch (Microsoft.Expression.Encoder.SystemErrorException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void StartCapture()
 {
     try
     {
         // Display webcam video
         WebcamViewer.StartPreview();
     }
     catch (Microsoft.Expression.Encoder.SystemErrorException ex)
     {
         MessageBox.Show("Device is in use by another application");
     }
 }
Exemple #10
0
        private async void WebcamViewer_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            if (waiting)
            {
                return;
            }
            waiting = true;
            WebcamViewer.StopPreview();
            await Task.Delay(100);

            WebcamViewer.StartPreview();
            waiting = false;
        }
Exemple #11
0
 private void StartCaptureButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         // Display webcam video
         WebcamViewer.StartPreview();
         TakePhotoBtn.IsEnabled  = true;
         StopCameraBtn.IsEnabled = true;
     }
     catch (Microsoft.Expression.Encoder.SystemErrorException ex)
     {
         CustomizeDialog dialog = new CustomizeDialog("カメラが他のアプリケーションに利用されています!");
         dialog.ShowDialog();
     }
 }
Exemple #12
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!initialized)
            {
                initialized = true;

                var cam = EncoderDevices.FindDevices(EncoderDeviceType.Video).Last();
                WebcamViewer.VideoDevice    = cam;
                WebcamViewer.ImageDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "VideoCaptures");
                WebcamViewer.StartPreview();

                DetailsList.ItemsSource = Images;
                VolumeSlider.Value      = DEFAULT_VOLUME * 100;

                _songController.BarStarted += Controller_BarStarted;
            }
        }
Exemple #13
0
        public MainWindow()
        {
            InitializeComponent();

            this.DataContext = this;

            window1         = new Window1();
            window1.Closed += (s, e) => this.Close();
            window1.Show();

            this.Closed += (s, e) => window1.Close();

            rect.ContextMenu = new ContextMenu();

            rect.ContextMenu.Opened += (s, e) =>
            {
                var VideoDevices = EncoderDevices.FindDevices(EncoderDeviceType.Video);

                rect.ContextMenu.Items.Clear();

                foreach (var device in VideoDevices)
                {
                    var menuItem = new MenuItem
                    {
                        Header = device.Name
                    };
                    menuItem.Click += (s1, e1) =>
                    {
                        WebcamViewer.VideoDevice = device;
                        try
                        {
                            WebcamViewer.StartPreview();
                        }
                        catch (Microsoft.Expression.Encoder.SystemErrorException ex)
                        {
                            MessageBox.Show("Device is in use by another application");
                        }
                    };
                    rect.ContextMenu.Items.Add(menuItem);
                }
            };
        }
Exemple #14
0
        private async void Capture_Click(object sender, RoutedEventArgs e)
        {
            CaptureButton.IsEnabled = false;
            CaptureLight.Fill       = new SolidColorBrush(Colors.Red);
            CaptureLight.Visibility = Visibility.Visible;
            await Task.Delay(200);

            CaptureLight.Visibility = Visibility.Hidden;
            await Task.Delay(200);

            CaptureLight.Visibility = Visibility.Visible;
            await Task.Delay(200);

            CaptureLight.Visibility = Visibility.Hidden;
            await Task.Delay(200);

            CaptureLight.Fill       = new SolidColorBrush(Colors.White);
            CaptureLight.Visibility = Visibility.Visible;

            var path = WebcamViewer.TakeSnapshot();
            var img  = CropImage(path);
            var bmp  = new BitmapImage(new Uri(img));

            var result = new FeedbackViewModel {
                Emotion = "Analyzing...", Image = bmp
            };

            if (App.OfflineMode)
            {
                var offline = new string[] { "Happiness", "Surprise", "Anger", "Sadness" };
                result.Emotion = offline[_offlineCount % offline.Length];
                _offlineCount++;
            }
            else
            {
                result.Emotion = await _emotionService.DetectEmotionFromFile(path);
            }
            Images.Add(result);

            CaptureLight.Visibility = Visibility.Hidden;
            CaptureButton.IsEnabled = true;
        }
Exemple #15
0
 private void StopRecordingButton_Click(object sender, RoutedEventArgs e)
 {
     // Stop recording of webcam video to harddisk.
     WebcamViewer.StopRecording();
 }
Exemple #16
0
 public void stopStreaming()
 {
     Session.dataRecorder.stopStreaming();
     WebcamViewer.StopPreview();
     NotStreaming();
 }
Exemple #17
0
 private void StopCaptureButton_Click(object sender, RoutedEventArgs e)
 {
     // Stop the display of webcam video.
     WebcamViewer.StopPreview();
 }
Exemple #18
0
 private void TakeSnapshotButton_Click(object sender, RoutedEventArgs e)
 {
     // Take snapshot of webcam video.
     WebcamViewer.TakeSnapshot();
 }
Exemple #19
0
        private void TakeSnapshotButton_Click(object sender, RoutedEventArgs e)
        {
            // Take snapshot of webcam video.
            var filepath = WebcamViewer.TakeSnapshot();

            //VisualStudioが利用しているインタープリターのパス
            var pythonInterpreterPath = @"C:\RFIDAIsrc\LocalPredict\env\Scripts\python.exe";

            //「1. Python側を実装」にて保存したスクリプトのパス
            var pythonScriptPath = @"C:\RFIDAIsrc\LocalPredict\LocalPredict.py";

            var arguments = new List <string>
            {
                pythonScriptPath,
                filepath //第1引数
            };

            var process = new Process()
            {
                StartInfo = new ProcessStartInfo(pythonInterpreterPath)
                {
                    UseShellExecute        = false,
                    RedirectStandardOutput = true,
                    Arguments = string.Join(" ", arguments),
                },
            };

            process.Start();

            //python側でprintした内容を取得
            var sr = process.StandardOutput;

            process.WaitForExit();

            var result = sr.ReadLine().ToString();

            var finalResult = AnalysisResult(result);

            process.Close();
            if (true)
            {
                //MessageBoxResult resultNotice;
                //認証できた場合
                if (finalResult.Count > 1)
                {
                    ImageSource             imageSource  = new BitmapImage(new Uri(filepath));
                    FaceConfirmResultDialog resultDialog = new FaceConfirmResultDialog(finalResult[0]);

                    float percentage = float.Parse(finalResult[1]) * 100;

                    resultDialog.userPercentage.Text = percentage + "%";
                    resultDialog.userImage.Source    = imageSource;

                    if ((bool)resultDialog.ShowDialog())
                    {
                        //カメラを閉じる
                        TakePhotoBtn.IsEnabled  = false;
                        StopCameraBtn.IsEnabled = false;
                        WebcamViewer.StopPreview();

                        //ユーザー情報を表示する
                        Employee emp = findEmployeeByAccountID(finalResult[0]);
                        fillInTextbox(emp);
                    }
                    //resultNotice = MessageBox.Show("あなたが" + finalResult[0] + "になる可能性は" + finalResult[1] + "です\n よろしでしょうか?", "写真認証結果メッセージ", MessageBoxButton.YesNo);
                    //switch (resultNotice)
                    //{
                    //    //もらった結果を使う
                    //    case MessageBoxResult.Yes:

                    //        //カメラを閉じる
                    //        TakePhotoBtn.IsEnabled = false;
                    //        StopCameraBtn.IsEnabled = false;
                    //        WebcamViewer.StopPreview();
                    //        //ユーザー情報を表示する
                    //        ImageSource imageSource = new BitmapImage(new Uri(filepath));
                    //        EmpImage.Source = imageSource;

                    //        WebcamViewer.Width = 0;
                    //        WebcamViewer.Height = 0;
                    //        //WebcamViewer.Visibility = 0;

                    //        Employee emp = findEmployeeByAccountID(finalResult[0]);
                    //        fillInTextbox(emp);
                    //        break;
                    //    //もらった結果を使わない
                    //    case MessageBoxResult.No:
                    //        break;
                    //}
                }
                //認証できなかった場合
                else
                {
                    CustomizeDialog dialog = new CustomizeDialog("認職できない! \n 写真を再度撮ってください!");
                    dialog.ShowDialog();
                }
            }
        }
 private void StopCaptureButton_Click(object sender, RoutedEventArgs e)
 {
     WebcamViewer.StopPreview();
 }
Exemple #21
0
 public void startStreaming()
 {
     Session.dataRecorder.startStreaming();
     WebcamViewer.StartPreview();
     Streaming();
 }