/**
         * コンストラクタから呼び出す関数です。
         * @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;
        }
Example #2
0
        public FreakKeypointMatching(NyARParam i_ref_cparam)
        {
            NyARIntSize size = i_ref_cparam.getScreenSize();

            this._ref_cparam = i_ref_cparam;


            this.mFeatureExtractor = new FREAKExtractor();
            int octerves = BinomialPyramid32f.octavesFromMinimumCoarsestSize(size.w, size.h, kMinCoarseSize);

            this._pyramid      = new BinomialPyramid32f(size.w, size.h, octerves, 3);
            this._dog_detector = new DoGScaleInvariantDetector(size.w, size.h, octerves, 3, kLaplacianThreshold, kEdgeThreshold, kMaxNumFeatures);

            this.mMinNumInliers = kMinNumInliers;

            //

            this._tmp_pair_stack[0] = new FeaturePairStack(kMaxNumFeatures);
            this._tmp_pair_stack[1] = new FeaturePairStack(kMaxNumFeatures);
            this._find_inliner      = new FindInliers_O1(kHomographyInlierThreshold);
            double dx = size.w + (size.w * 0.2f);
            double dy = size.h + (size.h * 0.2f);

            this.mHoughSimilarityVoting = new HoughSimilarityVoting_O3(-dx, dx, -dy, dy, 12, 10);
            this._matcher = new BinaryHirerarchialClusteringMatcher();
        }
 /**
  * コンストラクタです。カメラパラメータにサンプル値(../Data/camera_para.dat)をロードして、コンフィギュレーションを生成します。
  * @param i_width
  * @param i_height
  * @
  */
 public NyARMarkerSystemConfig(NyARParam i_param, int i_transmat_algo_type)
 {
     Debug.Assert(1 <= i_transmat_algo_type && i_transmat_algo_type <= 3);
     this._param = i_param;
     this._transmat_algo_type = i_transmat_algo_type;
     return;
 }
Example #4
0
        public D3dManager(Form i_main_window, NyARParam i_nyparam, int i_profile_id)
        {
            PresentParameters pp = new PresentParameters();
            // ウインドウモードなら true、フルスクリーンモードなら false を指定
            pp.Windowed = true;
            // スワップとりあえずDiscardを指定。
            pp.SwapEffect = SwapEffect.Discard;
            pp.EnableAutoDepthStencil = true;
            pp.AutoDepthStencilFormat = DepthFormat.D16;
            pp.BackBufferCount = 0;
            pp.BackBufferFormat = Format.R5G6B5;
            this._d3d_device = new Device(0, DeviceType.Default, i_main_window.Handle, CreateFlags.None, pp);

            //ビューポートを指定
            float scale = setupView(i_nyparam,i_main_window.ClientSize);
            this._scale = scale;
            // ライトを無効
            this._d3d_device.RenderState.Lighting = false;

            //カメラ画像の転写矩形を作成
            Viewport vp=this._d3d_device.Viewport;
            this._view_rect = new Rectangle(vp.X, vp.Y, vp.Width, vp.Height);

            NyARIntSize cap_size = i_nyparam.getScreenSize();
            this._background_size = new Size(cap_size.w, cap_size.h);
            return;
        }
Example #5
0
            public MarkerProcessor(NyARParam i_cparam, int i_raster_format)
            {
                initInstance(i_cparam, new NyIdMarkerDataEncoder_RawBit(), 100);

                //アプリケーションフレームワークの初期化
                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;
 }
 public DetectSquareCB(NyARParam i_param, INyIdMarkerDataEncoder i_encoder)
 {
     this._coordline = new Coord2Linear(i_param.getScreenSize(), i_param.getDistortionFactor());
     this._data_temp = i_encoder.createDataInstance();
     this._current_data = i_encoder.createDataInstance();
     this._encoder = i_encoder;
     return;
 }
 public RleDetector(NyARParam i_param, INyIdMarkerDataEncoder i_encoder, NyIdMarkerPickup i_id_pickup): base(i_param.getScreenSize())
 {
    
     this._coordline = new NyARCoord2Linear(i_param.getScreenSize(), i_param.getDistortionFactor());
     this._data_temp = i_encoder.createDataInstance();
     this._current_data = i_encoder.createDataInstance();
     this._encoder = i_encoder;
     this._id_pickup = i_id_pickup;
     return;
 }
 public NyARTransMat(NyARParam i_param)
 {
     NyARCameraDistortionFactor dist = i_param.getDistortionFactor();
     NyARPerspectiveProjectionMatrix pmat = i_param.getPerspectiveProjectionMatrix();
     this._transsolver = new NyARTransportVectorSolver(pmat, 4);
     //互換性が重要な時は、NyARRotMatrix_ARToolKitを使うこと。
     //理屈はNyARRotMatrix_NyARToolKitもNyARRotMatrix_ARToolKitも同じだけど、少しだけ値がずれる。
     this._rotmatrix = new NyARRotMatrix(pmat);
     this._mat_optimize = new NyARPartialDifferentiationOptimize(pmat);
     this._ref_dist_factor = dist;
     this._projection_mat_ref = pmat;
 }
      /// <summary>
      /// Initialize a new SquareDetectionListener.
      /// </summary>
      /// <param name="patternMatchers">The pattern matchers with the marker data.</param>
      /// <param name="cameraParameters">The camera calibration data.</param>
      /// <param name="colorPattern">The used color pattern.</param>
      /// <param name="patternMatchDeviationData">The pattern match deviation data.</param>
      public SquareDetectionListener(List<PatternMatcher> patternMatchers, NyARParam cameraParameters, INyARColorPatt colorPattern, NyARMatchPattDeviationColorData patternMatchDeviationData)
      {
         this.patternMatchers = patternMatchers;
         this.colorPattern = colorPattern;
         this.patternMatchDeviationData = patternMatchDeviationData;
         this.coordinationMapper = new Coord2Linear(cameraParameters.getScreenSize(), cameraParameters.getDistortionFactor());
         this.matrixCalculator = new NyARTransMat(cameraParameters);
         this.points = NyARIntPoint2d.createArray(4);
         this.evaluationResult = new NyARMatchPattResult();

         Reset();
      }
Example #11
0
        public NyARTransMat(NyARParam i_param)
        {
            NyARCameraDistortionFactor      dist = i_param.getDistortionFactor();
            NyARPerspectiveProjectionMatrix pmat = i_param.getPerspectiveProjectionMatrix();

            this._transsolver = new NyARTransportVectorSolver(pmat, 4);
            //互換性が重要な時は、NyARRotMatrix_ARToolKitを使うこと。
            //理屈はNyARRotMatrix_NyARToolKitもNyARRotMatrix_ARToolKitも同じだけど、少しだけ値がずれる。
            this._rotmatrix          = new NyARRotMatrix(pmat);
            this._mat_optimize       = new NyARPartialDifferentiationOptimize(pmat);
            this._ref_dist_factor    = dist;
            this._projection_mat_ref = pmat;
        }
Example #12
0
        public NyARSurfaceTracker(NyARParam i_param_ref, int i_max_search_feature_num, double i_sim_thresh)
        {
            this._candidate        = new NyARSurfaceFeatures(NyARSurfaceFeatures.AR2_TRACKING_CANDIDATE_MAX + 1);
            this._candidate2       = new NyARSurfaceFeatures(NyARSurfaceFeatures.AR2_TRACKING_CANDIDATE_MAX + 1);
            this._feature_selector = new NyARVisibleFeatureExtractor(i_param_ref.getScreenSize(), i_param_ref.getDistortionFactor());
            this.__pcpoints        = new PatchImagePositions(i_param_ref.getDistortionFactor());

            this._ref_cparam      = i_param_ref;
            this.searchFeatureNum = i_max_search_feature_num;
            this.simThresh        = i_sim_thresh;

            this._ctrans_log             = new NyARSurfaceTransMatrixSetFifo(3);
            this._prev_selected_features = new NyARFeatureCoordPtrList(this.searchFeatureNum);
            this.__selected_features     = new NyARSurfaceFeaturesPtr(this.searchFeatureNum);
            return;
        }
Example #13
0
        public void Test_arDetectMarkerLite()
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            
            //AR用カメラパラメタファイルをロード
            NyARParam ap = new NyARParam();
            ap.loadARParam(assembly.GetManifestResourceStream(RES_CAMERA));
            ap.changeScreenSize(320, 240);

            //AR用のパターンコードを読み出し	
            NyARCode code = new NyARCode(16, 16);
            Stream sr1=assembly.GetManifestResourceStream(RES_PATT);
            code.loadARPatt(new StreamReader(sr1));

            //試験イメージの読み出し(320x240 BGRAのRAWデータ)
            StreamReader sr = new StreamReader(assembly.GetManifestResourceStream(RES_DATA));
            BinaryReader bs = new BinaryReader(sr.BaseStream);
            byte[] raw = bs.ReadBytes(320 * 240 * 4);
            NyARRgbRaster_BGRA ra = new NyARRgbRaster_BGRA(320, 240,false);
            ra.wrapBuffer(raw);
            //		Blank_Raster ra=new Blank_Raster(320, 240);

            //1パターンのみを追跡するクラスを作成
//            NyARSingleDetectMarker_Quad ar = new NyARSingleDetectMarker_Quad(ap, code, 80.0);
            NyARSingleDetectMarker ar = new NyARSingleDetectMarker(ap, code, 80.0,ra.getBufferType());
            NyARTransMatResult result_mat = new NyARTransMatResult();
            ar.setContinueMode(false);
            ar.detectMarkerLite(ra, 100);
            ar.getTransmationMatrix(result_mat);

            //マーカーを検出
            for (int i3 = 0; i3 < 10; i3++)
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();
                for (int i = 0; i < 10; i++)
                {
                    //変換行列を取得
                    ar.detectMarkerLite(ra, 100);
                    ar.getTransmationMatrix(result_mat);
                }
                sw.Stop();
                Debug.WriteLine(sw.ElapsedMilliseconds + "[ms]");
            }
            return;
        }
Example #14
0
        private static bool kpmUtilGetPose_binary(NyARParam i_cparam, FeaturePairStack matchData, NyARDoubleMatrix44 i_transmat, NyARTransMatResultParam i_resultparam)
        {
            NyARDoubleMatrix44 initMatXw2Xc = new NyARDoubleMatrix44();
            // ARdouble err;
            int i;

            if (matchData.getLength() < 4)
            {
                return(false);
            }
            NyARDoublePoint2d[] sCoord = NyARDoublePoint2d.createArray(matchData.getLength());
            NyARDoublePoint3d[] wCoord = NyARDoublePoint3d.createArray(matchData.getLength());
            for (i = 0; i < matchData.getLength(); i++)
            {
                sCoord[i].x = matchData.getItem(i).query.x;
                sCoord[i].y = matchData.getItem(i).query.y;

                wCoord[i].x = matchData.getItem(i).ref_.pos3d.x;
                wCoord[i].y = matchData.getItem(i).ref_.pos3d.y;
                wCoord[i].z = 0.0;
            }


            NyARIcpPlane icp_planer = new NyARIcpPlane(i_cparam.getPerspectiveProjectionMatrix());

            if (!icp_planer.icpGetInitXw2Xc_from_PlanarData(sCoord, wCoord, matchData.getLength(), initMatXw2Xc))
            {
                return(false);
            }

            /*
             * printf("--- Init pose ---\n"); for( int j = 0; j < 3; j++ ) { for( i = 0; i < 4; i++ ) printf(" %8.3f",
             * initMatXw2Xc[j][i]); printf("\n"); }
             */
            NyARIcpPoint icp_point = new NyARIcpPoint(i_cparam.getPerspectiveProjectionMatrix());

            icp_point.icpPoint(sCoord, wCoord, matchData.getLength(), initMatXw2Xc, i_transmat, i_resultparam);
            if (i_resultparam.last_error > 10.0f)
            {
                return(false);
            }
            return(true);
        }
Example #15
0
        private void buttonBookDemo_Click(object sender, EventArgs e)
        {
            if (bookDemo == false)
            {
                StopOtherApps(this, e);
                bookDemo = true;
                labelDemoName.Text = "Book";
                buttonBookDemo.Text = "Stop Book";
                labelDemoInstructions.Enabled = true;
                labelDemoInstructions.Text = "Book Demo Instructions:\n\n"
                    + "Book \n";

                //pictureBoxAlbum.Show();
                lblResult.Hide();

                //NYAR
                //initialize nyar components.
                NyARParam ap = new NyARParam();
                ap.loadARParamFromFile(AR_CAMERA_FILE);
                ap.changeScreenSize(SCREEN_WIDTH, SCREEN_HEIGHT);
                _raster = new DsBGRX32Raster(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_WIDTH * 32 / 8);
                _utils = new NyARD3dUtil();

                // For each pattern
                NyARCode code1 = new NyARCode(16, 16);
                code1.loadARPattFromFile(AR_CODE_FILE1);
                _ar1 = new NyARSingleDetectMarker(ap, code1, 80.0);
                _ar1.setContinueMode(false);

                NyARCode code2 = new NyARCode(16, 16);
                code2.loadARPattFromFile(AR_CODE_FILE2);
                _ar2 = new NyARSingleDetectMarker(ap, code2, 80.0);
                _ar2.setContinueMode(false);

                NyARCode code3 = new NyARCode(16, 16);
                code3.loadARPattFromFile(AR_CODE_FILE3);
                _ar3 = new NyARSingleDetectMarker(ap, code3, 80.0);
                _ar3.setContinueMode(false);

                NyARCode code4 = new NyARCode(16, 16);
                code4.loadARPattFromFile(AR_CODE_FILE4);
                _ar4 = new NyARSingleDetectMarker(ap, code4, 80.0);
                _ar4.setContinueMode(false);
            }
            else
            {
                bookDemo = false;
                labelDemoName.Text = "WUW";
                buttonBookDemo.Text = "Book";
                Cursor = Cursors.Arrow;
                labelDemoInstructions.Enabled = false;
                labelDemoInstructions.Text = "";
                ResetEnvironment();

                //pictureBoxAlbum.Hide();
                lblResult.Show();
            }
        }
Example #16
0
 public static void toCameraFrustumRH(NyARParam i_arparam, double i_near, double i_far, ref Matrix o_d3d_projection)
 {
     toCameraFrustumRH(i_arparam.getPerspectiveProjectionMatrix(),i_arparam.getScreenSize(),1.0,i_near, i_far,ref o_d3d_projection);
 }
 public NyARIcpPlane(NyARParam i_param)
 {
     this._cparam = i_param.getPerspectiveProjectionMatrix();
 }
        protected void initInstance(NyARParam i_param, INyIdMarkerDataEncoder i_encoder, double i_marker_width, int i_raster_format)
        {
            //初期化済?
            Debug.Assert(this._initialized == false);

            NyARIntSize scr_size = i_param.getScreenSize();
            // 解析オブジェクトを作る
            this._square_detect = new NyARSquareContourDetector_Rle(scr_size);
            this._transmat = new NyARTransMat(i_param);
            this._callback = new DetectSquareCB(i_param, i_encoder);

            // 2値画像バッファを作る
            this._bin_raster = new NyARBinRaster(scr_size.w, scr_size.h);
            //ワーク用のデータオブジェクトを2個作る
            this._data_current = i_encoder.createDataInstance();
            this._tobin_filter = new NyARRasterFilter_ARToolkitThreshold(110, i_raster_format);
            this._threshold_detect = new NyARRasterThresholdAnalyzer_SlidePTile(15, i_raster_format, 4);
            this._initialized = true;
            this._is_active = false;
            this._offset = new NyARRectOffset();
            this._offset.setSquare(i_marker_width);
            return;

        }
Example #19
0
        /*
         * <nyar>
         *  <version>MobileSimpleLite/0.1</version>
         *  <config>
         *   <camera file="camera_para.dat" width="240" height="320" vertical="false"></camera>
         *   <patt file="patt.hiro" size="16"></patt>
         *   <direct3d background="texture"/>
         *  </config>
         * </nyar>
         */
        public ResourceBuilder()
        {
            //ルートパスの取得
            this._root_path=Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName);
            //設定の読み出し

            XmlDocument dom = new XmlDocument();
            dom.Load(this._root_path + "\\setting.xml");
            if (dom.SelectSingleNode("/root/version").InnerText != "MobileSimpleLite/0.1")
            {
                throw new Exception("設定ファイルのバージョンが違います?");
            }
            XmlNode config_node = dom.SelectSingleNode("/root/config");


            this._cap_size.Width = int.Parse(config_node.SelectSingleNode("camera/@width").Value);
            this._cap_size.Height =int.Parse(config_node.SelectSingleNode("camera/@height").Value);
            this._cpara_file = config_node.SelectSingleNode("camera/@file").Value;
            this._cvertical = bool.Parse(config_node.SelectSingleNode("camera/@vertical").Value);

            this._code_file = config_node.SelectSingleNode("patt/@file").Value;
            this._code_size = int.Parse(config_node.SelectSingleNode("patt/@size").Value);

            String bgmode=config_node.SelectSingleNode("direct3d/@background").Value;
            this._background_type = bgmode.CompareTo("texture")==0 ? BGMODE_TEXTURE : BGMODE_SURFACE;
            dom = null;

            //初期化セクション
            this._ar_param=new NyARParam();
            this._ar_param.loadARParamFromFile(this._root_path + "\\" +this._cpara_file);
            this._ar_param.changeScreenSize(this._cap_size.Width, this._cap_size.Height);


            return;
        }
Example #20
0
	    /**
	     * コンストラクタ。
	     * 樽型歪みが少ない、または補正済みの画像を入力するときには、{@link #NyARReality(NyARIntSize, double, double, NyARPerspectiveProjectionMatrix, NyARCameraDistortionFactor, int, int)}
	     * のi_dist_factorにnullを指定すると、より高速な動作が期待できます。
	     * @param i_param
	     * カメラパラメータを指定します。
	     * @param i_near
	     * 視錐体のnear-pointをmm単位で指定します。
	     * default値は{@link #FRASTRAM_ARTK_NEAR}です。
	     * @param i_far
	     * 視錐体のfar-pointをmm単位で指定します。
	     * default値は{@link #FRASTRAM_ARTK_FAR}です。
	     * @param i_max_known_target
	     * Knownターゲットの最大数を指定します。
	     * @param i_max_unknown_target
	     * UnKnownターゲットの最大数を指定します。
	     * @throws NyARException
	     */
	    public NyARReality(NyARParam i_param,double i_near,double i_far,int i_max_known_target,int i_max_unknown_target)
	    {
		    //定数とかいろいろ
		    this.MAX_LIMIT_KNOWN=i_max_known_target;
		    this.MAX_LIMIT_UNKNOWN=i_max_unknown_target;
		    this.initInstance(i_param.getScreenSize(),i_near,i_far,i_param.getPerspectiveProjectionMatrix(),i_param.getDistortionFactor());
		    return;
	    }
 public NyARMarkerSystemConfig(NyARParam i_param)
     : this(i_param, TM_ARTKICP)
 {
 }
 /**
  * @param i_param
  * @param i_max_points
  * 最大頂点数
  * @throws NyARException
  */
 public NyARIcpPointRobust(NyARParam i_param)
     : base(i_param)
 {
 }
 /**
  * @param i_param
  * @param i_max_points
  * 最大頂点数
  * @throws NyARException
  */
 public NyARIcpPointRobust(NyARParam i_param)
     : base(i_param)
 {
 }
 public NyARMarkerSystemConfig(StreamReader i_ar_param_stream, int i_width, int i_height)
 {
     this._param = new NyARParam();
     this._param.loadARParam(i_ar_param_stream);
     this._param.changeScreenSize(i_width, i_height);
 }
 public DetectSquare(NyARParam i_param): base(i_param.getScreenSize())
 {
     this._match_patt = null;
     this._coordline = new NyARCoord2Linear(i_param.getScreenSize(), i_param.getDistortionFactor());
     return;
 }
 /**
  * コンストラクタです。
  * 座標計算に必要なカメラパラメータの参照値を元に、インスタンスを生成します。
  * @param i_param
  * ARToolKit形式のカメラパラメータです。
  * インスタンスは、この中から樽型歪み矯正オブジェクト、射影変換オブジェクトを参照します。
  * @
  */
 public NyARTransMat(NyARParam i_param)
 {
     initInstance(i_param.getDistortionFactor(), i_param.getPerspectiveProjectionMatrix());
     return;
 }
        /// <summary>
        /// Initializes the detector for single marker detection.
        /// </summary>
        /// <param name="width">The width of the buffer that will be used for detection.</param>
        /// <param name="height">The height of the buffer that will be used for detection.</param>
        /// <param name="nearPlane">The near view plane of the frustum.</param>
        /// <param name="farPlane">The far view plane of the frustum.</param>
        /// <param name="markers">A list of markers that should be detected.</param>
        /// <param name="bufferType">The type of the buffer.</param>
        /// <param name="adaptive">Performs an adaptive bitmap thresholding if set to true. Default = false.</param>
        protected void Initialize(int width, int height, double nearPlane, double farPlane, IList<Marker> markers, int bufferType, bool adaptive = false)
        {
            // Check arguments
            if (markers == null || !markers.Any())
            {
                throw new ArgumentNullException("markers");
            }

            // Member init
            this.bufferWidth = width;
            this.bufferHeight = height;
            this.isAdaptive = adaptive;

            // Init pattern matchers with markers and check segment size, whcih has to be equal for all markers
            int segmentX = markers[0].SegmentsX;
            int segmentY = markers[0].SegmentsY;
            var patternMatchers = new List<PatternMatcher>(markers.Count);
            foreach (var marker in markers)
            {
                if (marker.SegmentsX != segmentX || marker.SegmentsY != segmentY)
                {
                    throw new ArgumentException("The Segment size has to be equal for all markers. Don't mix 16x16 and 32x32 markers for example.", "markers");
                }
                patternMatchers.Add(new PatternMatcher(marker));
            }

            // Load deafult camera calibration data
            string location = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            StreamReader reader = new StreamReader(location + "/Content/Data/Camera_Calibration_1280x720.dat");
            var cameraParameters = new NyARParam();
            using (var cameraCalibrationDataStream = reader.BaseStream)
            {
                cameraParameters.loadARParam(cameraCalibrationDataStream);
                cameraParameters.changeScreenSize(width, height);
            }

            //var asmName = new System.Reflection.AssemblyName(System.Reflection.Assembly.GetExecutingAssembly().FullName).Name;

            //var uri = new Uri(asmName + ";component/Assets/data/Camera_Calibration_1280x720.dat", UriKind.Relative);
            //var streamResInfoCam = Application.GetResourceStream(uri);
            //if (null == streamResInfoCam)
            //    throw new FileNotFoundException("Application.GetResourceStream returned null", uri.OriginalString);

            //var cameraParameters = new NyARParam();
            //using (var cameraCalibrationDataStream = streamResInfoCam.Stream)
            //{
            //    cameraParameters.loadARParam(cameraCalibrationDataStream);
            //    cameraParameters.changeScreenSize(width, height);
            //}

            // Get projection matrix from camera calibration data
            this.Projection = cameraParameters.GetCameraFrustumRH(nearPlane, farPlane);

            // Init detector and necessary data
            var colorPattern = new NyARColorPatt_Perspective_O2(segmentX, segmentY, 4, 25);
            var patternMatchDeviationData = new NyARMatchPattDeviationColorData(segmentX, segmentY);
            this.squareDetector = new NyARSquareContourDetector_Rle(cameraParameters.getScreenSize());
            this.squareDetectionListener = new SquareDetectionListener(patternMatchers, cameraParameters, colorPattern, patternMatchDeviationData);

            // Init buffer members 
            this.filteredBuffer = new NyARBinRaster(width, height);
            if (adaptive)
            {
                this.bufferFilter = new NyARRasterFilter_AdaptiveThreshold(bufferType);
            }
            else
            {
                this.bufferFilter = new NyARRasterFilter_ARToolkitThreshold(this.Threshold, bufferType);
            }
        }
 /**
  * コンストラクタです。
  * 座標計算に必要なカメラパラメータの参照値を元に、インスタンスを生成します。
  * @param i_param
  * ARToolKit形式のカメラパラメータです。
  * インスタンスは、この中から樽型歪み矯正オブジェクト、射影変換オブジェクトを参照します。
  * @
  */
 public NyARTransMat(NyARParam i_param)
     : this(i_param.getDistortionFactor(), i_param.getPerspectiveProjectionMatrix())
 {
     return;
 }
        /**
         * この関数は、インスタンスを初期化します。
         * 継承先のクラスから呼び出してください。
         * @param i_param
         * カメラパラメータオブジェクト。このサイズは、{@link #detectMarker}に入力する画像と同じサイズである必要があります。
         * @param i_encoder
         * IDマーカの値エンコーダを指定します。
         * @param i_marker_width
         * マーカの物理縦横サイズをmm単位で指定します。
         * @
         */
        protected void initInstance(NyARParam i_param, INyIdMarkerDataEncoder i_encoder, double i_marker_width)
        {
            //初期化済?
            Debug.Assert(this._initialized == false);

            NyARIntSize scr_size = i_param.getScreenSize();
            // 解析オブジェクトを作る
            this._square_detect = new RleDetector(
                i_param,
                i_encoder,
                new NyIdMarkerPickup());
            this._transmat = new NyARTransMat(i_param);

            // 2値画像バッファを作る
            this._gs_raster = new NyARGrayscaleRaster(scr_size.w, scr_size.h);
            this._histmaker = (INyARHistogramFromRaster)this._gs_raster.createInterface(typeof(INyARHistogramFromRaster));
            //ワーク用のデータオブジェクトを2個作る
            this._data_current = i_encoder.createDataInstance();
            this._threshold_detect = new NyARHistogramAnalyzer_SlidePTile(15);
            this._initialized = true;
            this._is_active = false;
            this._offset = new NyARRectOffset();
            this._offset.setSquare(i_marker_width);
            return;

        }
 /**
  * 処理プロファイルを指定して、{@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();
     }
 }
        /**
         * この関数は、インスタンスを初期化します。
         * 継承先のクラスから呼び出してください。
         * @param i_param
         * カメラパラメータオブジェクト。このサイズは、{@link #detectMarker}に入力する画像と同じサイズである必要があります。
         * @
         */
        protected void initInstance(NyARParam i_param)
        {
            //初期化済?
            Debug.Assert(this._initialized == false);

            NyARIntSize scr_size = i_param.getScreenSize();
            // 解析オブジェクトを作る
            this._transmat = new NyARTransMat(i_param);
            this._thdetect = new NyARHistogramAnalyzer_SlidePTile(15);

            // 2値画像バッファを作る
            this._gs_raster = new NyARGrayscaleRaster(scr_size.w, scr_size.h);
            this._initialized = true;
            //コールバックハンドラ
            this._detectmarker = new DetectSquare(i_param);
            this._offset = new NyARRectOffset();
            return;
        }
 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);
 }
 public NyARMarkerSystemConfig(NyARParam i_param)
 {
     this._param = i_param;
 }
 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());
 }
 /**
  * コンストラクタです。カメラパラメータにサンプル値(../Data/camera_para.dat)をロードして、コンフィギュレーションを生成します。
  * @param i_width
  * @param i_height
  * @
  */
 public NyARMarkerSystemConfig(int i_width, int i_height)
 {
     this._param = new NyARParam();
     this._param.loadDefaultParameter();
     this._param.changeScreenSize(i_width, i_height);
 }
 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);
 }
 /**
  * コンストラクタです。
  * 座標計算に必要なカメラパラメータの参照値を元に、インスタンスを生成します。
  * @param i_param
  * ARToolKit形式のカメラパラメータです。
  * インスタンスは、この中から樽型歪み矯正オブジェクト、射影変換オブジェクトを参照します。
  * @
  */
 public NyARTransMat(NyARParam i_param)
 {
     initInstance(i_param.getDistortionFactor(), i_param.getPerspectiveProjectionMatrix());
     return;
 }
 public NyARMarkerSystemConfig(StreamReader i_ar_param_stream, int i_width, int i_height)
 {
     this._param = NyARParam.createFromARParamFile(i_ar_param_stream);
     this._param.changeScreenSize(i_width, i_height);
 }