/**
         * ContourTargetを表示します。
         */
        private void drawContourTarget(NyARTarget t, Graphics sink)
        {
            Font f = new Font("System", 14);

            sink.DrawString("CT", f, Brushes.Blue, new PointF(t._sample_area.x, t._sample_area.y));
            //		g.drawRect(t._sample_area.x,t._sample_area.y,t._sample_area.w,t._sample_area.h);
            NyARContourTargetStatus      st = (NyARContourTargetStatus)t._ref_status;
            VecLinearCoordinatesOperator vp = new VecLinearCoordinatesOperator();

            vp.margeResembleCoords(st.vecpos);
            for (int i2 = 0; i2 < st.vecpos.length; i2++)
            {
                //		for(int i2=43;i2<44;i2++){
                //			g.drawString(i2+":"+"-"+t._delay_tick,(int)st.vecpos.items[i2].x-1, (int)st.vecpos.items[i2].y-1);
                sink.FillRectangle(Brushes.Blue, (int)st.vecpos.items[i2].x, (int)st.vecpos.items[i2].y, 1, 1);
                double co, si;
                co = st.vecpos.items[i2].dx;
                si = st.vecpos.items[i2].dy;
                double p = Math.Sqrt(co * co + si * si);
                co /= p;
                si /= p;
                double ss = st.vecpos.items[i2].scalar * 3;
                sink.DrawLine(
                    Pens.Blue,
                    (int)st.vecpos.items[i2].x,
                    (int)st.vecpos.items[i2].y,
                    (int)(co * ss) + (int)st.vecpos.items[i2].x, (int)(si * ss) + (int)st.vecpos.items[i2].y);
                int xx = (int)st.vecpos.items[i2].x;
                int yy = (int)st.vecpos.items[i2].y;
                //			g.drawRect(xx/8*8,yy/8*8,16,16);
            }
        }
Ejemplo n.º 2
0
 /**
  * このターゲットのステータスを、CntoureStatusへ遷移させます。
  * @param i_c
  */
 private NyARTarget changeStatusToCntoure(NyARTarget i_target, NyARContourTargetStatus i_c)
 {
     //遷移元のステータスを制限
     Debug.Assert(i_c != null);
     Debug.Assert(i_target._st_type == NyARTargetStatus.ST_NEW);
     //個数制限
     if (this._number_of_contoure >= this.MAX_NUMBER_OF_CONTURE)
     {
         return(null);
     }
     i_target._st_type = NyARTargetStatus.ST_CONTURE;
     i_target._ref_status.releaseObject();
     i_target._status_life = LIFE_OF_CONTURE_FROM_NEW;
     i_target._ref_status  = i_c;
     //カウンタ更新
     this._number_of_new--;
     this._number_of_contoure++;
     return(i_target);
 }
Ejemplo n.º 3
0
        /**
         * i_new_targetのアップグレードを試行します。
         * アップグレードの種類は以下のにとおりです。1.一定期間経過後の破棄ルート(Ignoreへ遷移)2.正常認識ルート(Contourへ遷移)
         * @param i_new_target
         * @param i_base_raster
         * @return
         * @throws NyARException
         */
        private void upgradeNewTarget(NyARTarget i_new_target, INyARVectorReader i_vecreader)
        {
            Debug.Assert(i_new_target._st_type == NyARTargetStatus.ST_NEW);

            //寿命を超えたらignoreへ遷移
            if (i_new_target._status_life <= 0)
            {
                this.changeStatusToIgnore(i_new_target, LIFE_OF_IGNORE_FROM_NEW);
                return;
            }
            NyARNewTargetStatus st = (NyARNewTargetStatus)i_new_target._ref_status;

            //このターゲットをアップグレードできるか確認
            if (st.current_sampleout == null)
            {
                //直近のsampleoutが無い。->なにもできない。
                return;
            }
            //coordステータスを生成
            NyARContourTargetStatus c = this.contourst_pool.newObject();

            if (c == null)
            {
                //ターゲットがいっぱい。(失敗して何もしない)
//			    System.out.println("upgradeNewTarget:status pool full");
                return;
            }
            //ステータスの値をセット
            if (!c.setValue(i_vecreader, st.current_sampleout))
            {
                //値のセットに失敗したので、Ignoreへ遷移(この対象は輪郭認識できない)
                this.changeStatusToIgnore(i_new_target, LIFE_OF_IGNORE_FROM_NEW);
                //System.out.println("drop:new->ignore[contoure failed.]"+t.serial+":"+t.last_update);
                c.releaseObject();
                return;            //失敗しようが成功しようが終了
            }
            if (this.changeStatusToCntoure(i_new_target, c) == null)
            {
                c.releaseObject();
                return;
            }
            return;
        }
Ejemplo n.º 4
0
        /**
         * ContoureTargetのステータスを更新します。
         * @param i_list
         * @param i_vecreader
         * @param i_stpool
         * @param source
         * @param index
         * @throws NyARException
         */
        public static void updateContureStatus(NyARTargetList i_list, INyARVectorReader i_vecreader, NyARContourTargetStatusPool i_stpool, LowResolutionLabelingSamplerOut.Item[] source, int[] index)
        {
            NyARTarget[] crd = i_list.getArray();
            NyARTarget   d_ptr;

            //ターゲットの更新
            for (int i = i_list.getLength() - 1; i >= 0; i--)
            {
                d_ptr = crd[i];
                int sample_index = index[i];
                //年齢を加算
                d_ptr._status_life--;
                if (sample_index < 0)
                {
                    //このターゲットに合致するアイテムは無い。
                    d_ptr._delay_tick++;
                    continue;
                }
                LowResolutionLabelingSamplerOut.Item s = source[sample_index];
                //失敗の可能性を考慮して、Statusを先に生成しておく
                NyARContourTargetStatus st = i_stpool.newObject();
                if (st == null)
                {
                    //失敗(作れなかった?)
                    d_ptr._delay_tick++;
                    continue;
                }
                if (!st.setValue(i_vecreader, s))
                {
                    //新しいステータスのセットに失敗?
                    st.releaseObject();
                    d_ptr._delay_tick++;
                    continue;
                }
                d_ptr.setSampleArea(s);
                d_ptr._delay_tick = 0;
                //ref_statusの切り替え
                d_ptr._ref_status.releaseObject();
                d_ptr._ref_status = st;
            }
        }
Ejemplo n.º 5
0
        /**
         * NyARTrackerOutのCOntourTargetについて、アップグレード処理をします。
         * アップグレードの種類は以下のにとおりです。1.一定期間経過後の破棄ルート(Ignoreへ遷移)2.正常認識ルート(Rectへ遷移)
         * @param i_base_raster
         * @param i_trackdata
         * @throws NyARException
         */
        private void upgradeContourTarget(NyARTarget i_contoure_target)
        {
            Debug.Assert(i_contoure_target._st_type == NyARTargetStatus.ST_CONTURE);
            if (i_contoure_target._status_life <= 0)
            {
                //一定の期間が経過したら、ignoreへ遷移
                this.changeStatusToIgnore(i_contoure_target, LIFE_OF_IGNORE_FROM_CONTOUR);
                return;
            }
            if (i_contoure_target._delay_tick > 20)
            {
                this.changeStatusToIgnore(i_contoure_target, LIFE_OF_IGNORE_FROM_CONTOUR);
                return;
                //一定の期間updateができなければ、ignoreへ遷移
            }

            NyARContourTargetStatus st = (NyARContourTargetStatus)i_contoure_target._ref_status;
            //coordステータスを生成
            NyARRectTargetStatus c = this.rect_pool.newObject();

            if (c == null)
            {
                //ターゲットがいっぱい。
                return;
            }
            //ステータスの値をセット
            if (!c.setValueWithInitialCheck(st, i_contoure_target._sample_area))
            {
                //値のセットに失敗した。
                c.releaseObject();
                return;
            }
            if (this.changeStatusToRect(i_contoure_target, c) == null)
            {
                //ターゲットいっぱい?
                c.releaseObject();
                return;
            }
            return;
        }