コード例 #1
0
	    /**
	     * super classの機能に、予測位置からの探索を追加します。
	     */
	    public override int getMatchTargetIndex(LowResolutionLabelingSamplerOut.Item i_item)
	    {
		    //1段目:通常の検索
		    int ret=base.getMatchTargetIndex(i_item);
		    if(ret>=0){
			    return ret;
		    }
		    //2段目:予測位置から検索
		    NyARRectTargetStatus iitem;
		    int min_d=int.MaxValue;

		    //対角範囲の距離が、対角距離の1/2以下で、最も小さいこと。
		    for(int i=this._length-1;i>=0;i--)
		    {
			    iitem=(NyARRectTargetStatus)this._items[i]._ref_status;
			    int d;
			    d=i_item.base_area.sqDiagonalPointDiff(iitem.estimate_rect);	
			    if(d<min_d){
				    min_d=d;
				    ret=i;
			    }
		    }
		    //許容距離誤差の2乗を計算(対角線の20%以内)
		    //(Math.sqrt((i_item.area.w*i_item.area.w+i_item.area.h*i_item.area.h))/5)^2
		    if(min_d<(2*(i_item.base_area_sq_diagonal)/25)){
			    return ret;
		    }
		    return -1;
	    }
コード例 #2
0
	    /**
	     * 値をセットします。この関数は、処理の成功失敗に関わらず、内容変更を行います。
	     * @param i_src
	     * セットするLowResolutionLabelingSamplerOut.Itemを指定します。関数は、このアイテムの参照カウンタをインクリメントします。
	     * @throws NyARException
	     */
	    public void setValue(LowResolutionLabelingSamplerOut.Item i_src)
	    {
		    if(this.current_sampleout!=null){
			    this.current_sampleout.releaseObject();
		    }
		    if(i_src!=null){
                this.current_sampleout = (LowResolutionLabelingSamplerOut.Item)i_src.referenceObject();
		    }else{
			    this.current_sampleout=null;
		    }
	    }
コード例 #3
0
ファイル: NyARTracker.cs プロジェクト: thaisrezendeb/brincAR
 /**
  * ターゲットリストを参考に、sampleを振り分て、サンプルスタックに格納します。
  * ターゲットは、rect>coord>new>ignoreの順に優先して振り分けられます。
  * @param i_snapshot
  * @param i_source
  * @param i_new
  * @param i_ig
  * @param i_cood
  * @param i_rect
  * @param i_newsrc
  * @param i_igsrc
  * @param i_coodsrc
  * @param i_rectsrc
  * @throws NyARException
  */
 private void sampleMapper(
     LowResolutionLabelingSamplerOut i_source,
     NyARTargetList i_new, NyARTargetList i_ig, NyARTargetList i_cood, NyARTargetList i_rect,
     SampleStack i_newsrc, SampleStack i_igsrc, SampleStack i_coodsrc, SampleStack i_rectsrc)
 {
     //スタックを初期化
     i_newsrc.clear();
     i_coodsrc.clear();
     i_igsrc.clear();
     i_rectsrc.clear();
     //
     LowResolutionLabelingSamplerOut.Item[] sample_items = i_source.getArray();
     for (int i = i_source.getLength() - 1; i >= 0; i--)
     {
         //サンプラからの値を其々のターゲットのソースへ分配
         LowResolutionLabelingSamplerOut.Item sample_item = sample_items[i];
         int id;
         id = i_rect.getMatchTargetIndex(sample_item);
         if (id >= 0)
         {
             i_rectsrc.push(sample_item);
             continue;
         }
         //coord
         id = i_cood.getMatchTargetIndex(sample_item);
         if (id >= 0)
         {
             i_coodsrc.push(sample_item);
             continue;
         }
         //newtarget
         id = i_new.getMatchTargetIndex(sample_item);
         if (id >= 0)
         {
             i_newsrc.push(sample_item);
             continue;
         }
         //ignore target
         id = i_ig.getMatchTargetIndex(sample_item);
         if (id >= 0)
         {
             i_igsrc.push(sample_item);
             continue;
         }
         //マップできなかったものは、NewTragetへ登録(種類別のListには反映しない)
         NyARTarget t = this.addNewTarget(sample_item);
         if (t == null)
         {
             continue;
         }
         i_newsrc.push(sample_item);
     }
     return;
 }
コード例 #4
0
	    /**
	     * @param i_vecreader
	     * @param i_sample
	     * @return
	     * @throws NyARException
	     */
        public bool setValue(INyARVectorReader i_vecreader, LowResolutionLabelingSamplerOut.Item i_sample)
	    {
		    return i_vecreader.traceConture(i_sample.lebeling_th, i_sample.entry_pos, this.vecpos);
	    }	
コード例 #5
0
	/**
	 * i_inのデータをサンプリングして、o_outにサンプル値を作成します。
	 * この関数は、o_outにi_inのサンプリング結果を出力します。既にo_outにあるデータは初期化されます。
	 * @param i_in
	 * 入力元のデータです。
	 * @param i_th
	 * ラべリングの敷居値です。
	 * @param o_out
	 * 出力先のデータです。
	 * @throws NyARException
	 */
	public void sampling(NyARGrayscaleRaster i_in,int i_th,LowResolutionLabelingSamplerOut o_out)
	{
		//クラスのパラメータ初期化
		Main_Labeling lb=this._main_labeling;
		lb.current_output=o_out;
		lb.current_th=i_th;


		//パラメータの設定
		o_out.initializeParams();
		//ラべリング
		lb.setAreaRange(10000,3);
		lb.labeling(i_in,i_th);
	}
コード例 #6
0
ファイル: NyARTracker.cs プロジェクト: thaisrezendeb/brincAR
        /**
         * Trackerの状態を更新します。
         * @param i_source
         * @throws NyARException
         */
        public void progress(NyARTrackerSource i_s)
        {
            //SampleOutを回収
            LowResolutionLabelingSamplerOut sample_out = i_s.makeSampleOut();

            NyARTargetList[] targets = this._temp_targets;
            NyARTargetList   newtr   = targets[NyARTargetStatus.ST_NEW];
            NyARTargetList   igtr    = targets[NyARTargetStatus.ST_IGNORE];
            NyARTargetList   cotr    = targets[NyARTargetStatus.ST_CONTURE];
            NyARTargetList   retw    = targets[NyARTargetStatus.ST_RECT];

            INyARVectorReader vecreader = i_s.getBaseVectorReader();

            //ターゲットリストの振り分け
            NyARTarget[] target_array = this._targets.getArray();
            newtr.clear();
            igtr.clear();
            cotr.clear();
            retw.clear();
            for (int i = this._targets.getLength() - 1; i >= 0; i--)
            {
                targets[target_array[i]._st_type].pushAssert(target_array[i]);
            }
            int[] index = this._index;
            //サンプルをターゲット毎に振り分け
            sampleMapper(sample_out, newtr, igtr, cotr, retw, this._newsource, this._igsource, this._coordsource, this._rectsource);

            //ターゲットの更新
            this._map.makePairIndexes(this._igsource, igtr, index);
            updateIgnoreStatus(igtr, this._igsource.getArray(), index);

            this._map.makePairIndexes(this._newsource, newtr, index);
            updateNewStatus(newtr, this.newst_pool, this._newsource.getArray(), index);

            this._map.makePairIndexes(this._rectsource, retw, index);
            updateRectStatus(retw, vecreader, this.rect_pool, this._rectsource.getArray(), index);

            this._map.makePairIndexes(this._coordsource, cotr, index);
            updateContureStatus(cotr, vecreader, this.contourst_pool, this._coordsource.getArray(), index);

            //ターゲットのアップグレード
            for (int i = this._targets.getLength() - 1; i >= 0; i--)
            {
                switch (target_array[i]._st_type)
                {
                case NyARTargetStatus.ST_IGNORE:
                    upgradeIgnoreTarget(i);
                    continue;

                case NyARTargetStatus.ST_NEW:
                    upgradeNewTarget(target_array[i], vecreader);
                    continue;

                case NyARTargetStatus.ST_RECT:
                    upgradeRectTarget(target_array[i]);
                    continue;

                case NyARTargetStatus.ST_CONTURE:
                    upgradeContourTarget(target_array[i]);
                    continue;
                }
            }
            return;
        }
	    /**
	     * 状況に応じて矩形選択手法を切り替えます。
	     * @param i_vec_reader
	     * サンプリングデータの基本画像にリンクしたVectorReader
	     * @param i_source
	     * サンプリングデータ
	     * @param i_prev_status
	     * 前回の状態を格納したオブジェクト
	     * @return
	     * @throws NyARException
	     */
        public bool setValueByAutoSelect(INyARVectorReader i_vec_reader, LowResolutionLabelingSamplerOut.Item i_source, NyARRectTargetStatus i_prev_status)
	    {
		    int current_detect_type=DT_SQDAILY;
		    //移動速度による手段の切り替え
		    int sq_v_ave_limit=i_prev_status.estimate_sum_sq_vertex_velocity_ave/4;
		    //速度が小さい時か、前回LineLogが成功したときはDT_LIDAILY
		    if(((sq_v_ave_limit<10) && (i_prev_status.detect_type==DT_SQDAILY)) || (i_prev_status.detect_type==DT_LIDAILY)){
			    current_detect_type=DT_LIDAILY;
		    }
    		
		    //前回の動作ログによる手段の切り替え
		    switch(current_detect_type)
		    {
		    case DT_LIDAILY:
			    //LineLog->
			    if(setValueByLineLog(i_vec_reader,i_prev_status))
			    {
				    //うまくいった。
				    this.detect_type=DT_LIDAILY;
				    return true;
			    }
			    if(i_source!=null){
				    if(setValueWithDeilyCheck(i_vec_reader,i_source,i_prev_status))
				    {
					    //うまくいった
					    this.detect_type=DT_SQDAILY;
					    return true;
				    }
			    }
			    break;
		    case DT_SQDAILY:
			    if(i_source!=null){
				    if(setValueWithDeilyCheck(i_vec_reader,i_source,i_prev_status))
				    {
					    this.detect_type=DT_SQDAILY;
					    return true;
				    }
			    }
			    break;
		    default:
			    break;
		    }
		    //前回の動作ログを書き換え
		    i_prev_status.detect_type=DT_FAILED;
		    return false;
	    }
	    /**
	     * 値をセットします。この関数は、処理の成功失敗に関わらず、内容変更を行います。
	     * @param i_sampler_in
	     * @param i_source
	     * @param i_prev_status
	     * @return
	     * @throws NyARException
	     */
        public bool setValueWithDeilyCheck(INyARVectorReader i_vec_reader, LowResolutionLabelingSamplerOut.Item i_source, NyARRectTargetStatus i_prev_status)
	    {
		    VecLinearCoordinates vecpos=this._ref_my_pool._vecpos;
		    //輪郭線を取る
		    if(!i_vec_reader.traceConture(i_source.lebeling_th,i_source.entry_pos,vecpos)){
			    return false;
		    }
		    //3,4象限方向のベクトルは1,2象限のベクトルに変換する。
		    vecpos.limitQuadrantTo12();
		    //ベクトルのマージ
		    this._ref_my_pool._vecpos_op.margeResembleCoords(vecpos);
		    if(vecpos.length<4){
			    return false;
		    }
		    //キーベクトルを取得
		    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;
		    }
		    //頂点並び順の調整
		    rotateVertexL(this.vertex,checkVertexShiftValue(i_prev_status.vertex,this.vertex));	

		    //パラメタチェック
		    if(!checkDeilyRectCondition(i_prev_status)){
			    return false;
		    }
		    //次回の予測
		    setEstimateParam(i_prev_status);
		    return true;
	    }
コード例 #9
0
ファイル: NyARTarget.cs プロジェクト: whztt07/NyARToolkitCS
	    /**
	     * LowResolutionLabelingSamplerOut.Itemの値をを元に、sample_areaにRECTを設定します。
	     * @param i_item
	     * 設定する値です。
	     */
	    public void setSampleArea(LowResolutionLabelingSamplerOut.Item i_item)
	    {
		    this._sample_area.setValue(i_item.base_area);
	    }