Ejemplo n.º 1
0
 private void TakeSnapshotButton_Click(object sender, RoutedEventArgs e)
 {
     // Take snapshot of webcam video.
     WebcamViewer.TakeSnapshot();
     FilePath = (WebcamViewer.TakeSnapshot());
     TransferFileName();
 }
Ejemplo n.º 2
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());
 }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
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;
        }
Ejemplo n.º 5
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();
                }
            }
        }
Ejemplo n.º 6
0
 private void TakeSnapshotButton_Click(object sender, RoutedEventArgs e)
 {
     // Take snapshot of webcam video.
     WebcamViewer.TakeSnapshot();
 }