/** * [readonly]マーカにマッチした{@link NyARMatchPattDeviationColorData}インスタンスを得る。 * @ */ public NyARMatchPattDeviationColorData getDeviationColorData(MarkerInfoARMarker i_marker, INyARPerspectiveCopy i_pix_drv, NyARIntPoint2d[] i_vertex) { int mk_edge = i_marker.patt_edge_percentage; for (int i = this.items.Count - 1; i >= 0; i--) { Item ptr = this.items[i]; if (!ptr._patt.getSize().isEqualSize(i_marker.patt_w, i_marker.patt_h) || ptr._patt_edge != mk_edge) { //サイズとエッジサイズが合致しない物はスルー continue; } //古かったら更新 i_pix_drv.copyPatt(i_vertex, ptr._patt_edge, ptr._patt_edge, ptr._patt_resolution, ptr._patt); ptr._patt_d.setRaster(ptr._patt); return(ptr._patt_d); } //無い。新しく生成 Item item = new Item(i_marker.patt_w, i_marker.patt_h, mk_edge); //タイムスタンプの更新とデータの生成 i_pix_drv.copyPatt(i_vertex, item._patt_edge, item._patt_edge, item._patt_resolution, item._patt); item._patt_d.setRaster(item._patt); this.items.Add(item); return(item._patt_d); }
public int addARMarker(INyARRgbRaster i_raster, int i_patt_resolution, int i_patt_edge_percentage, double i_marker_size) { NyARCode c = new NyARCode(i_patt_resolution, i_patt_resolution); NyARIntSize s = i_raster.getSize(); INyARPerspectiveCopy pc = (INyARPerspectiveCopy)i_raster.createInterface(typeof(INyARPerspectiveCopy)); INyARRgbRaster tr = NyARRgbRaster.createInstance(i_patt_resolution, i_patt_resolution); pc.copyPatt(0, 0, s.w, 0, s.w, s.h, 0, s.h, i_patt_edge_percentage, i_patt_edge_percentage, 4, tr); c.setRaster(tr); return(this.addARMarker(c, i_patt_edge_percentage, i_marker_size)); }
/// <summary> /// {@link #addARMarker(INyARRgbRaster, int, int, double)}のラッパーです。Bitmapからマーカパターンを作ります。 /// 引数については、{@link #addARMarker(INyARRgbRaster, int, int, double)}を参照してください。 /// /// </summary> /// <param name="i_img"></param> /// <param name="i_patt_resolution">生成するマーカの解像度を指定します。</param> /// <param name="i_patt_edge_percentage">画像のエッジ領域を%で指定します。</param> /// <param name="i_marker_size">マーカの物理サイズを指定します。</param> /// <returns></returns> public int addARMarker(Texture2D i_img, int i_patt_resolution, int i_patt_edge_percentage, double i_marker_size) { int w = i_img.width; int h = i_img.height; NyARUnityRaster ur = new NyARUnityRaster(i_img); NyARCode c = new NyARCode(i_patt_resolution, i_patt_resolution); //ラスタからマーカパターンを切り出す INyARPerspectiveCopy pc = (INyARPerspectiveCopy)ur.createInterface(typeof(INyARPerspectiveCopy)); NyARRgbRaster tr = new NyARRgbRaster(i_patt_resolution, i_patt_resolution); pc.copyPatt(0, 0, w, 0, w, h, 0, h, i_patt_edge_percentage, i_patt_edge_percentage, 4, tr); //切り出したパターンをセット c.setRaster(tr); return(base.addARMarker(c, i_patt_edge_percentage, i_marker_size)); }
/** * [readonly]マーカにマッチした{@link NyARMatchPattDeviationColorData}インスタンスを得る。 * @ */ public NyARMatchPattDeviationColorData getDeviationColorData(MarkerInfoARMarker i_marker, INyARPerspectiveCopy i_pix_drv, NyARIntPoint2d[] i_vertex) { int mk_edge = i_marker.patt_edge_percentage; for (int i = this.items.Count - 1; i >= 0; i--) { Item ptr = this.items[i]; if (!ptr._patt.getSize().isEqualSize(i_marker.patt_w, i_marker.patt_h) || ptr._patt_edge != mk_edge) { //サイズとエッジサイズが合致しない物はスルー continue; } //古かったら更新 i_pix_drv.copyPatt(i_vertex, ptr._patt_edge, ptr._patt_edge, ptr._patt_resolution, ptr._patt); ptr._patt_d.setRaster(ptr._patt); return ptr._patt_d; } //無い。新しく生成 Item item = new Item(i_marker.patt_w, i_marker.patt_h, mk_edge); //タイムスタンプの更新とデータの生成 i_pix_drv.copyPatt(i_vertex, item._patt_edge, item._patt_edge, item._patt_resolution, item._patt); item._patt_d.setRaster(item._patt); this.items.Add(item); return item._patt_d; }
// // This reogion may be moved to NyARJ2seMarkerSystem. // /// <summary> /// {@link #addARMarker(INyARRgbRaster, int, int, double)}のラッパーです。Bitmapからマーカパターンを作ります。 /// 引数については、{@link #addARMarker(INyARRgbRaster, int, int, double)}を参照してください。 /// /// </summary> /// <param name="i_img"></param> /// <param name="i_patt_resolution">生成するマーカの解像度を指定します。</param> /// <param name="i_patt_edge_percentage">画像のエッジ領域を%で指定します。</param> /// <param name="i_marker_size">マーカの物理サイズを指定します。</param> /// <returns></returns> public int addARMarker(Bitmap i_img, int i_patt_resolution, int i_patt_edge_percentage, double i_marker_size) { int w = i_img.Width; int h = i_img.Height; using (NyARBitmapRaster bmr = new NyARBitmapRaster(i_img)) { NyARCode c = new NyARCode(i_patt_resolution, i_patt_resolution); //ラスタからマーカパターンを切り出す。 INyARPerspectiveCopy pc = (INyARPerspectiveCopy)bmr.createInterface(typeof(INyARPerspectiveCopy)); NyARRgbRaster tr = new NyARRgbRaster(i_patt_resolution, i_patt_resolution); pc.copyPatt(0, 0, w, 0, w, h, 0, h, i_patt_edge_percentage, i_patt_edge_percentage, 4, tr); //切り出したパターンをセット c.setRaster(tr); return(base.addARMarker(c, i_patt_edge_percentage, i_marker_size)); } }
/** * RealityTargetに最も一致するパターンをテーブルから検索して、メタデータを返します。 * @param i_target * Realityが検出したターゲット。 * Unknownターゲットを指定すること。 * @param i_rtsorce * i_targetを検出したRealitySourceインスタンス。 * @param o_result * 返却値を格納するインスタンスを設定します。 * 返却値がtrueの場合のみ、内容が更新されています。 * @return * 特定に成功すると、trueを返します。 * @throws NyARException */ public bool getBestMatchTarget(NyARRealityTarget i_target, NyARRealitySource i_rtsorce, GetBestMatchTargetResult o_result) { //パターン抽出 NyARMatchPattResult tmp_patt_result = this.__tmp_patt_result; INyARPerspectiveCopy r = i_rtsorce.refPerspectiveRasterReader(); r.copyPatt(i_target.refTargetVertex(), this._edge_x, this._edge_y, this._sample_per_pix, this._tmp_raster); //比較パターン生成 this._deviation_data.setRaster(this._tmp_raster); int ret = -1; int dir = -1; double cf = Double.MinValue; for (int i = this._table.getLength() - 1; i >= 0; i--) { this._match_patt.setARCode(this._table.getItem(i).code); this._match_patt.evaluate(this._deviation_data, tmp_patt_result); if (cf < tmp_patt_result.confidence) { ret = i; cf = tmp_patt_result.confidence; dir = tmp_patt_result.direction; } } if (ret < 0) { return(false); } //戻り値を設定 MarkerTable.SerialTableRow row = this._table.getItem(ret); o_result.artk_direction = dir; o_result.confidence = cf; o_result.idtag = row.idtag; o_result.marker_height = row.marker_height; o_result.marker_width = row.marker_width; o_result.name = row.name; return(true); }