Ejemplo n.º 1
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();
        }
        public static NyARNftFreakFsetFile genFeatureSet3(NyARNftIsetFile i_iset_file)
        {
            int max_features = 500;
            DogFeaturePointStack   _dog_feature_points = new DogFeaturePointStack(max_features);
            FreakFeaturePointStack query_keypoint      = new FreakFeaturePointStack(max_features);
            //
            List <NyARNftFreakFsetFile.RefDataSet> refdataset = new List <NyARNftFreakFsetFile.RefDataSet>();
            List <NyARNftFreakFsetFile.ImageInfo>  imageinfo  = new List <NyARNftFreakFsetFile.ImageInfo>();

            for (int ii = 0; ii < i_iset_file.items.Length; ii++)
            {
                NyARNftIsetFile.ReferenceImage rimg         = i_iset_file.items[ii];
                FREAKExtractor            mFeatureExtractor = new FREAKExtractor();
                int                       octerves          = BinomialPyramid32f.octavesFromMinimumCoarsestSize(rimg.width, rimg.height, 8);
                BinomialPyramid32f        _pyramid          = new BinomialPyramid32f(rimg.width, rimg.height, octerves, 3);
                DoGScaleInvariantDetector _dog_detector     = new DoGScaleInvariantDetector(rimg.width, rimg.height, octerves, 3, 3, 4, max_features);

                //RefDatasetの作成
                _pyramid.build(NyARGrayscaleRaster.createInstance(rimg.width, rimg.height, NyARBufferType.INT1D_GRAY_8, rimg.img));
                // Detect feature points
                _dog_feature_points.clear();
                _dog_detector.detect(_pyramid, _dog_feature_points);

                // Extract features
                query_keypoint.clear();
                mFeatureExtractor.extract(_pyramid, _dog_feature_points, query_keypoint);

                for (int i = 0; i < query_keypoint.getLength(); i++)
                {
                    FreakFeaturePoint ffp = query_keypoint.getItem(i);
                    NyARNftFreakFsetFile.RefDataSet rds = new NyARNftFreakFsetFile.RefDataSet();
                    rds.pageNo     = 1;
                    rds.refImageNo = ii;
                    rds.coord2D.setValue(ffp.x, ffp.y);
                    rds.coord3D.setValue((ffp.x + 0.5f) / rimg.dpi * 25.4f, ((rimg.height - 0.5f) - ffp.y) / rimg.dpi * 25.4f);
                    rds.featureVec.angle  = ffp.angle;
                    rds.featureVec.maxima = ffp.maxima ? 1 : 0;
                    rds.featureVec.scale  = ffp.scale;
                    ffp.descripter.getValueLe(rds.featureVec.v);
                    refdataset.Add(rds);
                }
                imageinfo.Add(new NyARNftFreakFsetFile.ImageInfo(rimg.width, rimg.height, ii));
            }
            NyARNftFreakFsetFile.PageInfo[] pi = new NyARNftFreakFsetFile.PageInfo[1];
            pi[0] = new NyARNftFreakFsetFile.PageInfo(1, imageinfo.ToArray());
            return(new NyARNftFreakFsetFile(refdataset.ToArray(), pi));
        }