/**
         * この関数は、入力したセンサ入力値から、インスタンスの状態を更新します。
         * 関数は、センサオブジェクトから画像を取得して、マーカ検出、一致判定、トラッキング処理を実行します。
         * @param i_sensor
         * {@link MarkerSystem}に入力する画像を含むセンサオブジェクト。
         * @throws NyARException
         */
        public void update(NyARSensor i_sensor)
        {
            long time_stamp = i_sensor.getTimeStamp();

            //センサのタイムスタンプが変化していなければ何もしない。
            if (this._time_stamp == time_stamp)
            {
                return;
            }
            int th = this._bin_threshold == THLESHOLD_AUTO?this._hist_th.getThreshold(i_sensor.getGsHistogram()) : this._bin_threshold;

            this._sq_stack.clear();    //矩形情報の保持スタック初期化
            //解析
            this._tracking_list.prepare();
            this._idmk_list.prepare();
            this._armk_list.prepare();
            //検出処理
            this._on_sq_handler._ref_input_rfb = i_sensor.getPerspectiveCopy();
            this._on_sq_handler._ref_input_gs  = i_sensor.getGsImage();
            //検出
            this._sqdetect.detectMarkerCb(i_sensor, th, this._on_sq_handler);

            //検出結果の反映処理
            this._tracking_list.finish();
            this._armk_list.finish();
            this._idmk_list.finish();
            //期限切れチェック
            for (int i = this._tracking_list.Count - 1; i >= 0; i--)
            {
                TMarkerData item = this._tracking_list[i];
                if (item.lost_count > this.lost_th)
                {
                    item.life = 0;          //活性off
                }
            }
            //各ターゲットの更新
            for (int i = this._armk_list.Count - 1; i >= 0; i--)
            {
                MarkerInfoARMarker target = this._armk_list[i];
                if (target.lost_count == 0)
                {
                    target.time_stamp = time_stamp;
                    this._transmat.transMatContinue(target.sq, target.marker_offset, target.tmat, target.tmat);
                }
            }
            for (int i = this._idmk_list.Count - 1; i >= 0; i--)
            {
                MarkerInfoNyId target = this._idmk_list[i];
                if (target.lost_count == 0)
                {
                    target.time_stamp = time_stamp;
                    this._transmat.transMatContinue(target.sq, target.marker_offset, target.tmat, target.tmat);
                }
            }
            //解析/
            //タイムスタンプを更新
            this._time_stamp = time_stamp;
            this._last_gs_th = th;
        }
 /**
  * この関数は、マーカ平面上の任意の矩形で囲まれる領域から、画像を射影変換して返します。
  * {@link #isExistMarker(int)}がtrueの時にだけ使用できます。
  * @param i_id
  * マーカID(ハンドル)値。
  * @param i_sensor
  * 画像を取得するセンサオブジェクト。通常は{@link #update(NyARSensor)}関数に入力したものと同じものを指定します。
  * @param i_l
  * 矩形の左上点です。
  * @param i_t
  * 矩形の左上点です。
  * @param i_w
  * 矩形の幅です。
  * @param i_h
  * 矩形の幅です。
  * @param i_raster
  * 出力先のオブジェクト
  * @return
  * 結果を格納したi_rasterオブジェクト
  * @throws NyARException
  */
 public INyARRgbRaster getMarkerPlaneImage(
     int i_id,
     NyARSensor i_sensor,
     double i_l, double i_t,
     double i_w, double i_h,
     INyARRgbRaster i_raster)
 {
     return(this.getMarkerPlaneImage(i_id, i_sensor, i_l + i_w - 1, i_t + i_h - 1, i_l, i_t + i_h - 1, i_l, i_t, i_l + i_w - 1, i_t, i_raster));
 }
Ejemplo n.º 3
0
        public INyARRgbRaster getPlaneImage(int i_id, NyARSensor i_sensor, double i_x1, double i_y1, double i_x2,
                                            double i_y2, double i_x3, double i_y3, double i_x4, double i_y4, INyARRgbRaster i_raster)
        {
            NyARDoublePoint3d[] pos  = this.__pos3d;
            NyARDoublePoint2d[] pos2 = this.__pos2d;
            NyARDoubleMatrix44  tmat = this.getTransformMatrix(i_id);

            tmat.transform3d(i_x1, i_y1, 0, pos[1]);
            tmat.transform3d(i_x2, i_y2, 0, pos[0]);
            tmat.transform3d(i_x3, i_y3, 0, pos[3]);
            tmat.transform3d(i_x4, i_y4, 0, pos[2]);
            for (int i = 3; i >= 0; i--)
            {
                this._view.getFrustum().project(pos[i], pos2[i]);
            }
            return(i_sensor.getPerspectiveImage(pos2[0].x, pos2[0].y, pos2[1].x, pos2[1].y, pos2[2].x, pos2[2].y,
                                                pos2[3].x, pos2[3].y, i_raster));
        }
Ejemplo n.º 4
0
 public override void setup(CaptureDevice i_cap)
 {
     Device d3d = this.size(SCREEN_WIDTH, SCREEN_HEIGHT);
     INyARMarkerSystemConfig cf = new NyARMarkerSystemConfig(SCREEN_WIDTH, SCREEN_HEIGHT);
     d3d.RenderState.ZBufferEnable = true;
     d3d.RenderState.Lighting = false;
     d3d.RenderState.CullMode = Cull.CounterClockwise;
     this._ms = new NyARD3dMarkerSystem(cf);
     this._ss = new NyARSensor(cf.getScreenSize());
     this._rs = new NyARD3dRender(d3d, this._ms);
     this.mid = this._ms.addARMarker(AR_CODE_FILE, 16, 25, 80);
     //set View mmatrix
     this._rs.loadARViewMatrix(d3d);
     //set Viewport matrix
     this._rs.loadARViewPort(d3d);
     //setD3dProjectionMatrix
     this._rs.loadARProjectionMatrix(d3d);
     this._ss.update( new NyARBitmapRaster(new Bitmap(TEST_IMAGE)));
 }
Ejemplo n.º 5
0
 public INyARRgbRaster getMarkerPlaneImage(int i_id, NyARSensor i_sensor, double i_x1, double i_y1, double i_x2,
                                           double i_y2, double i_x3, double i_y3, double i_x4, double i_y4, INyARRgbRaster i_raster)
 {
     return(this.getPlaneImage(i_id, i_sensor, i_x1, i_y1, i_x2, i_y2, i_x3, i_y3, i_x4, i_y4, i_raster));
 }
Ejemplo n.º 6
0
 /**
  * この関数は、{@link #getMarkerPlaneImage(int, NyARSensor, int, int, int, int, INyARRgbRaster)}
  * のラッパーです。取得画像を{@link #BufferedImage}形式で返します。
  * @param i_id
  * マーカid
  * @param i_sensor
  * 画像を取得するセンサオブジェクト。通常は{@link #update(NyARSensor)}関数に入力したものと同じものを指定します。
  * @param i_l
  * @param i_t
  * @param i_w
  * @param i_h
  * @param i_raster
  * 出力先のオブジェクト
  * @return
  * 結果を格納したi_rasterオブジェクト
  * @throws NyARException
  */
 public void getMarkerPlaneImage(
     int i_id,
     NyARSensor i_sensor,
     int i_l, int i_t,
     int i_w, int i_h,
     Bitmap i_img)
 {
     using (NyARBitmapRaster bmr = new NyARBitmapRaster(i_img))
     {
         base.getMarkerPlaneImage(i_id, i_sensor, i_l, i_t, i_w, i_h, bmr);
         this.getMarkerPlaneImage(i_id, i_sensor, i_l + i_w - 1, i_t + i_h - 1, i_l, i_t + i_h - 1, i_l, i_t, i_l + i_w - 1, i_t, bmr);
         return;
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// この関数は、{@link #getMarkerPlaneImage(int, NyARSensor, int, int, int, int, int, int, int, int, INyARRgbRaster)}
        /// のラッパーです。取得画像を{@link #BufferedImage}形式で返します。
        /// </summary>
        /// <param name="i_id"></param>
        /// <param name="i_sensor"></param>
        /// <param name="i_x1"></param>
        /// <param name="i_y1"></param>
        /// <param name="i_x2"></param>
        /// <param name="i_y2"></param>
        /// <param name="i_x3"></param>
        /// <param name="i_y3"></param>
        /// <param name="i_x4"></param>
        /// <param name="i_y4"></param>
        /// <param name="i_img"></param>
        /// <returns></returns>

        public void getMarkerPlaneImage(
            int i_id,
            NyARSensor i_sensor,
            int i_x1, int i_y1,
            int i_x2, int i_y2,
            int i_x3, int i_y3,
            int i_x4, int i_y4,
            Bitmap i_img)
        {
            using (NyARBitmapRaster bmr = new NyARBitmapRaster(i_img))
            {
                base.getMarkerPlaneImage(i_id, i_sensor, i_x1, i_y1, i_x2, i_y2, i_x3, i_y3, i_x4, i_y4, bmr);
                return;
            }
        }
	/**
	 * この関数は、マーカ平面上の任意の4点で囲まれる領域から、画像を射影変換して返します。
	 * {@link #isExistMarker(int)}がtrueの時にだけ使用できます。
	 * @param i_id
	 * マーカID(ハンドル)値。
	 * @param i_sensor
	 * 画像を取得するセンサオブジェクト。通常は{@link #update(NyARSensor)}関数に入力したものと同じものを指定します。
	 * @param i_x1
	 * 頂点1[mm]
	 * @param i_y1
	 * 頂点1[mm]
	 * @param i_x2
	 * 頂点2[mm]
	 * @param i_y2
	 * 頂点2[mm]
	 * @param i_x3
	 * 頂点3[mm]
	 * @param i_y3
	 * 頂点3[mm]
	 * @param i_x4
	 * 頂点4[mm]
	 * @param i_y4
	 * 頂点4[mm]
	 * @param i_raster
	 * 取得した画像を格納するオブジェクト
	 * @return
	 * 結果を格納したi_rasterオブジェクト
	 * @throws NyARException
	 */
	public INyARRgbRaster getMarkerPlaneImage(
		int i_id,
		NyARSensor i_sensor,
		double i_x1,double i_y1,
		double i_x2,double i_y2,
		double i_x3,double i_y3,
		double i_x4,double i_y4,
	    INyARRgbRaster i_raster)
	{
		NyARDoublePoint3d[] pos  = this.__pos3d;
		NyARDoublePoint2d[] pos2 = this.__pos2d;
		NyARDoubleMatrix44 tmat=this.getMarkerMatrix(i_id);
		tmat.transform3d(i_x1, i_y1,0,	pos[1]);
		tmat.transform3d(i_x2, i_y2,0,	pos[0]);
		tmat.transform3d(i_x3, i_y3,0,	pos[3]);
		tmat.transform3d(i_x4, i_y4,0,	pos[2]);
		for(int i=3;i>=0;i--){
			this._frustum.project(pos[i],pos2[i]);
		}
		return i_sensor.getPerspectiveImage(pos2[0].x, pos2[0].y,pos2[1].x, pos2[1].y,pos2[2].x, pos2[2].y,pos2[3].x, pos2[3].y,i_raster);
	}
 /** <summary>
 * This function is{@link #getMarkerPlaneImage(int, NyARSensor, int, int, int, int, int, int, int, int, INyARRgbRaster)}
 * It is a wrapper. The acquired image{@link #BufferedImage}I returned in the form.
 * </summary>
 * <param name="i_id"></param>
 * <param name="i_sensor"></param>
 * <param name="i_x1"></param>
 * <param name="i_y1"></param>
 * <param name="i_x2"></param>
 * <param name="i_y2"></param>
 * <param name="i_x3"></param>
 * <param name="i_y3"></param>
 * <param name="i_x4"></param>
 * <param name="i_y4"></param>
 * <param name="i_img"></param>
 * <returns></returns>
 **/
 public void getMarkerPlaneImage(int i_id, NyARSensor i_sensor, int i_x1, int i_y1, int i_x2, int i_y2, int i_x3, int i_y3, int i_x4, int i_y4, Texture2D i_img)
 {
     NyARUnityRaster bmr = new NyARUnityRaster(i_img);
     base.getMarkerPlaneImage(i_id, i_sensor, i_x1, i_y1, i_x2, i_y2, i_x3, i_y3, i_x4, i_y4, bmr);
     return;
 }
        /**
         * This function is{@link #getMarkerPlaneImage(int, NyARSensor, int, int, int, int, INyARRgbRaster)}
         * It is a wrapper. The acquired image{@link #BufferedImage}I returned in the form.
         * @param i_id
         * marker id
         * @param i_sensor
         * Object to retrieve the image sensor. Is usually{@link #update(NyARSensor)}I will be the same as it was entered into the function.
         * @param i_l
         * @param i_t
         * @param i_w
         * @param i_h
         * @param i_raster
         * Object where the output
         * @return
         * I have to store the result i_raster Object
         * @throws NyARException
         */
        public void getMarkerPlaneImage(int i_id, NyARSensor i_sensor, int i_l, int i_t, int i_w, int i_h, Texture2D i_img)
        {
            NyARUnityRaster bmr = new NyARUnityRaster(i_img.width,i_img.height,true);
            base.getMarkerPlaneImage(i_id, i_sensor, i_l, i_t, i_w, i_h, bmr);
            i_img.SetPixels32((Color32[])bmr.getBuffer());
            i_img.Apply();

            return;
        }
Ejemplo n.º 11
0
        /**
         * この関数は、入力したセンサ入力値から、インスタンスの状態を更新します。
         * 関数は、センサオブジェクトから画像を取得して、マーカ検出、一致判定、トラッキング処理を実行します。
         * @param i_sensor
         * {@link MarkerSystem}に入力する画像を含むセンサオブジェクト。
         * @throws NyARException
         */
        public void update(NyARSensor i_sensor)
        {
            long time_stamp = i_sensor.getTimeStamp();

            //センサのタイムスタンプが変化していなければ何もしない。
            if (this._time_stamp == time_stamp)
            {
                return;
            }
            int th = this._bin_threshold == THLESHOLD_AUTO?this._hist_th.getThreshold(i_sensor.getGsHistogram()) : this._bin_threshold;

            //解析
            this._tracking_list.prepare();
            this._idmk_list.prepare();
            this._armk_list.prepare();
            this._psmk_list.prepare();
            //検出
            this._on_sq_handler.prepare(i_sensor.getPerspectiveCopy(), i_sensor.getGsImage(), th);
            this._sqdetect.detectMarkerCb(i_sensor, th, this._on_sq_handler);

            //検出結果の反映処理
            this._tracking_list.finish();
            this._armk_list.finish();
            this._idmk_list.finish();
            this._psmk_list.finish();
            //期限切れチェック
            for (int i = this._tracking_list.Count - 1; i >= 0; i--)
            {
                TMarkerData item = this._tracking_list[i];
                if (item.lost_count > this.lost_th)
                {
                    //連続で検出できなかった場合
                    item.life = 0;//活性off
                }
                else if (item.sq != null)
                {
                    //直前のsqを検出できた場合
                    if (!this._transmat.transMatContinue(item.sq, item.marker_offset, item.tmat, item.last_param.last_error, item.tmat, item.last_param))
                    {
                        if (!this._transmat.transMat(item.sq, item.marker_offset, item.tmat, item.last_param))
                        {
                            item.life = 0;//活性off
                        }
                    }
                }
            }
            //各ターゲットの更新
            for (int i = this._armk_list.Count - 1; i >= 0; i--)
            {
                TMarkerData target = this._armk_list[i];
                if (target.lost_count == 0)
                {
                    target.time_stamp = time_stamp;
                    //lifeが1(開始時検出のときのみ)
                    if (target.life != 1)
                    {
                        continue;
                    }
                    this._transmat.transMat(target.sq, target.marker_offset, target.tmat, target.last_param);
                }
            }
            for (int i = this._idmk_list.Count - 1; i >= 0; i--)
            {
                TMarkerData target = this._idmk_list[i];
                if (target.lost_count == 0)
                {
                    target.time_stamp = time_stamp;
                    //lifeが1(開始時検出のときのみ)
                    if (target.life != 1)
                    {
                        continue;
                    }
                    this._transmat.transMat(target.sq, target.marker_offset, target.tmat, target.last_param);
                }
            }
            for (int i = this._psmk_list.Count - 1; i >= 0; i--)
            {
                TMarkerData target = this._psmk_list[i];
                if (target.lost_count == 0)
                {
                    target.time_stamp = time_stamp;
                    //lifeが1(開始時検出のときのみ)
                    if (target.life != 1)
                    {
                        continue;
                    }
                    this._transmat.transMat(target.sq, target.marker_offset, target.tmat, target.last_param);
                }
            }
            //解析/
            //タイムスタンプを更新
            this._time_stamp = time_stamp;
            this._last_gs_th = th;
        }
	public void detectMarkerCb(NyARSensor i_sensor,int i_th,NyARSquareContourDetector.CbHandler i_handler)
	{
		this._sd.detectMarker(i_sensor.getGsImage(), i_th,i_handler);
	}
	/**
	 * この関数は、入力したセンサ入力値から、インスタンスの状態を更新します。
	 * 関数は、センサオブジェクトから画像を取得して、マーカ検出、一致判定、トラッキング処理を実行します。
	 * @param i_sensor
	 * {@link MarkerSystem}に入力する画像を含むセンサオブジェクト。
	 * @throws NyARException 
	 */
	public void update(NyARSensor i_sensor)
	{
		long time_stamp=i_sensor.getTimeStamp();
		//センサのタイムスタンプが変化していなければ何もしない。
		if(this._time_stamp==time_stamp){
			return;
		}
		int th=this._bin_threshold==THLESHOLD_AUTO?this._hist_th.getThreshold(i_sensor.getGsHistogram()):this._bin_threshold;
		//解析
		this._tracking_list.prepare();
		this._idmk_list.prepare();
		this._armk_list.prepare();
        this._psmk_list.prepare();
		//検出
        this._on_sq_handler.prepare(i_sensor.getPerspectiveCopy(), i_sensor.getGsImage(), th);
        this._sqdetect.detectMarkerCb(i_sensor, th, this._on_sq_handler);

		//検出結果の反映処理
		this._tracking_list.finish();
		this._armk_list.finish();
		this._idmk_list.finish();
        this._psmk_list.finish();
		//期限切れチェック
        for (int i = this._tracking_list.Count - 1; i >= 0; i--)
        {
			TMarkerData item=this._tracking_list[i];
			if(item.lost_count>this.lost_th){
                //連続で検出できなかった場合
                item.life = 0;//活性off
            }
            else if (item.sq != null)
            {
                //直前のsqを検出できた場合
                if (!this._transmat.transMatContinue(item.sq, item.marker_offset, item.tmat, item.last_param.last_error, item.tmat, item.last_param))
                {
                    if (!this._transmat.transMat(item.sq, item.marker_offset, item.tmat, item.last_param))
                    {
                        item.life = 0;//活性off
                    }
                }
            }
		}
		//各ターゲットの更新
		for(int i=this._armk_list.Count-1;i>=0;i--){
			TMarkerData target=this._armk_list[i];
			if(target.lost_count==0){
				target.time_stamp=time_stamp;
                //lifeが1(開始時検出のときのみ)
                if (target.life != 1)
                {
                    continue;
                }
                this._transmat.transMat(target.sq, target.marker_offset, target.tmat, target.last_param);
			}
		}
		for(int i=this._idmk_list.Count-1;i>=0;i--){
			TMarkerData target=this._idmk_list[i];
			if(target.lost_count==0){
				target.time_stamp=time_stamp;
                //lifeが1(開始時検出のときのみ)
                if (target.life != 1)
                {
                    continue;
                }
                this._transmat.transMat(target.sq, target.marker_offset, target.tmat, target.last_param);
            }
		}
        for (int i = this._psmk_list.Count - 1; i >= 0; i--)
        {
			TMarkerData target=this._psmk_list[i];
			if(target.lost_count==0){
				target.time_stamp=time_stamp;
                //lifeが1(開始時検出のときのみ)
                if (target.life != 1)
                {
                    continue;
                }
                this._transmat.transMat(target.sq, target.marker_offset, target.tmat, target.last_param);
            }
		}
		//解析/
		//タイムスタンプを更新
		this._time_stamp=time_stamp;
		this._last_gs_th=th;
	}
	/**
	 * この関数は、マーカ平面上の任意の矩形で囲まれる領域から、画像を射影変換して返します。
	 * {@link #isExistMarker(int)}がtrueの時にだけ使用できます。
	 * @param i_id
	 * マーカID(ハンドル)値。
	 * @param i_sensor
	 * 画像を取得するセンサオブジェクト。通常は{@link #update(NyARSensor)}関数に入力したものと同じものを指定します。
	 * @param i_l
	 * 矩形の左上点です。
	 * @param i_t
	 * 矩形の左上点です。
	 * @param i_w
	 * 矩形の幅です。
	 * @param i_h
	 * 矩形の幅です。
	 * @param i_raster
	 * 出力先のオブジェクト
	 * @return
	 * 結果を格納したi_rasterオブジェクト
	 * @throws NyARException
	 */
	public INyARRgbRaster getMarkerPlaneImage(
		int i_id,
		NyARSensor i_sensor,
	    double i_l,double i_t,
	    double i_w,double i_h,
	    INyARRgbRaster i_raster)
    {
		return this.getMarkerPlaneImage(i_id,i_sensor,i_l+i_w-1,i_t+i_h-1,i_l,i_t+i_h-1,i_l,i_t,i_l+i_w-1,i_t,i_raster);
    }
Ejemplo n.º 15
0
        public void update(NyARSensor i_sensor)
        {
            long time_stamp = i_sensor.getTimeStamp();

            if (this._time_stamp == time_stamp)
            {
                return;
            }
            int th = this._bin_threshold == THLESHOLD_AUTO
                ? this._hist_th.getThreshold(i_sensor.getGsHistogram())
                : this._bin_threshold;

            if (this.ThresholdValue != -1)
            {
                th = this.ThresholdValue;
            }

            //解析
            this._tracking_list.prepare();
            this._idmk_list.prepare();
            this._armk_list.prepare();
            this._psmk_list.prepare();
            //検出
            this._on_sq_handler.prepare(i_sensor.getPerspectiveCopy(), i_sensor.getGsImage(), th);
            this._sqdetect.detectMarkerCb(i_sensor, th, this._on_sq_handler);

            //検出結果の反映処理
            this._tracking_list.finish();
            this._armk_list.finish();
            this._idmk_list.finish();
            this._psmk_list.finish();

            for (int i = this._tracking_list.Count - 1; i >= 0; i--)
            {
                TMarkerData item = this._tracking_list[i];
                if (item.lost_count > this.lost_th)
                {
                    item.life = 0;
                }
                else if (item.sq != null)
                {
                    if (
                        !this._transmat.transMatContinue(item.sq, item.marker_offset, item.tmat,
                                                         item.last_param.last_error, item.tmat, item.last_param))
                    {
                        if (!this._transmat.transMat(item.sq, item.marker_offset, item.tmat, item.last_param))
                        {
                            item.life = 0;
                        }
                    }
                }
            }
            for (int i = this._armk_list.Count - 1; i >= 0; i--)
            {
                TMarkerData target = this._armk_list[i];
                if (target.lost_count == 0)
                {
                    target.time_stamp = time_stamp;
                    if (target.life != 1)
                    {
                        continue;
                    }
                    this._transmat.transMat(target.sq, target.marker_offset, target.tmat, target.last_param);
                }
            }
            for (int i = this._idmk_list.Count - 1; i >= 0; i--)
            {
                TMarkerData target = this._idmk_list[i];
                if (target.lost_count == 0)
                {
                    target.time_stamp = time_stamp;
                    if (target.life != 1)
                    {
                        continue;
                    }
                    this._transmat.transMat(target.sq, target.marker_offset, target.tmat, target.last_param);
                }
            }
            for (int i = this._psmk_list.Count - 1; i >= 0; i--)
            {
                TMarkerData target = this._psmk_list[i];
                if (target.lost_count == 0)
                {
                    target.time_stamp = time_stamp;
                    if (target.life != 1)
                    {
                        continue;
                    }
                    this._transmat.transMat(target.sq, target.marker_offset, target.tmat, target.last_param);
                }
            }
            this._time_stamp = time_stamp;
            this._last_gs_th = th;
        }
        /**
         * この関数は、入力した画像でインスタンスの状態を更新します。
         * 関数は、入力画像を処理して検出、一致判定、トラッキング処理を実行します。
         * @param i_sensor
         * 画像を含むセンサオブジェクト
         */
        public void update(NyARSensor i_sensor)
        {
            long time_stamp = i_sensor.getTimeStamp();

            //センサのタイムスタンプが変化していなければ何もしない。
            if (this._last_time_stamp == time_stamp)
            {
                return;
            }
            //タイムスタンプの更新
            this._last_time_stamp = time_stamp;

            //ステータス遷移


            NyARDoublePoint2d[]  pos2d = this._pos2d;
            NyARDoublePoint3d[]  pos3d = this._pos3d;
            INyARGrayscaleRaster gs    = i_sensor.getGsImage();

            //KPMスレッドによる更新()
            this._kpm_worker.updateInputImage(gs);

            //SurfaceTrackingによるfrontデータの更新

            foreach (NftTarget target in this._nftdatalist)
            {
                if (target.stage < NftTarget.ST_KPM_FOUND)
                {
                    //System.out.println("NOTHING");
                    //KPM検出前なら何もしない。
                    continue;
                }
                switch (target.stage)
                {
                case NftTarget.ST_AR2_TRACKING:
                    //NftTarget.ST_AR2_TRACKING以降
                    //front_transmatに作る。
                    NyARSurfaceTracker st = this._surface_tracker;
                    int nop = st.tracking(gs, target.dataset.surface_dataset, target.front_transmat, this._pos2d, pos3d, 16);
                    if (nop == 0)
                    {
                        //失敗
                        target.stage = NftTarget.ST_KPM_SEARCH;
                        //System.out.println("ST_KPM_SEARCH");
                        continue;
                    }
                    //Transmatの試験
                    NyARDoublePoint3d off = NyARSurfaceTrackingTransmatUtils.centerOffset(pos3d, nop, new NyARDoublePoint3d());
                    NyARSurfaceTrackingTransmatUtils.modifyInputOffset(target.front_transmat, pos3d, nop, off);    //ARTK5の補正
                    if (!this._sftrackingutils.surfaceTrackingTransmat(target.front_transmat, pos2d, pos3d, nop, target.front_transmat, this.result_param))
                    {
                        //失敗
                        target.stage = NftTarget.ST_KPM_SEARCH;
                        //System.out.println("ST_KPM_SEARCH");
                        continue;
                    }
                    NyARSurfaceTrackingTransmatUtils.restoreOutputOffset(target.front_transmat, off);    //ARTK5の補正
                    break;

                case NftTarget.ST_KPM_FOUND:
                    target.stage = NftTarget.ST_AR2_TRACKING;
                    //System.out.println("ST_AR2_TRACKING");
                    break;
                }
            }
        }
Ejemplo n.º 17
0
 public void detectMarkerCb(NyARSensor i_sensor, int i_th, NyARSquareContourDetector.CbHandler i_handler)
 {
     this._sd.detectMarker(i_sensor.getGsImage(), i_th, i_handler);
 }
        /**
         * この関数は、入力したセンサ入力値から、インスタンスの状態を更新します。
         * 関数は、センサオブジェクトから画像を取得して、マーカ検出、一致判定、トラッキング処理を実行します。
         * @param i_sensor
         * {@link MarkerSystem}に入力する画像を含むセンサオブジェクト。
         * @throws NyARException
         */
        public void update(NyARSensor i_sensor)
        {
            long time_stamp=i_sensor.getTimeStamp();
            //センサのタイムスタンプが変化していなければ何もしない。
            if(this._time_stamp==time_stamp){
            return;
            }
            int th=this._bin_threshold==THLESHOLD_AUTO?this._hist_th.getThreshold(i_sensor.getGsHistogram()):this._bin_threshold;
            this._sq_stack.clear();//矩形情報の保持スタック初期化
            //解析
            this._tracking_list.prepare();
            this._idmk_list.prepare();
            this._armk_list.prepare();
            //検出処理
            this._on_sq_handler._ref_input_rfb=i_sensor.getPerspectiveCopy();
            this._on_sq_handler._ref_input_gs=i_sensor.getGsImage();
            //検出
            this._sqdetect.detectMarkerCb(i_sensor,th,this._on_sq_handler);

            //検出結果の反映処理
            this._tracking_list.finish();
            this._armk_list.finish();
            this._idmk_list.finish();
            //期限切れチェック
            for (int i = this._tracking_list.Count - 1; i >= 0; i--)
            {
            TMarkerData item=this._tracking_list[i];
            if(item.lost_count>this.lost_th){
                item.life=0;//活性off
            }
            }
            //各ターゲットの更新
            for(int i=this._armk_list.Count-1;i>=0;i--){
            MarkerInfoARMarker target=this._armk_list[i];
            if(target.lost_count==0){
                target.time_stamp=time_stamp;
                this._transmat.transMatContinue(target.sq,target.marker_offset,target.tmat,target.tmat);
            }
            }
            for(int i=this._idmk_list.Count-1;i>=0;i--){
            MarkerInfoNyId target=this._idmk_list[i];
            if(target.lost_count==0){
                target.time_stamp=time_stamp;
                this._transmat.transMatContinue(target.sq,target.marker_offset,target.tmat,target.tmat);
            }
            }
            //解析/
            //タイムスタンプを更新
            this._time_stamp=time_stamp;
            this._last_gs_th=th;
        }