Пример #1
0
        /**
         * 輪郭情報を元に矩形パラメータを推定し、値をセットします。
         * この関数は、処理の成功失敗に関わらず、内容変更を行います。
         * @param i_contour_status
         * 関数を実行すると、このオブジェクトの内容は破壊されます。
         * @return
         * @throws NyARException
         */
        public bool setValueWithInitialCheck(NyARContourTargetStatus i_contour_status, NyARIntRect i_sample_area)
        {
            //ベクトルのマージ(マージするときに、3,4象限方向のベクトルは1,2象限のベクトルに変換する。)
            i_contour_status.vecpos.limitQuadrantTo12();
            this._ref_my_pool._vecpos_op.margeResembleCoords(i_contour_status.vecpos);
            if (i_contour_status.vecpos.length < 4)
            {
                return(false);
            }

            //キーベクトルを取得
            i_contour_status.vecpos.getKeyCoord(this._ref_my_pool._indexbuf);
            //点に変換
            NyARDoublePoint2d[] this_vx = this.vertex;
            if (!this._ref_my_pool._line_detect.line2SquareVertex(this._ref_my_pool._indexbuf, this_vx))
            {
                return(false);
            }

            //		//点から直線を再計算
            //		for(int i=3;i>=0;i--){
            //			this_sq.line[i].makeLinearWithNormalize(this_sq.sqvertex[i],this_sq.sqvertex[(i+1)%4]);
            //		}
            this.setEstimateParam(null);
            if (!checkInitialRectCondition(i_sample_area))
            {
                return(false);
            }
            this.detect_type = DT_SQINIT;
            return(true);
        }
Пример #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);
 }
Пример #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;
        }
Пример #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;
            }
        }
Пример #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;
        }
	    /**
	     * 輪郭情報を元に矩形パラメータを推定し、値をセットします。
	     * この関数は、処理の成功失敗に関わらず、内容変更を行います。
	     * @param i_contour_status
	     * 関数を実行すると、このオブジェクトの内容は破壊されます。
	     * @return
	     * @throws NyARException
	     */
        public bool setValueWithInitialCheck(NyARContourTargetStatus i_contour_status, NyARIntRect i_sample_area)
	    {
		    //ベクトルのマージ(マージするときに、3,4象限方向のベクトルは1,2象限のベクトルに変換する。)
		    i_contour_status.vecpos.limitQuadrantTo12();
		    this._ref_my_pool._vecpos_op.margeResembleCoords(i_contour_status.vecpos);
		    if(i_contour_status.vecpos.length<4){
			    return false;
		    }
    		
		    //キーベクトルを取得
		    i_contour_status.vecpos.getKeyCoord(this._ref_my_pool._indexbuf);
		    //点に変換
		    NyARDoublePoint2d[] this_vx=this.vertex;
		    if(!this._ref_my_pool._line_detect.line2SquareVertex(this._ref_my_pool._indexbuf,this_vx)){
			    return false;
		    }
    		
    //		//点から直線を再計算
    //		for(int i=3;i>=0;i--){
    //			this_sq.line[i].makeLinearWithNormalize(this_sq.sqvertex[i],this_sq.sqvertex[(i+1)%4]);
    //		}
		    this.setEstimateParam(null);
		    if(!checkInitialRectCondition(i_sample_area))
		    {
			    return false;
		    }
		    this.detect_type=DT_SQINIT;
		    return true;
	    }