示例#1
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;
        }
示例#2
0
 private void StopPreview()
 {
     try
     {
         WebcamViewer.StopPreview();
     }
     catch (Microsoft.Expression.Encoder.SystemErrorException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#3
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;
        }
示例#4
0
 private void StopCaptureButton_Click(object sender, RoutedEventArgs e)
 {
     // Stop the display of webcam video.
     WebcamViewer.StopPreview();
 }
 private void StopCaptureButton_Click(object sender, RoutedEventArgs e)
 {
     WebcamViewer.StopPreview();
 }
示例#6
0
 public void stopStreaming()
 {
     Session.dataRecorder.stopStreaming();
     WebcamViewer.StopPreview();
     NotStreaming();
 }
示例#7
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();
                }
            }
        }