Exemplo n.º 1
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;
        }
Exemplo n.º 2
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;
            }
        }