示例#1
0
 /**
  * この関数は、マーカ平面上の任意の矩形で囲まれる領域から、画像を射影変換して返します。
  * {@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));
 }
 /// <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,
     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;
 }
示例#3
0
        /**
         * この関数は、マーカ平面上の任意の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));
        }
示例#4
0
 public void detectMarkerCb(NyARSensor i_sensor, int i_th, NyARSquareContourDetector.CbHandler i_handler)
 {
     this._sd.detectMarker(i_sensor.GetGsImage(), i_th, i_handler);
 }
示例#5
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 = _bin_threshold == THLESHOLD_AUTO?_hist_th.getThreshold(i_sensor.GetGsHistogram()) : _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);

            //検出結果の反映処理
            _tracking_list.finish();
            _armk_list.Finish();
            _idmk_list.Finish();
            _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 #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,
            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;
        }
示例#7
0
 public void detectMarkerCb(NyARSensor i_sensor, int i_th, NyARSquareContourDetector.CbHandler i_handler)
 {
     this._sd.detectMarker(i_sensor.GetGsImage(), i_th, i_handler);
 }
示例#8
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 = _bin_threshold == THLESHOLD_AUTO ? _hist_th.getThreshold(i_sensor.GetGsHistogram()) : _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);

              //検出結果の反映処理
              _tracking_list.finish();
              _armk_list.Finish();
              _idmk_list.Finish();
              _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;
        }
示例#9
0
 /**
  * この関数は、マーカ平面上の任意の矩形で囲まれる領域から、画像を射影変換して返します。
  * {@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);
 }
示例#10
0
 /**
  * この関数は、マーカ平面上の任意の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);
 }