static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //キャプチャデバイスリストを取得 CaptureDeviceList capture_device_list = new CaptureDeviceList(); if (capture_device_list.count < 1) { MessageBox.Show("キャプチャデバイスが見つかりませんでした。"); return; } //キャプチャデバイスを選択してもらう。 int cdevice_number = 0; using (CameraSelectDialog frm2 = new CameraSelectDialog()) { frm2.ShowDialog(capture_device_list, out cdevice_number); } using (CaptureDevice capture_device = capture_device_list[cdevice_number]) { // フォームとメインサンプルクラスを作成 using (Form1 frm = new Form1()){ // メインフォームを表示 frm.Show(); using (SimpleLiteMain sample = new SimpleLiteMain(frm, capture_device)) { capture_device.StartCapture(); // フォームが作成されている間はループし続ける while (frm.Created) { // メインループ処理を行う sample.MainLoop(); //スレッドスイッチ Thread.Sleep(1); // イベントがある場合はその処理する Application.DoEvents(); } capture_device.StopCapture(); } } } }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { MyCaptureDevice.StartCapture(); DispatcherTimer oTimer = new DispatcherTimer(); oTimer.Interval = TimeSpan.FromSeconds(0.01); oTimer.Tick += (s1, e1) => { Dispatcher.Invoke(new Action(delegate() { this._ms.update(this._ss); if (this._ms.isExistMarker(this.mid)) { double d = this._ms.getConfidence(this.mid); NyARIntPoint2d[] oPoints = this._ms.getVertex2D(this.mid); this.CvMainZm.Children.Clear(); Polygon oPolygon = new Polygon() { SnapsToDevicePixels = true, Fill = new SolidColorBrush(Colors.Violet), Opacity = 0.8, Stroke = new SolidColorBrush(Colors.Red) }; oPolygon.Points = new PointCollection(new Point[] { new Point(oPoints[0].x, 600 - oPoints[0].y), new Point(oPoints[1].x, 600 - oPoints[1].y), new Point(oPoints[2].x, 600 - oPoints[2].y), new Point(oPoints[3].x, 600 - oPoints[3].y) }); this.CvMainZm.Children.Add(oPolygon); } else { Console.WriteLine("Checked Nothing"); } })); }; oTimer.Start(); }
private void CameraPnl1_Loaded(object sender, RoutedEventArgs e) { MyCaptureDevice.StartCapture(); }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { MyCaptureDevice.StartCapture(); }
/// <summary> /// Inicia a captura da câmera /// </summary> /// <param name="cap"></param> public void startCapture(CaptureDevice cap) { cap.StartCapture(); }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { MyCaptureDevice.StartCapture(); this.SlidThresholdZm.ValueChanged += SlidThresholdZm_ValueChanged; }