Example #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;
        }
Example #2
0
        /**
         * NewTargetのステータスを更新します。
         * @param i_sample
         * @throws NyARException
         */
        public static void updateNewStatus(NyARTargetList i_list, NyARNewTargetStatusPool i_pool, LowResolutionLabelingSamplerOut.Item[] source, int[] index)
        {
            NyARTarget d_ptr;

            NyARTarget[] i_nes = i_list.getArray();
            //ターゲットの更新
            for (int i = i_list.getLength() - 1; i >= 0; i--)
            {
                d_ptr = i_nes[i];
                int sample_index = index[i];
                //年齢を加算
                d_ptr._status_life--;
                if (sample_index < 0)
                {
                    //このターゲットに合致するアイテムは無い。
                    ((NyARNewTargetStatus)d_ptr._ref_status).setValue(null);
                    d_ptr._delay_tick++;
                    continue;
                }
                LowResolutionLabelingSamplerOut.Item s = source[sample_index];
                //先にステータスを作成しておく
                NyARNewTargetStatus st = i_pool.newObject();
                if (st == null)
                {
                    //ステータスの生成に失敗
                    d_ptr._delay_tick++;
                    //System.out.println("updateNewStatus:status pool full");
                    continue;
                }
                //新しいステータス値のセット
                st.setValue(s);

                //ターゲットの更新
                d_ptr.setSampleArea(s);
                d_ptr._delay_tick = 0;

                //ref_statusのセットと切り替え(失敗時の上書き防止のためにダブルバッファ化)
                d_ptr._ref_status.releaseObject();
                d_ptr._ref_status = st;
            }
        }