Ejemplo n.º 1
0
 public void prepare(INyARPerspectiveCopy i_pcopy, INyARGrayscaleRaster i_gs, int th)
 {
     this._ref_input_rfb = i_pcopy;
     this._ref_input_gs  = i_gs;
     this._ref_th        = th;
     this._sq_stack.clear();
 }
Ejemplo n.º 2
0
 /**
  * この関数は、ラスタのi_vertexsで定義される四角形からパターンを取得して、インスタンスに格納します。
  */
 public bool pickFromRaster(INyARRgbRaster image, NyARIntPoint2d[] i_vertexs)
 {
     if (this._last_input_raster != image)
     {
         this._raster_driver     = (INyARPerspectiveCopy)image.createInterface(typeof(INyARPerspectiveCopy));
         this._last_input_raster = image;
     }
     //遠近法のパラメータを計算
     return(this._raster_driver.copyPatt(i_vertexs, this._edge.x, this._edge.y, this._sample_per_pixel, this));
 }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
 /**
  * この関数は、入力画像を元に、インスタンスの状態を更新します。
  * この関数は、タイムスタンプをインクリメントします。
  * @param i_input
  * @
  */
 public virtual void update(INyARRgbRaster i_input)
 {
     //ラスタドライバの準備
     if (this._ref_raster != i_input)
     {
         this._rgb2gs     = (INyARRgb2GsFilter)i_input.createInterface(typeof(INyARRgb2GsFilter));
         this._pcopy      = (INyARPerspectiveCopy)i_input.createInterface(typeof(INyARPerspectiveCopy));
         this._ref_raster = i_input;
     }
     //ソースidのインクリメント
     this._src_ts++;
 }
Ejemplo n.º 5
0
 /**
  * Based on the input image, this function updates the status of the instance.
  * This function increments the time stamp.
  * @param i_input
  * @
  */
 public virtual void update(INyARRgbRaster i_input)
 {
     //Preparation of raster driver
     if (this._ref_raster != i_input)
     {
         this._rgb2gs     = (INyARRgb2GsFilter)i_input.createInterface(typeof(INyARRgb2GsFilter));
         this._pcopy      = (INyARPerspectiveCopy)i_input.createInterface(typeof(INyARPerspectiveCopy));
         this._ref_raster = i_input;
     }
     //Increment of the source id
     this._src_ts++;
 }
        /// <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));
        }
Ejemplo n.º 7
0
        //
        // 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));
            }
        }
Ejemplo n.º 8
0
        /**
         * o_targetsに、敷居値を越えたターゲットリストを返却する。
         * @param i_pix_drv
         * @param i_vertex
         * @param o_targets
         * @return
         * @
         */
        public bool Update(INyARPerspectiveCopy i_pix_drv, SquareStack.Item i_sq)
        {
            //sq_tmpに値を生成したかのフラグ
            bool is_ganalated_sq = false;

            for (int i = this.Count - 1; i >= 0; i--)
            {
                ARMarkerList.Item target = this[i];
                //解像度に一致する画像を取得
                NyARMatchPattDeviationColorData diff = this._mpickup.getDeviationColorData(target, i_pix_drv, i_sq.ob_vertex);

                //マーカのパターン解像度に一致したサンプリング画像と比較する。
                if (!target.matchpatt.evaluate(diff, this._patt_result))
                {
                    continue;
                }

                //敷居値をチェック
                if (this._patt_result.confidence < this._configense_th)
                {
                    continue;
                }

                //マーカマップへの追加対象か調べる。
                ARMarkerSortList.Item ip = this._mkmap.getInsertPoint(this._patt_result.confidence);
                if (ip == null)
                {
                    continue;
                }

                //マーカマップアイテムの矩形に参照値を設定する。
                ip              = this._mkmap.insertFromTailBefore(ip);
                ip.cf           = this._patt_result.confidence;
                ip.dir          = this._patt_result.direction;
                ip.marker       = target;
                ip.ref_sq       = i_sq;
                is_ganalated_sq = true;
            }
            return(is_ganalated_sq);
        }
Ejemplo n.º 9
0
        /**
         * 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);
        }
 /**
  * [readonly]マーカにマッチした{@link NyARMatchPattDeviationColorData}インスタンスを得る。
  * @ 
  */
 public NyARMatchPattDeviationColorData getDeviationColorData(ARMarkerList.Item 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;
 }
        /**
         * [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);
        }
Ejemplo n.º 12
0
 /**
  * この関数は、入力画像を元に、インスタンスの状態を更新します。
  * この関数は、タイムスタンプをインクリメントします。
  * @param i_input
  * @
  */
 public virtual void update(INyARRgbRaster i_input)
 {
     //ラスタドライバの準備
     if (this._ref_raster != i_input)
     {
         this._rgb2gs = (INyARRgb2GsFilter)i_input.createInterface(typeof(INyARRgb2GsFilter));
         this._pcopy = (INyARPerspectiveCopy)i_input.createInterface(typeof(INyARPerspectiveCopy));
         this._ref_raster = i_input;
     }
     //ソースidのインクリメント
     this._src_ts++;
 }
 /**
  * この関数は、ラスタのi_vertexsで定義される四角形からパターンを取得して、インスタンスに格納します。
  */
 public bool pickFromRaster(INyARRgbRaster image, NyARIntPoint2d[] i_vertexs)
 {
     if (this._last_input_raster != image)
     {
         this._raster_driver = (INyARPerspectiveCopy)image.createInterface(typeof(INyARPerspectiveCopy));
         this._last_input_raster = image;
     }
     //遠近法のパラメータを計算
     return this._raster_driver.copyPatt(i_vertexs, this._edge.x, this._edge.y, this._sample_per_pixel, this);
 }
	/**
	 * {@link #detectMarkerCallback}コール前に1度だけ呼び出してください。
	 * @param i_max_detect_marker
	 * @param i_pcopy
	 * @param i_gs
	 * @param th
	 * @throws NyARException
	 */
	public void prepare(INyARPerspectiveCopy i_pcopy, INyARGrayscaleRaster i_gs, int th)
	{
		this._ref_input_rfb=i_pcopy;
		this._ref_input_gs=i_gs;
		this._ref_th=th;
		// initialize square stack
		this._sq_stack.clear();		
	}
Ejemplo n.º 15
0
 /**
  * Based on the input image, this function updates the status of the instance.
  * This function increments the time stamp.
  * @param i_input
  * @
  */
 public virtual void update(INyARRgbRaster i_input)
 {
     //Preparation of raster driver
     if (this._ref_raster != i_input)
     {
         this._rgb2gs = (INyARRgb2GsFilter)i_input.createInterface(typeof(INyARRgb2GsFilter));
         this._pcopy = (INyARPerspectiveCopy)i_input.createInterface(typeof(INyARPerspectiveCopy));
         this._ref_raster = i_input;
     }
     //Increment of the source id
     this._src_ts++;
 }