Esempio n. 1
0
        private void CalibrateCameraInputLoop(object s, EventArgs ea)
        {
            Trace.WriteLine("Trying Calibration Count:" + (calibratingCount + 1));

            using (Mat mat = new Mat())
            {
                vc.Retrieve(mat, CameraChannels.Zero);
                vtArray = calibrator.Detect10x7(mat);
                if (vtArray != null)
                {
                    Trace.WriteLine("Calibration succeeded!");

                    //キャリブレーションの停止
                    timerToCalibrate.Stop();

                    //コントロールの切り替え
                    ViewCameraInputGrid.Visibility = System.Windows.Visibility.Hidden;
                    ProcessGrid.Visibility         = Visibility.Visible;

                    //タッチボタン・スクロールバーの初期化
                    EnterButton.Prepare(mainGrid, PreviewImage);
                    ScrollBar.PrepareScrollbar(mainGrid, PreviewImage);

                    timerToRetrieveBackground          = new DispatcherTimer();
                    timerToRetrieveBackground.Tick    += (ss, e) => RetrieveButtonBackground(ss, e);
                    timerToRetrieveBackground.Interval = TimeSpan.FromMilliseconds(1);
                    timerToRetrieveBackground.Start();
                }
                else if ((++calibratingCount + 1) > Max_calibratingCount)
                {
                    Trace.WriteLine("Failed Calibration...");

                    //キャリブレーションの停止
                    timerToCalibrate.Stop();

                    //コントロールの切り替え
                    InitializeGrid.Visibility = System.Windows.Visibility.Visible;

                    //カメラプレビューの再開
                    bitmap = new WriteableBitmap(VGACameraWidth, VGACameraHeight, 92, 92, PixelFormats.Bgr24, null);
                    timerToPreview.Start();
                }
            }
        }