예제 #1
0
 /**
  * ARコードファイルからデータを読み込んでo_codeに格納します。
  * @param i_stream
  * @param o_code
  * @throws NyARException
  */
 public static void loadFromARToolKitFormFile(StreamReader i_stream, NyARCode o_code)
 {
     int width = o_code.getWidth();
     int height = o_code.getHeight();
     NyARRaster tmp_raster = new NyARRaster(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
 public NyARMatchPatt_BlackWhite(NyARCode i_code_ref)
 {
     //最適化定数の計算
     this._pixels    = i_code_ref.getWidth() * i_code_ref.getHeight();
     this._code_patt = i_code_ref;
     return;
 }
예제 #3
0
        /**
         * ImputStreamからARToolKit形式のマーカデータを読み込んでo_codeに格納します。
         * @param i_stream
         * 読出し元のストリームです。
         * @param o_code
         * 出力先のNyARCodeオブジェクトです。
         * @throws NyARException
         */
        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;
        }
 public NyARMatchPatt_BlackWhite(NyARCode i_code_ref)
 {
     //最適化定数の計算
     this._pixels = i_code_ref.getWidth() * i_code_ref.getHeight();
     this._code_patt = i_code_ref;
     return;
 }
 public DetectSquareCB(INyARColorPatt i_inst_patt, NyARCode i_ref_code, NyARParam i_param)
 {
     this._inst_patt = i_inst_patt;
     this._deviation_data = new NyARMatchPattDeviationColorData(i_ref_code.getWidth(), i_ref_code.getHeight());
     this._coordline = new Coord2Linear(i_param.getScreenSize(), i_param.getDistortionFactor());
     this._match_patt = new NyARMatchPatt_Color_WITHOUT_PCA(i_ref_code);
     return;
 }
 /**
  * コンストラクタ。
  * 基準パターンを元に、インスタンスを生成します。
  * @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;
 }
 /** */
 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;
 }
예제 #8
0
        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;
        }
 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);
 }
 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());
 }
        /**
         * コンストラクタから呼び出す関数です。
         * @param i_ref_param
         * @param i_ref_code
         * @param i_marker_width
         * @param i_input_raster_type
         * @param i_profile_id
         * @throws NyARException
         */
        protected void initialize(
            NyARParam i_ref_param,
            NyARCode i_ref_code,
            double i_marker_width,
            int i_input_raster_type,
            int i_profile_id)
        {
            NyARRasterFilter_ARToolkitThreshold th = new NyARRasterFilter_ARToolkitThreshold(100, i_input_raster_type);
            INyARColorPatt patt_inst;
            NyARSquareContourDetector sqdetect_inst;
            INyARTransMat transmat_inst;

            switch (i_profile_id)
            {
                case PF_ARTOOLKIT_COMPATIBLE:
                    patt_inst = new NyARColorPatt_O3(i_ref_code.getWidth(), i_ref_code.getHeight());
                    sqdetect_inst = new NyARSquareContourDetector_ARToolKit(i_ref_param.getScreenSize());
                    transmat_inst = new NyARTransMat_ARToolKit(i_ref_param);
                    break;
                case PF_NYARTOOLKIT_ARTOOLKIT_FITTING:
                    patt_inst = new NyARColorPatt_Perspective_O2(i_ref_code.getWidth(), i_ref_code.getHeight(), 4, 25);
                    sqdetect_inst = new NyARSquareContourDetector_Rle(i_ref_param.getScreenSize());
                    transmat_inst = new NyARTransMat_ARToolKit(i_ref_param);
                    break;
                case PF_NYARTOOLKIT://default
                    patt_inst = new NyARColorPatt_Perspective_O2(i_ref_code.getWidth(), i_ref_code.getHeight(), 4, 25);
                    sqdetect_inst = new NyARSquareContourDetector_Rle(i_ref_param.getScreenSize());
                    transmat_inst = new NyARTransMat(i_ref_param);
                    break;
                default:
                    throw new NyARException();
            }
            base.initInstance(patt_inst, sqdetect_inst, transmat_inst,th, i_ref_param, i_ref_code, i_marker_width);
            return;
        }