示例#1
0
 /**
  * この関数は、入力画像を元に、インスタンスの状態を更新します。
  * この関数は、タイムスタンプをインクリメントします。
  * @param i_input
  * @
  */
 public virtual void update(INyARRgbRaster i_input)
 {
     //ラスタドライバの準備
     if (this._ref_raster != i_input)
     {
         this._rgb2gs     = (INyARRgb2GsFilter)i_input.createInterface(typeof(INyARRgb2GsFilter));
         this._pcopy      = (INyARPerspectiveCopy)i_input.createInterface(typeof(INyARPerspectiveCopy));
         this._ref_raster = i_input;
     }
     //ソースidのインクリメント
     this._src_ts++;
 }
示例#2
0
 /**
  * Based on the input image, this function updates the status of the instance.
  * This function increments the time stamp.
  * @param i_input
  * @
  */
 public virtual void update(INyARRgbRaster i_input)
 {
     //Preparation of raster driver
     if (this._ref_raster != i_input)
     {
         this._rgb2gs     = (INyARRgb2GsFilter)i_input.createInterface(typeof(INyARRgb2GsFilter));
         this._pcopy      = (INyARPerspectiveCopy)i_input.createInterface(typeof(INyARPerspectiveCopy));
         this._ref_raster = i_input;
     }
     //Increment of the source id
     this._src_ts++;
 }
示例#3
0
        /**
         * この関数は、画像から登録済のマーカ検出を行います。
         * マーカの検出に成功すると、thisのプロパティにマーカの二次元位置を記録します。
         * 関数の成功後は、マーカの姿勢行列と、一致度を、それぞれ{@link #getTransmationMatrix}と{@link #getConfidence}から得ることができます。
         * @param i_raster
         * マーカーを検出する画像。画像のサイズは、コンストラクタに指定した{@link NyARParam}オブジェクトと一致していなければなりません。
         * @param i_th
         * 2値化敷居値。0から256までの値を指定します。
         * @return
         * マーカーが検出できたかを、真偽値で返します。
         * @
         */
        public bool detectMarkerLite(INyARRgbRaster i_raster, int i_th)
        {
            NyARIntSize size1, size2;

            size1 = _bin_raster.getSize();
            size2 = i_raster.getSize();
            //System.Windows.Forms.MessageBox.Show("   bin: w " + size1.w.ToString() + " h " + size1.h.ToString() +
            //                                   "\nraster: w " + size2.w.ToString() + " h " + size2.h.ToString());
            //サイズチェック
            if (!this._bin_raster.getSize().isEqualSize(i_raster.getSize()))
            {
                throw new NyARException();
            }
            //最終入力ラスタを更新
            if (this._last_input_raster != i_raster)
            {
                this._bin_filter        = (INyARRgb2GsFilterArtkTh)i_raster.createInterface(typeof(INyARRgb2GsFilterArtkTh));
                this._last_input_raster = i_raster;
            }
            //ラスタを2値イメージに変換する.
            this._bin_filter.doFilter(i_th, this._bin_raster);

            //コールバックハンドラの準備
            this._confidence        = 0;
            this._last_input_raster = i_raster;
            //
            //マーカ検出器をコール
            this.execDetectMarker();
            if (this._confidence == 0)
            {
                return(false);
            }
            return(true);
        }
示例#4
0
        /**
         * この関数は、画像から登録済のマーカ検出を行います。
         * マーカの検出に成功すると、thisのプロパティにマーカの二次元位置を記録します。
         * 関数の成功後は、マーカの姿勢行列と、一致度を、それぞれ{@link #getTransmationMatrix}と{@link #getConfidence}から得ることができます。
         * @param i_raster
         * マーカーを検出する画像。画像のサイズは、コンストラクタに指定した{@link NyARParam}オブジェクトと一致していなければなりません。
         * @param i_th
         * 2値化敷居値。0から256までの値を指定します。
         * @return
         * マーカーが検出できたかを、真偽値で返します。
         * @
         */
        public bool detectMarkerLite(INyARRgbRaster i_raster, int i_th)
        {
            //サイズチェック
            if (!this._bin_raster.getSize().isEqualSize(i_raster.getSize()))
            {
                throw new NyARException();
            }

            //最終入力ラスタを更新
            if (this._last_input_raster != i_raster)
            {
                this._bin_filter        = (INyARRgb2GsFilterArtkTh)i_raster.createInterface(typeof(INyARRgb2GsFilterArtkTh));
                this._last_input_raster = i_raster;
            }

            //ラスタを2値イメージに変換する.
            this._bin_filter.doFilter(i_th, this._bin_raster);

            //コールバックハンドラの準備
            this._confidence        = 0;
            this._last_input_raster = i_raster;

            //
            //マーカ検出器をコール
            this.execDetectMarker();
            if (this._confidence == 0)
            {
                return(false);
            }
            return(true);
        }
示例#5
0
 /**
  * この関数は、ラスタのi_vertexsで定義される四角形からパターンを取得して、インスタンスに格納します。
  */
 public bool pickFromRaster(INyARRgbRaster image, NyARIntPoint2d[] i_vertexs)
 {
     if (this._last_input_raster != image)
     {
         this._raster_driver     = (INyARPerspectiveCopy)image.createInterface(typeof(INyARPerspectiveCopy));
         this._last_input_raster = image;
     }
     //遠近法のパラメータを計算
     return(this._raster_driver.copyPatt(i_vertexs, this._edge.x, this._edge.y, this._sample_per_pixel, this));
 }
示例#6
0
 /**
  * この関数は、ラスタから差分画像を生成して、インスタンスに格納します。
  * @param i_raster
  * 差分画像の元画像。サイズは、このインスタンスと同じである必要があります。
  * {@link NyARBufferType#INT1D_X8R8G8B8_32}形式のバッファを持つラスタの場合、他の形式よりも
  * 何倍か高速に動作します。
  */
 public void setRaster(INyARRgbRaster i_raster)
 {
     //ドライバの生成
     if (this._last_input_raster != i_raster)
     {
         this._last_drv          = (IRasterDriver)i_raster.createInterface(typeof(IRasterDriver));
         this._last_input_raster = i_raster;
     }
     this._pow = this._last_drv.makeColorData(this._data);
     return;
 }
示例#7
0
        public int addARMarker(INyARRgbRaster i_raster, int i_patt_resolution, int i_patt_edge_percentage,
                               double i_marker_size)
        {
            NyARCode             c  = new NyARCode(i_patt_resolution, i_patt_resolution);
            NyARIntSize          s  = i_raster.getSize();
            INyARPerspectiveCopy pc = (INyARPerspectiveCopy)i_raster.createInterface(typeof(INyARPerspectiveCopy));
            INyARRgbRaster       tr = NyARRgbRaster.createInstance(i_patt_resolution, i_patt_resolution);

            pc.copyPatt(0, 0, s.w, 0, s.w, s.h, 0, s.h, i_patt_edge_percentage, i_patt_edge_percentage, 4, tr);
            c.setRaster(tr);
            return(this.addARMarker(c, i_patt_edge_percentage, i_marker_size));
        }
示例#8
0
        static void Main(string[] args)
        {
            String img_file    = "../../../../../data/testcase/test.raw";
            String cparam_file = "../../../../../data/testcase/camera_para5.dat";
            String fset3file   = "../../../../../data/testcase/pinball.fset3";
            //カメラパラメータ
            NyARParam param = NyARParam.loadFromARParamFile(File.OpenRead(cparam_file), 640, 480, NyARParam.DISTFACTOR_LT_ARTK5);

            INyARGrayscaleRaster gs = NyARGrayscaleRaster.createInstance(640, 480);
            //試験画像の準備
            {
                INyARRgbRaster rgb = NyARRgbRaster.createInstance(640, 480, NyARBufferType.BYTE1D_B8G8R8X8_32);
                Stream         fs  = File.OpenRead(img_file);
                byte[]         b   = (byte[])rgb.getBuffer();
                fs.Read(b, 0, b.Length);
                INyARRgb2GsFilterRgbAve filter = (INyARRgb2GsFilterRgbAve)rgb.createInterface(typeof(INyARRgb2GsFilterRgbAve));
                filter.convert(gs);
            }
            NyARDoubleMatrix44   tmat = new NyARDoubleMatrix44();
            NyARNftFreakFsetFile f    = NyARNftFreakFsetFile.loadFromfset3File(File.OpenRead(fset3file));
//			KpmHandle kpm=new KpmHandle(new ARParamLT(param));
            Stopwatch             sw     = new Stopwatch();
            FreakKeypointMatching kpm    = new FreakKeypointMatching(param);
            KeyframeMap           keymap = new KeyframeMap(f, 0);

            for (int j = 0; j < 4; j++)
            {
                sw.Reset();
                sw.Start();
                for (int i = 0; i < 20; i++)
                {
                    kpm.updateInputImage(gs);
                    kpm.updateFeatureSet();
                    kpm.kpmMatching(keymap, tmat);
                }
                //FreakKeypointMatching#kMaxNumFeaturesを300にしてテストして。
                sw.Stop();
                System.Console.WriteLine("Total=" + (sw.ElapsedMilliseconds));
                NyARDoubleMatrix44 TEST_PATT = new NyARDoubleMatrix44(new double[] {
                    0.98436354107742652, 0.0066768917838370646, -0.17602226595996517, -191.17967199668533,
                    0.011597578022657571, -0.99956974712564306, 0.026940987645082352, 63.00280574839347,
                    -0.17576664981496215, -0.028561157958401542, -0.98401745160789567, 611.75871553558636,
                    0, 0, 0, 1
                });
                System.Console.WriteLine(TEST_PATT.Equals(tmat));
            }
        }
        /**
         * この関数は、画像からマーカを検出します。
         * 関数は、登録されているマーカパターンそれぞれに対し、検出したマーカから最も一致した物を探し、その一致率と位置を計算します。
         * @param i_raster
         * マーカーを検出するイメージを指定します。
         * @param i_threshold
         * 検出閾値を指定します。0~255の範囲で指定してください。 通常は100~130くらいを指定します。
         * @return
         * 検出したマーカーの数を返します。 マーカーが見つからない場合は0を返します。
         * @
         */
        public int detectMarkerLite(INyARRgbRaster i_raster, int i_threshold)
        {
            // サイズチェック
            if (!this._bin_raster.getSize().isEqualSize(i_raster.getSize()))
            {
                throw new NyARException();
            }
            if (this._last_input_raster != i_raster)
            {
                this._tobin_filter      = (INyARRgb2GsFilterArtkTh)i_raster.createInterface(typeof(INyARRgb2GsFilterArtkTh));
                this._last_input_raster = i_raster;
            }
            this._tobin_filter.doFilter(i_threshold, this._bin_raster);
            //detect
            this._square_detect.init(i_raster);
            this._square_detect.detectMarker(this._bin_raster, 0, this._square_detect);

            //見付かった数を返す。
            return(this._square_detect.result_stack.getLength());
        }
示例#10
0
        /**
         * この関数は、画像を処理して、適切なマーカ検出イベントハンドラを呼び出します。
         * イベントハンドラの呼び出しは、この関数を呼び出したスレッドが、この関数が終了するまでに行います。
         * @param i_raster
         * 検出処理をする画像を指定します。
         * @
         */
        public void DetectMarker(INyARRgbRaster i_raster)
        {
            // サイズチェック
            if (!this._gs_raster.getSize().isEqualSize(i_raster.getSize().w, i_raster.getSize().h))
            {
                throw new NyARException();
            }

            // ラスタをGSへ変換する。
            if (this._last_input_raster != i_raster)
            {
                this._togs_filter       = (INyARRgb2GsFilter)i_raster.createInterface(typeof(INyARRgb2GsFilter));
                this._last_input_raster = i_raster;
            }
            this._togs_filter.convert(this._gs_raster);

            // スクエアコードを探す(第二引数に指定したマーカ、もしくは新しいマーカを探す。)
            this._square_detect.init(this._gs_raster, this._is_active ? this._data_current : null);
            this._square_detect.detectMarker(this._gs_raster, this._current_threshold, this._square_detect);

            // 認識状態を更新(マーカを発見したなら、current_dataを渡すかんじ)
            bool is_id_found = UpdateStatus(this._square_detect.square, this._square_detect.marker_data);

            //閾値フィードバック(detectExistMarkerにもあるよ)
            if (is_id_found)
            {
                //マーカがあれば、マーカの周辺閾値を反映
                this._current_threshold = (this._current_threshold + this._square_detect.threshold) / 2;
            }
            else
            {
                //マーカがなければ、探索+DualPTailで基準輝度検索
                this._histmaker.createHistogram(4, this._hist);
                int th = this._threshold_detect.getThreshold(this._hist);
                this._current_threshold = (this._current_threshold + th) / 2;
            }
            return;
        }
示例#11
0
        /**
         * この関数は、画像を処理して、適切なマーカ検出イベントハンドラを呼び出します。
         * イベントハンドラの呼び出しは、この関数を呼び出したスレッドが、この関数が終了するまでに行います。
         * @param i_raster
         * 検出処理をする画像を指定します。
         * @
         */
        public void detectMarker(INyARRgbRaster i_raster)
        {
            // サイズチェック
            Debug.Assert(this._gs_raster.getSize().isEqualSize(i_raster.getSize().w, i_raster.getSize().h));
            if (this._last_input_raster != i_raster)
            {
                this._histmaker         = (INyARHistogramFromRaster)this._gs_raster.createInterface(typeof(INyARHistogramFromRaster));
                this._togs_filter       = (INyARRgb2GsFilter)i_raster.createInterface(typeof(INyARRgb2GsFilter));
                this._last_input_raster = i_raster;
            }

            //GSイメージへの変換とヒストグラムの生成
            this._togs_filter.convert(this._gs_raster);
            this._histmaker.createHistogram(4, this._hist);

            // スクエアコードを探す
            this._detectmarker.init(i_raster, this._current_arcode_index);
            this._detectmarker.detectMarker(this._gs_raster, this._thdetect.getThreshold(this._hist), this._detectmarker);

            // 認識状態を更新
            this.updateStatus(this._detectmarker.square, this._detectmarker.code_index);
            return;
        }
 /**
  * この関数は、ラスタのi_vertexsで定義される四角形からパターンを取得して、インスタンスに格納します。
  */
 public bool pickFromRaster(INyARRgbRaster image, NyARIntPoint2d[] i_vertexs)
 {
     if (this._last_input_raster != image)
     {
         this._raster_driver = (INyARPerspectiveCopy)image.createInterface(typeof(INyARPerspectiveCopy));
         this._last_input_raster = image;
     }
     //遠近法のパラメータを計算
     return this._raster_driver.copyPatt(i_vertexs, this._edge.x, this._edge.y, this._sample_per_pixel, this);
 }
        /**
         * この関数は、画像を処理して、適切なマーカ検出イベントハンドラを呼び出します。
         * イベントハンドラの呼び出しは、この関数を呼び出したスレッドが、この関数が終了するまでに行います。
         * @param i_raster
         * 検出処理をする画像を指定します。
         * @
         */
        public void detectMarker(INyARRgbRaster i_raster)
        {
            // サイズチェック
            Debug.Assert(this._gs_raster.getSize().isEqualSize(i_raster.getSize().w, i_raster.getSize().h));
            if (this._last_input_raster != i_raster)
            {
                this._histmaker = (INyARHistogramFromRaster)this._gs_raster.createInterface(typeof(INyARHistogramFromRaster));
                this._togs_filter = (INyARRgb2GsFilter)i_raster.createInterface(typeof(INyARRgb2GsFilter));
                this._last_input_raster = i_raster;
            }

            //GSイメージへの変換とヒストグラムの生成
            this._togs_filter.convert(this._gs_raster);
            this._histmaker.createHistogram(4, this._hist);

            // スクエアコードを探す
            this._detectmarker.init(i_raster, this._current_arcode_index);
            this._detectmarker.detectMarker(this._gs_raster, this._thdetect.getThreshold(this._hist),this._detectmarker);

            // 認識状態を更新
            this.updateStatus(this._detectmarker.square, this._detectmarker.code_index);
            return;
        }
示例#14
0
 /**
  * Based on the input image, this function updates the status of the instance.
  * This function increments the time stamp.
  * @param i_input
  * @
  */
 public virtual void update(INyARRgbRaster i_input)
 {
     //Preparation of raster driver
     if (this._ref_raster != i_input)
     {
         this._rgb2gs = (INyARRgb2GsFilter)i_input.createInterface(typeof(INyARRgb2GsFilter));
         this._pcopy = (INyARPerspectiveCopy)i_input.createInterface(typeof(INyARPerspectiveCopy));
         this._ref_raster = i_input;
     }
     //Increment of the source id
     this._src_ts++;
 }
        /**
         * この関数は、画像から登録済のマーカ検出を行います。
         * マーカの検出に成功すると、thisのプロパティにマーカの二次元位置を記録します。
         * 関数の成功後は、マーカの姿勢行列と、一致度を、それぞれ{@link #getTransmationMatrix}と{@link #getConfidence}から得ることができます。
         * @param i_raster
         * マーカーを検出する画像。画像のサイズは、コンストラクタに指定した{@link NyARParam}オブジェクトと一致していなければなりません。
         * @param i_th
         * 2値化敷居値。0から256までの値を指定します。
         * @return
         * マーカーが検出できたかを、真偽値で返します。
         * @
         */
        public bool detectMarkerLite(INyARRgbRaster i_raster, int i_th)
        {
            NyARIntSize size1, size2;
            size1 = _bin_raster.getSize();
            size2 = i_raster.getSize();
            //System.Windows.Forms.MessageBox.Show("   bin: w " + size1.w.ToString() + " h " + size1.h.ToString() +
            //                                   "\nraster: w " + size2.w.ToString() + " h " + size2.h.ToString());
            //サイズチェック
            if (!this._bin_raster.getSize().isEqualSize(i_raster.getSize()))
            {
                throw new NyARException();
            }
            //最終入力ラスタを更新
            if (this._last_input_raster != i_raster)
            {
                this._bin_filter = (INyARRgb2GsFilterArtkTh)i_raster.createInterface(typeof(INyARRgb2GsFilterArtkTh));
                this._last_input_raster = i_raster;
            }
            //ラスタを2値イメージに変換する.
            this._bin_filter.doFilter(i_th, this._bin_raster);

            //コールバックハンドラの準備
            this._confidence = 0;
            this._last_input_raster = i_raster;
            //
            //マーカ検出器をコール
            this.execDetectMarker();
            if (this._confidence == 0)
            {
                return false;
            }
            return true;
        }
示例#16
0
        static void Main(string[] args)
        {
            NyARDoubleMatrix44 DEST_MAT = new NyARDoubleMatrix44(
                new double[] {
                0.9832165682361184, 0.004789697223621061, -0.18237945710280384, -190.59060790299358,
                0.012860184615056927, -0.9989882709616935, 0.04309419210331572, 64.04490277502563,
                -0.18198852802987958, -0.044716355753573425, -0.9822833548209547, 616.6427596804766,
                0, 0, 0, 1
            });
            NyARDoubleMatrix44 SRC_MAT = new NyARDoubleMatrix44(new double[] {
                0.984363556, 0.00667689135, -0.176022261, -191.179672,
                0.0115975942, -0.999569774, 0.0269410834, 63.0028076,
                -0.175766647, -0.0285612550, -0.984017432, 611.758728,
                0, 0, 0, 1
            });

            String img_file = "../../../../../data/testcase/test.raw";
            String cparam   = "../../../../../data/testcase/camera_para5.dat";
            String fsetfile = "../../../../../data/testcase/pinball.fset";
            String isetfile = "../../../../../data/testcase/pinball.iset5";
            //カメラパラメータ
            NyARParam param = NyARParam.loadFromARParamFile(File.OpenRead(cparam), 640, 480, NyARParam.DISTFACTOR_LT_ARTK5);


            INyARGrayscaleRaster gs = NyARGrayscaleRaster.createInstance(640, 480);
            //試験画像の準備
            {
                INyARRgbRaster rgb = NyARRgbRaster.createInstance(640, 480, NyARBufferType.BYTE1D_B8G8R8X8_32);
                Stream         fs  = File.OpenRead(img_file);
                byte[]         b   = (byte[])rgb.getBuffer();
                fs.Read(b, 0, b.Length);
                INyARRgb2GsFilterRgbAve filter = (INyARRgb2GsFilterRgbAve)rgb.createInterface(typeof(INyARRgb2GsFilterRgbAve));
                filter.convert(gs);
            }

            NyARNftFsetFile    fset = NyARNftFsetFile.loadFromFsetFile(File.OpenRead(fsetfile));
            NyARNftIsetFile    iset = NyARNftIsetFile.loadFromIsetFile(File.OpenRead(isetfile));
            NyARSurfaceTracker st   = new NyARSurfaceTracker(param, 16, 0.5);
            NyARSurfaceDataSet sd   = new NyARSurfaceDataSet(iset, fset);
            NyARDoubleMatrix44 sret = new NyARDoubleMatrix44();

            NyARDoublePoint2d[] o_pos2d           = NyARDoublePoint2d.createArray(16);
            NyARDoublePoint3d[] o_pos3d           = NyARDoublePoint3d.createArray(16);
            NyARSurfaceTrackingTransmatUtils tmat = new NyARSurfaceTrackingTransmatUtils(param, 5.0);
            NyARDoubleMatrix44 tret = new NyARDoubleMatrix44();

            for (int j = 0; j < 10; j++)
            {
                Stopwatch s = new Stopwatch();
                s.Reset();
                s.Start();
                for (int i = 0; i < 3000; i++)
                {
                    sret.setValue(SRC_MAT);
                    int nop = st.tracking(gs, sd, sret, o_pos2d, o_pos3d, 16);
                    //Transmatの試験
                    NyARDoublePoint3d off = NyARSurfaceTrackingTransmatUtils.centerOffset(o_pos3d, nop, new NyARDoublePoint3d());
                    NyARSurfaceTrackingTransmatUtils.modifyInputOffset(sret, o_pos3d, nop, off);
                    tmat.surfaceTrackingTransmat(sret, o_pos2d, o_pos3d, nop, tret, new NyARTransMatResultParam());
                    NyARSurfaceTrackingTransmatUtils.restoreOutputOffset(tret, off);
                    System.Console.WriteLine(tret.Equals(DEST_MAT));
                }
                s.Stop();
                System.Console.WriteLine(s.ElapsedMilliseconds);
            }
            return;
        }
        /**
         * この関数は、画像から登録済のマーカ検出を行います。
         * マーカの検出に成功すると、thisのプロパティにマーカの二次元位置を記録します。
         * 関数の成功後は、マーカの姿勢行列と、一致度を、それぞれ{@link #getTransmationMatrix}と{@link #getConfidence}から得ることができます。
         * @param i_raster
         * マーカーを検出する画像。画像のサイズは、コンストラクタに指定した{@link NyARParam}オブジェクトと一致していなければなりません。
         * @param i_th
         * 2値化敷居値。0から256までの値を指定します。
         * @return
         * マーカーが検出できたかを、真偽値で返します。
         * @
         */
        public bool detectMarkerLite(INyARRgbRaster i_raster, int i_th)
        {
            //サイズチェック
              if (!this._bin_raster.getSize().isEqualSize(i_raster.getSize())) { throw new NyARException(); }

              //最終入力ラスタを更新
              if (this._last_input_raster != i_raster) {
            this._bin_filter = (INyARRgb2GsFilterArtkTh)i_raster.createInterface(typeof(INyARRgb2GsFilterArtkTh));
            this._last_input_raster = i_raster;
              }

              //ラスタを2値イメージに変換する.
              this._bin_filter.doFilter(i_th, this._bin_raster);

              //コールバックハンドラの準備
              this._confidence = 0;
              this._last_input_raster = i_raster;

              //
              //マーカ検出器をコール
              this.execDetectMarker();
              if (this._confidence == 0) { return false; }
              return true;
        }
        /**
         * この関数は、画像を処理して、適切なマーカ検出イベントハンドラを呼び出します。
         * イベントハンドラの呼び出しは、この関数を呼び出したスレッドが、この関数が終了するまでに行います。
         * @param i_raster
         * 検出処理をする画像を指定します。
         * @
         */
        public void detectMarker(INyARRgbRaster i_raster)
        {
            // サイズチェック
            if (!this._gs_raster.getSize().isEqualSize(i_raster.getSize().w, i_raster.getSize().h))
            {
                throw new NyARException();
            }
            // ラスタをGSへ変換する。
            if (this._last_input_raster != i_raster)
            {
                this._togs_filter = (INyARRgb2GsFilter)i_raster.createInterface(typeof(INyARRgb2GsFilter));
                this._last_input_raster = i_raster;
            }
            this._togs_filter.convert(this._gs_raster);

            // スクエアコードを探す(第二引数に指定したマーカ、もしくは新しいマーカを探す。)
            this._square_detect.init(this._gs_raster, this._is_active ? this._data_current : null);
            this._square_detect.detectMarker(this._gs_raster, this._current_threshold, this._square_detect);

            // 認識状態を更新(マーカを発見したなら、current_dataを渡すかんじ)
            bool is_id_found = updateStatus(this._square_detect.square, this._square_detect.marker_data);

            //閾値フィードバック(detectExistMarkerにもあるよ)
            if (is_id_found)
            {
                //マーカがあれば、マーカの周辺閾値を反映
                this._current_threshold = (this._current_threshold + this._square_detect.threshold) / 2;
            }
            else
            {
                //マーカがなければ、探索+DualPTailで基準輝度検索
                this._histmaker.createHistogram(4, this._hist);
                int th = this._threshold_detect.getThreshold(this._hist);
                this._current_threshold = (this._current_threshold + th) / 2;
            }
            return;
        }
示例#19
0
 /**
  * この関数は、入力画像を元に、インスタンスの状態を更新します。
  * この関数は、タイムスタンプをインクリメントします。
  * @param i_input
  * @
  */
 public virtual void update(INyARRgbRaster i_input)
 {
     //ラスタドライバの準備
     if (this._ref_raster != i_input)
     {
         this._rgb2gs = (INyARRgb2GsFilter)i_input.createInterface(typeof(INyARRgb2GsFilter));
         this._pcopy = (INyARPerspectiveCopy)i_input.createInterface(typeof(INyARPerspectiveCopy));
         this._ref_raster = i_input;
     }
     //ソースidのインクリメント
     this._src_ts++;
 }
	/**
	 * この関数は、画像からARマーカパターンを生成して、登録します。
	 * ビットマップ等の画像から生成したパターンは、撮影画像から生成したパターンファイルと比較して、撮影画像の色調変化に弱くなります。
	 * 注意してください。
	 * @param i_raster
	 * マーカ画像を格納したラスタオブジェクト
	 * @param i_patt_resolution
	 * マーカの解像度
	 * @param i_patt_edge_percentage
	 * マーカのエッジ領域のサイズ。マーカパターンは、i_rasterからエッジ領域を除いたパターンから生成します。
	 * ARToolKitスタイルの画像を用いる場合は、25を指定します。
	 * @param i_marker_size
	 * マーカの平方サイズ[mm]
	 * @return
	 * マーカID(ハンドル)値。
	 * @throws NyARException
	 */
	public int addARMarker(INyARRgbRaster i_raster,int i_patt_resolution,int i_patt_edge_percentage,double i_marker_size)
	{
		NyARCode c=new NyARCode(i_patt_resolution,i_patt_resolution);
		NyARIntSize s=i_raster.getSize();
		//ラスタからマーカパターンを切り出す。
		INyARPerspectiveCopy pc=(INyARPerspectiveCopy)i_raster.createInterface(typeof(INyARPerspectiveCopy));
		NyARRgbRaster tr=new NyARRgbRaster(i_patt_resolution,i_patt_resolution);
		pc.copyPatt(0,0,s.w,0,s.w,s.h,0,s.h,i_patt_edge_percentage, i_patt_edge_percentage,4, tr);
		//切り出したパターンをセット
		c.setRaster(tr);
		return this.addARMarker(c,i_patt_edge_percentage,i_marker_size);
	}
 /**
  * この関数は、ラスタから差分画像を生成して、インスタンスに格納します。
  * @param i_raster
  * 差分画像の元画像。サイズは、このインスタンスと同じである必要があります。
  * {@link NyARBufferType#INT1D_X8R8G8B8_32}形式のバッファを持つラスタの場合、他の形式よりも
  * 何倍か高速に動作します。
  */
 public void setRaster(INyARRgbRaster i_raster)
 {
     //ドライバの生成
     if (this._last_input_raster != i_raster)
     {
         this._last_drv = (IRasterDriver)i_raster.createInterface(typeof(IRasterDriver));
         this._last_input_raster = i_raster;
     }
     this._pow = this._last_drv.makeColorData(this._data);
     return;
 }