コード例 #1
0
        /**
         * ImputStreamからARToolKit形式のマーカデータを読み込み、o_codeオブジェクトへ格納します。
         * @param i_stream
         * 読出し元のストリームです。
         * @param o_code
         * 出力先の{@link NyARCode}オブジェクトです。
         * @
         */
        public static void loadFromARToolKitFormFile(StreamReader i_stream, NyARCode o_code)
        {
            int           width      = o_code.getWidth();
            int           height     = o_code.getHeight();
            NyARRgbRaster tmp_raster = new NyARRgbRaster(width, height, NyARBufferType.INT1D_X8R8G8B8_32);

            //4個の要素をラスタにセットする。
            try
            {
                int[]    buf  = (int[])tmp_raster.getBuffer();
                string[] data = i_stream.ReadToEnd().Split(new Char[] { ' ', '\r', '\n' });
                //GBRAで一度読みだす。
                int idx = 0;
                for (int h = 0; h < 4; h++)
                {
                    idx = readBlock(data, idx, width, height, buf);
                    //ARCodeにセット(カラー)
                    o_code.getColorData(h).setRaster(tmp_raster);
                    o_code.getBlackWhiteData(h).setRaster(tmp_raster);
                }
            }
            catch (Exception e)
            {
                throw new NyARException(e);
            }
            tmp_raster = null;//ポイ
            return;
        }
コード例 #2
0
 /**
  * コンストラクタ。
  * 基準パターンを元に、評価インスタンスを生成します。
  * @param i_code_ref
  * セットする基準パターン
  */
 public NyARMatchPatt_BlackWhite(NyARCode i_code_ref)
 {
     //最適化定数の計算
     this._pixels = i_code_ref.getWidth() * i_code_ref.getHeight();
     //基準パターンをセット
     this._ref_code_patt = i_code_ref;
     return;
 }
コード例 #3
0
 /**
  * コンストラクタ。
  * 基準パターンを元に、評価インスタンスを生成します。
  * @param i_code_ref
  * セットする基準パターン
  */
 public NyARMatchPatt_BlackWhite(NyARCode i_code_ref)
 {
     //最適化定数の計算
     this._pixels = i_code_ref.getWidth() * i_code_ref.getHeight();
     //基準パターンをセット
     this._ref_code_patt = i_code_ref;
     return;
 }
コード例 #4
0
        /**
         * inputStreamからARToolKit形式のパターンデータを指定サイズで読み出して、格納したインスタンスを生成します。
         * ロードするパターンデータの縦横解像度は、このインスタンスの値と同じである必要があります。
         * @param i_stream
         * 読出し元のStreamオブジェクト
         * @param i_width
         * パターンの幅pixel数。データの内容と一致している必要があります。
         * @param i_height
         * パターンの幅pixel数。データの内容と一致している必要があります。
         * @throws NyARException
         */
        public static NyARCode createFromARPattFile(StreamReader i_stream, int i_width, int i_height)
        {
            //ラスタにパターンをロードする。
            NyARCode ret = new NyARCode(i_width, i_height);

            NyARCodeFileReader.loadFromARToolKitFormFile(i_stream, ret);
            return(ret);
        }
コード例 #5
0
 /**
  * コンストラクタ。
  * 基準パターンを元に、インスタンスを生成します。
  * @param i_code_ref
  * セットする基準パターンの参照値
  */
 public NyARMatchPatt_Color_WITHOUT_PCA(NyARCode i_code_ref)
 {
     int w = i_code_ref.getWidth();
     int h = i_code_ref.getHeight();
     //最適化定数の計算
     this._rgbpixels = w * h * 3;
     this._optimize_for_mod = this._rgbpixels - (this._rgbpixels % 16);
     this.setARCode(i_code_ref);
     return;
 }
コード例 #6
0
 /** */
 public MarkerInfoARMarker(NyARCode i_patt, int i_patt_edge_percentage, double i_patt_size)
     : base()
 {
     this.matchpatt = new NyARMatchPatt_Color_WITHOUT_PCA(i_patt);
     this.patt_edge_percentage = i_patt_edge_percentage;
     this.marker_offset.setSquare(i_patt_size);
     this.patt_w = i_patt.getWidth();
     this.patt_h = i_patt.getHeight();
     return;
 }
コード例 #7
0
        /**
         * コンストラクタ。
         * 基準パターンを元に、インスタンスを生成します。
         * @param i_code_ref
         * セットする基準パターンの参照値
         */
        public NyARMatchPatt_Color_WITHOUT_PCA(NyARCode i_code_ref)
        {
            int w = i_code_ref.getWidth();
            int h = i_code_ref.getHeight();

            //最適化定数の計算
            this._rgbpixels        = w * h * 3;
            this._optimize_for_mod = this._rgbpixels - (this._rgbpixels % 16);
            this.setARCode(i_code_ref);
            return;
        }
コード例 #8
0
        /// <summary>
        /// {@link #addARMarker(INyARRgbRaster, int, int, double)}のラッパーです。Bitmapからマーカパターンを作ります。
        /// 引数については、{@link #addARMarker(INyARRgbRaster, int, int, double)}を参照してください。
        /// 
        /// </summary>
        /// <param name="i_img"></param>
        /// <param name="i_patt_resolution">生成するマーカの解像度を指定します。</param>
        /// <param name="i_patt_edge_percentage">画像のエッジ領域を%で指定します。</param>
        /// <param name="i_marker_size">マーカの物理サイズを指定します。</param>
        /// <returns></returns>
        public int addARMarker(Texture2D i_img, int i_patt_resolution, int i_patt_edge_percentage, double i_marker_size)
        {
            int w = i_img.width;
              int h = i_img.height;
              NyARUnityRaster ur = new NyARUnityRaster(i_img);
              NyARCode c = new NyARCode(i_patt_resolution, i_patt_resolution);

              //ラスタからマーカパターンを切り出す
              INyARPerspectiveCopy pc = (INyARPerspectiveCopy)ur.createInterface(typeof(INyARPerspectiveCopy));
              NyARRgbRaster tr = new NyARRgbRaster(i_patt_resolution, i_patt_resolution);
              pc.copyPatt(0, 0, w, 0, w, h, 0, h, i_patt_edge_percentage, i_patt_edge_percentage, 4, tr);

              //切り出したパターンをセット
              c.setRaster(tr);
              return base.addARMarker(c, i_patt_edge_percentage, i_marker_size);
        }
コード例 #9
0
 public NyARSingleDetectMarker_NyARTK_FITTING_ARTKv2(NyARParam i_ref_param, NyARCode i_ref_code, double i_marker_width)
     : base(i_ref_param, i_ref_code, i_marker_width)
 {
     this._inst_patt = new NyARColorPatt_Perspective(i_ref_code.getWidth(), i_ref_code.getHeight(), 4, 25);
       this._transmat = new NyARTransMat_ARToolKit(i_ref_param);
       this._square_detect = new NyARSingleDetectMarker_ARTKv2.ARTKDetector(this, i_ref_param.getScreenSize());
 }
コード例 #10
0
 public static NyARSingleDetectMarker createInstance(NyARParam i_param, NyARCode i_code, double i_marker_width)
 {
     return createInstance(i_param, i_code, i_marker_width, PF_NYARTOOLKIT);
 }
コード例 #11
0
 /**
  * 処理プロファイルを指定して、{@link NyARSingleDetectoMarker}オブジェクトを生成します。
  * @param i_param
  * カメラパラメータを指定します。このサイズは、{@link #detectMarkerLite}に入力する画像と同じである必要があります。
  * @param i_code
  * 検出するマーカパターンを指定します。
  * @param i_marker_width
  * 正方形マーカの物理サイズをmm単位で指定します。
  * @param i_input_raster_type
  * {@link #detectMarkerLite}に入力するラスタの画素形式を指定します。
  * この値は、{@link INyARRgbRaster#getBufferType}関数の戻り値を利用します。
  * @param i_profile_id
  * 計算アルゴリズムの選択値です。以下の定数のいずれかを指定します。
  * <ul>
  * <li>{@link #PF_ARTOOLKIT_COMPATIBLE}
  * <li>{@link #PF_NYARTOOLKIT}
  * <li>{@link #PF_NYARTOOLKIT_ARTOOLKIT_FITTING}
  * </ul>
  * @
  * @
  */
 public static NyARSingleDetectMarker createInstance(NyARParam i_param, NyARCode i_code, double i_marker_width, int i_profile_id)
 {
     switch (i_profile_id) {
     case PF_ARTOOLKIT_COMPATIBLE:
       return new NyARSingleDetectMarker_ARTKv2(i_param, i_code, i_marker_width);
     case PF_NYARTOOLKIT_ARTOOLKIT_FITTING:
       return new NyARSingleDetectMarker_NyARTK_FITTING_ARTKv2(i_param, i_code, i_marker_width);
     case PF_NYARTOOLKIT://default
       return new NyARSingleDetectMarker_NyARTK(i_param, i_code, i_marker_width);
     default:
       throw new NyARException();
       }
 }
コード例 #12
0
 protected NyARSingleDetectMarker(NyARParam i_ref_param, NyARCode i_ref_code, double i_marker_width)
 {
     this._deviation_data = new NyARMatchPattDeviationColorData(i_ref_code.getWidth(), i_ref_code.getHeight());
       this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA(i_ref_code);
       this._offset = new NyARRectOffset();
       this._offset.setSquare(i_marker_width);
       this._coordline = new NyARCoord2Linear(i_ref_param.getScreenSize(), i_ref_param.getDistortionFactor());
       //2値画像バッファを作る
       NyARIntSize s = i_ref_param.getScreenSize();
       this._bin_raster = new NyARBinRaster(s.w, s.h);
 }
コード例 #13
0
ファイル: NyARCode.cs プロジェクト: ooHIROoo/Imagine2016
 /**
  * inputStreamからARToolKit形式のパターンデータを指定サイズで読み出して、格納したインスタンスを生成します。
  * ロードするパターンデータの縦横解像度は、このインスタンスの値と同じである必要があります。
  * @param i_stream
  * 読出し元のStreamオブジェクト
  * @param i_width
  * パターンの幅pixel数。データの内容と一致している必要があります。
  * @param i_height
  * パターンの幅pixel数。データの内容と一致している必要があります。
  * @throws NyARException
  */
 public static NyARCode createFromARPattFile(StreamReader i_stream,int i_width,int i_height)
 {
     //ラスタにパターンをロードする。
     NyARCode ret=new NyARCode(i_width,i_height);
     NyARCodeFileReader.loadFromARToolKitFormFile(i_stream,ret);
     return ret;
 }
コード例 #14
0
ファイル: NyARCode.cs プロジェクト: ooHIROoo/Imagine2016
 /**
  * ImputStreamからARToolKit形式のマーカデータを読み込み、o_codeオブジェクトへ格納します。
  * @param i_stream
  * 読出し元のストリームです。
  * @param o_code
  * 出力先の{@link NyARCode}オブジェクトです。
  * @
  */
 public static void loadFromARToolKitFormFile(StreamReader i_stream, NyARCode o_code)
 {
     int width = o_code.getWidth();
     int height = o_code.getHeight();
     NyARRgbRaster tmp_raster = new NyARRgbRaster(width, height, NyARBufferType.INT1D_X8R8G8B8_32);
     //4個の要素をラスタにセットする。
     try
     {
         int[] buf = (int[])tmp_raster.getBuffer();
         string[] data = i_stream.ReadToEnd().Split(new Char[] { ' ', '\r', '\n' });
         //GBRAで一度読みだす。
         int idx = 0;
         for (int h = 0; h < 4; h++)
         {
             idx = readBlock(data, idx, width, height, buf);
             //ARCodeにセット(カラー)
             o_code.getColorData(h).setRaster(tmp_raster);
             o_code.getBlackWhiteData(h).setRaster(tmp_raster);
         }
     }
     catch (Exception e)
     {
         throw new NyARException(e);
     }
     tmp_raster = null;//ポイ
     return;
 }
コード例 #15
0
 /**
  * この関数は、検出するマーカパターンテーブルの配列を指定します。
  * マーカパターンには、配列の先頭から、0から始まるID番号を割り当てられます。
  * このIDは、{@link #onEnterHandler}イベントハンドラに通知されるID番号に対応し、マーカパターンの識別に使います。
  * @param i_ref_code_table
  * マーカパターンテーブルにセットする配列です。配列にあるマーカパターンの解像度は、i_code_resolutionに一致している必要があります。
  * @param i_code_resolution
  * マーカパターン縦横解像度です。
  * @param i_marker_width
  * <p>メモ:
  * マーカを検出している状態で関数を実行すると、イベント通知なしに、認識中のマーカを見失います。
  * </p>
  * @
  */
 public void setARCodeTable(NyARCode[] i_ref_code_table, int i_code_resolution, double i_marker_width)
 {
     if (this._current_arcode_index != -1) {
     // 強制リセット
     reset(true);
       }
       //検出するマーカセット、情報、検出器を作り直す。(1ピクセル4ポイントサンプリング,マーカのパターン領域は50%)
       this._detectmarker.setNyARCodeTable(i_ref_code_table, i_code_resolution);
       this._offset.setSquare(i_marker_width);
       return;
 }
コード例 #16
0
 /**
  * この関数は、画像から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);
 }
コード例 #17
0
 /**
  * 基準パターンをセットします。セットできる基準パターンは、コンストラクタに設定したサイズと同じものである必要があります。
  * @param i_code_ref
  * セットする基準パターンを格納したオブジェクト
  * @
  */
 public void setARCode(NyARCode i_code_ref)
 {
     this._code_patt = i_code_ref;
     return;
 }
コード例 #18
0
 public void setNyARCodeTable(NyARCode[] i_ref_code, int i_code_resolution)
 {
     /*unmanagedで実装するときは、ここでリソース解放をすること。*/
     this._deviation_data = new NyARMatchPattDeviationColorData(i_code_resolution, i_code_resolution);
     this._inst_patt = new NyARColorPatt_Perspective(i_code_resolution, i_code_resolution, 4, 25);
     this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA[i_ref_code.Length];
     for (int i = 0; i < i_ref_code.Length; i++) {
       this._match_patt[i] = new NyARMatchPatt_Color_WITHOUT_PCA(i_ref_code[i]);
     }
 }
コード例 #19
0
 /**
  * この関数は、ARToolKitスタイルのマーカーを登録します。
  * @param i_code
  * 登録するマーカパターンオブジェクト
  * @param i_patt_edge_percentage
  * エッジ割合。ARToolkitと同じ場合は25を指定します。
  * @param i_marker_size
  * マーカの平方サイズ[mm]
  * @return
  * マーカID(ハンドル)値。
  * @throws NyARException
  */
 public int addARMarker(NyARCode i_code, int i_patt_edge_percentage, double i_marker_size)
 {
     ARMarkerList.Item target = new ARMarkerList.Item(i_code, i_patt_edge_percentage, i_marker_size);
       this._armk_list.Add(target);
       this._tracking_list.add(target);
       this._on_sq_handler.setMaxDetectMarkerCapacity(this._tracking_list.Count);
       return (this._armk_list.Count - 1) | IDTYPE_ARTK;
 }
コード例 #20
0
 /**
  * 基準パターンをセットします。セットできる基準パターンは、コンストラクタに設定したサイズと同じものである必要があります。
  * @param i_code_ref
  * セットする基準パターンを格納したオブジェクト
  * @
  */
 public void setARCode(NyARCode i_code_ref)
 {
     this._ref_code_patt = i_code_ref;
     return;
 }