private void StartCalibration_Click(object sender, RoutedEventArgs e) { //カメラプレビューの停止 timerToPreview.Stop(); //コントロールの切り替え InitializeGrid.Visibility = System.Windows.Visibility.Hidden; //チェスボード投影 if (!IsMaximized) { bitmap = new WriteableBitmap((int)ImageWidthStandard, (int)ImageHeightStandard, 92, 92, PixelFormats.Gray8, null); } else { bitmap = new WriteableBitmap((int)mainGrid.ActualWidth, (int)mainGrid.ActualHeight, 92, 92, PixelFormats.Gray8, null); } TSUtil.CopyImageToBitmap(bitmap, calibrator.ChessBoardMat); SetBitmapToImage(PreviewImage, bitmap); //キャリブレーションテストの初期化 calibratingCount = 0; //キャリブレーションの実行 timerToCalibrate = new DispatcherTimer(); timerToCalibrate.Tick += (s, ea) => CalibrateCameraInputLoop(s, ea); timerToCalibrate.Interval = TimeSpan.FromMilliseconds(1); timerToCalibrate.Start(); }
private void PreviewCameraInputLoop(object s, EventArgs e) { using (Mat mat = new Mat()) { vc.Retrieve(mat, CameraChannels.Zero); TSUtil.CopyImageToBitmap(bitmap, mat); } SetBitmapToImage(PreviewImage, bitmap); }