public int OnSample(INySample i_sample) { if (this._on_sample_event != null) { this._on_sample_event.onSample(this,i_sample); } return 0; }
public int OnSample(INySample i_sample) { if (this._on_sample_event != null) { this._on_sample_event.onSample(this, i_sample); } return(0); }
/* 非同期イベントハンドラ * CaptureDeviceからのイベントをハンドリングして、バッファとテクスチャを更新する。 */ public void onSample(WmCapture i_sender, INySample i_sample) { int w = SCREEN_WIDTH; int h = SCREEN_HEIGHT; int s = w * h; Thread.Sleep(0); lock (this) { //カメラ映像をARのバッファにコピー this._reality_source.setWMCaptureSample(i_sample.GetData(), i_sender.vertical_flip); this._reality.progress(this._reality_source); //テクスチャ内容を更新 this._back_ground.CopyFromRaster((DsRGB565Raster)this._reality_source.refRgbSource()); //UnknownTargetを1個取得して、遷移を試す。 NyARRealityTarget t = this._reality.selectSingleUnknownTarget(); if (t == null) { return; } //ターゲットに一致するデータを検索 ARTKMarkerTable.GetBestMatchTargetResult r = new ARTKMarkerTable.GetBestMatchTargetResult(); if (this._mklib.getBestMatchTarget(t, this._reality_source, r)) { if (r.confidence < 0.5) { //一致率が低すぎる。 return; } //既に認識しているターゲットの内側のものでないか確認する?(この処理をすれば、二重認識は無くなる。) //一致度を確認して、80%以上ならKnownターゲットへ遷移 if (!this._reality.changeTargetToKnown(t, r.artk_direction, r.marker_width)) { //遷移の成功チェック return;//失敗 } //遷移に成功したので、tagにResult情報をコピーしておく。(後で表示に使う) t.tag = r; } else { //一致しないので、このターゲットは捨てる。 this._reality.changeTargetToDead(t, 10); } } return; }
/* 非同期イベントハンドラ * CaptureDeviceからのイベントをハンドリングして、バッファとテクスチャを更新する。 */ public void onSample(WmCapture i_sender, INySample i_sample) { lock (this) { IntPtr data = i_sample.GetData(); this.m_raster.setBuffer(data, i_sender.vertical_flip); //テクスチャ内容を更新 this._back_ground.CopyFromRaster(this.m_raster); //マーカーは見つかったかな? is_marker_enable = this.m_ar.detectMarkerLite(this.m_raster, 110); if (is_marker_enable) { //あればMatrixを計算 this.m_ar.getTransmationMatrix(trans_result); NyARD3dUtil.toD3dCameraView(trans_result, 1, ref trans_matrix); } } Thread.Sleep(0); return; }
public int OnSample(INySample i_sample) { BitmapData bd = this.bmp.LockBits( new Rectangle(0, 0, 240, 320), ImageLockMode.WriteOnly, PixelFormat.Format16bppRgb565); //ビットマップデータのコピー i_sample.CopyToBuffer(bd.Scan0, 0, i_sample.GetDataSize()); this.bmp.UnlockBits(bd); //メインスレッドに同期して画面更新 if (this._dispose_request) { this._dispose_ready = true; } else { myDelegate d = new myDelegate(dg); this.Invoke(d); } return(0); }
/* 非同期イベントハンドラ * CaptureDeviceからのイベントをハンドリングして、バッファとテクスチャを更新する。 */ public void onSample(WmCapture i_sender, INySample i_sample) { lock (this) { IntPtr data=i_sample.GetData(); this.m_raster.setBuffer(data, i_sender.vertical_flip); //テクスチャ内容を更新 this._back_ground.CopyFromRaster(this.m_raster); //マーカーは見つかったかな? is_marker_enable = this.m_ar.detectMarkerLite(this.m_raster, 110); if (is_marker_enable) { //あればMatrixを計算 this.m_ar.getTransmationMatrix(trans_result); NyARD3dUtil.toD3dCameraView(trans_result,1, ref trans_matrix); } } Thread.Sleep(0); return; }