コード例 #1
0
        /**
         * コンストラクタです。
         * @param i_max_new
         * Newトラックターゲットの最大数を指定します。
         * @param i_max_cont
         * Contourトラックターゲットの最大数を指定します。
         * @param i_max_rect
         * Rectトラックターゲットの最大数を指定します。
         * @throws NyARException
         */
        public NyARTracker(int i_max_new, int i_max_cont, int i_max_rect)
        {
            //環境定数の設定
            this.MAX_NUMBER_OF_NEW     = i_max_new;
            this.MAX_NUMBER_OF_CONTURE = i_max_cont;
            this.MAX_NUMBER_OF_RECT    = i_max_rect;
            this.MAX_NUMBER_OF_TARGET  = (i_max_new + i_max_cont + i_max_rect) * 5;


            //ターゲットマップ用の配列と、リスト。この関数はNyARTargetStatusのIDと絡んでるので、気をつけて!
            this._temp_targets = new NyARTargetList[NyARTargetStatus.MAX_OF_ST_KIND + 1];
            this._temp_targets[NyARTargetStatus.ST_NEW]     = new NyARTargetList(i_max_new);
            this._temp_targets[NyARTargetStatus.ST_IGNORE]  = new NyARTargetList(this.MAX_NUMBER_OF_TARGET);
            this._temp_targets[NyARTargetStatus.ST_CONTURE] = new NyARTargetList(i_max_cont);
            this._temp_targets[NyARTargetStatus.ST_RECT]    = new NyARRectTargetList(i_max_rect);

            //ソースリスト
            this._newsource   = new SampleStack(i_max_new);
            this._igsource    = new SampleStack(this.MAX_NUMBER_OF_TARGET);
            this._coordsource = new SampleStack(i_max_cont);
            this._rectsource  = new SampleStack(i_max_rect);

            //ステータスプール
            this.newst_pool     = new NyARNewTargetStatusPool(i_max_new * 2);
            this.contourst_pool = new NyARContourTargetStatusPool(i_max_rect + i_max_cont * 2);
            this.rect_pool      = new NyARRectTargetStatusPool(i_max_rect * 2);
            //ターゲットプール
            this.target_pool = new NyARTargetPool(this.MAX_NUMBER_OF_TARGET);
            //ターゲット
            this._targets = new NyARTargetList(this.MAX_NUMBER_OF_TARGET);

            //ここ注意!マップの最大値は、ソースアイテムの個数よりおおきいこと!
            this._map   = new DistMap(this.MAX_NUMBER_OF_TARGET, this.MAX_NUMBER_OF_TARGET);
            this._index = new int[this.MAX_NUMBER_OF_TARGET];

            //定数初期化
            this._number_of_new = this._number_of_ignore = this._number_of_contoure = this._number_of_rect = 0;
        }
コード例 #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;
            }
        }