public Form1() { InitializeComponent(); //ARの設定 //AR用カメラパラメタファイルをロード NyARParam ap = NyARParam.createFromARParamFile(new StreamReader(AR_CAMERA_FILE)); ap.changeScreenSize(320, 240); //AR用のパターンコードを読み出し NyARCode code = NyARCode.createFromARPattFile(new StreamReader(AR_CODE_FILE),16, 16); NyARDoubleMatrix44 result_mat = new NyARDoubleMatrix44(); //計算モードの設定 //キャプチャを作る /************************************************** このコードは、0番目(一番初めに見つかったキャプチャデバイス) を使用するようにされています。 複数のキャプチャデバイスを持つシステムの場合、うまく動作しないかもしれません。 n番目のデバイスを使いたいときには、CaptureDevice cap=cl[0];←ここの0を変えてください。 手動で選択させる方法は、SimpleLiteDirect3Dを参考にしてください。 **************************************************/ CaptureDeviceList cl=new CaptureDeviceList(); CaptureDevice cap=cl[0]; cap.SetCaptureListener(this); cap.PrepareCapture(320, 240,30); this.m_cap = cap; //ラスタを作る。 this.m_raster = new DsRgbRaster(cap.video_width, cap.video_height,NyARBufferType.OBJECT_CS_Bitmap); //1パターンのみを追跡するクラスを作成 this.m_ar = NyARSingleDetectMarker.createInstance(ap, code, 80.0); this.m_ar.setContinueMode(false); }
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 (Form2 frm2 = new Form2()) { frm2.ShowDialog(capture_device_list, out cdevice_number); } using (CaptureDevice capture_device = capture_device_list[cdevice_number]) { // フォームとメインサンプルクラスを作成 using (Form1 frm = new Form1()) using (ABGRAcapture sample = new ABGRAcapture()) { frm.ref_cap = sample; // アプリケーションの初期化 if (sample.InitializeApplication(frm, capture_device)) { // メインフォームを表示 frm.Show(); //キャプチャ開始 sample.StartCap(); // フォームが作成されている間はループし続ける while (frm.Created) { // メインループ処理を行う sample.MainLoop(); //スレッドスイッチ Thread.Sleep(1); // イベントがある場合はその処理する Application.DoEvents(); } //キャプチャの停止 sample.StopCap(); } else { // 初期化に失敗 } } } }
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()) using (SimpleLiteD3d sample = new SimpleLiteD3d()) { if (sample.InitializeApplication(frm, capture_device)) { frm.Show(); sample.StartCap(); while (frm.Created) { sample.MainLoop(); Thread.Sleep(1); Application.DoEvents(); } sample.StopCap(); } else { } } } }
public DialogResult ShowDialog(CaptureDeviceList i_clist,out int o_selected_no) { if (i_clist.count < 1) { throw new Exception("カメラが無いのに選ぼうとしてはいけない。"); } for (int i = 0; i < i_clist.count; i++) { this.comboBox1.Items.Add(i_clist[i].name + ":"); } this.comboBox1.SelectedIndex = 0; DialogResult ret=base.ShowDialog(); o_selected_no = this.comboBox1.SelectedIndex; return ret; }
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(); } } } }
public void run() { //キャプチャデバイスリストを取得 CaptureDeviceList capture_device_list = new CaptureDeviceList(); if (capture_device_list.count < 1) { MessageBox.Show("The capture system is not found."); return; } //キャプチャデバイスを選択してもらう。 int cdevice_number = 0; using (CameraSelectDialog camera_select = new CameraSelectDialog()) { camera_select.ShowDialog(capture_device_list, out cdevice_number); } // フォームとメインサンプルクラスを作成 using (D3dSketchForm mwin = new D3dSketchForm()) { this.form = mwin; using (CaptureDevice capture_device = capture_device_list[cdevice_number]) { mwin.Show(); //setup this.setup(capture_device); if (this._d3d == null) { this._d3d = prepareD3dDevice(this.form, this._dpp); } //loop while (mwin.Created) { this.loop(this._d3d); //スレッドスイッチ Thread.Sleep(1); // イベントがある場合はその処理する Application.DoEvents(); } } this.cleanup(); this._d3d.Dispose(); } }