All Downloads are FREE. Search and download functionalities are using the official Maven repository.

boofcv.factory.feature.detect.interest.FactoryInterestPoint Maven / Gradle / Ivy

Go to download

BoofCV is an open source Java library for real-time computer vision and robotics applications.

There is a newer version: 1.1.7
Show newest version
/*
 * Copyright (c) 2011-2020, Peter Abeles. All Rights Reserved.
 *
 * This file is part of BoofCV (http://boofcv.org).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package boofcv.factory.feature.detect.interest;

import boofcv.abst.feature.describe.ConfigSiftScaleSpace;
import boofcv.abst.feature.detect.extract.NonMaxLimiter;
import boofcv.abst.feature.detect.extract.NonMaxSuppression;
import boofcv.abst.feature.detect.interest.*;
import boofcv.abst.filter.derivative.ImageGradient;
import boofcv.abst.filter.derivative.ImageHessian;
import boofcv.alg.feature.detect.interest.*;
import boofcv.alg.filter.derivative.GImageDerivativeOps;
import boofcv.factory.feature.detect.extract.FactoryFeatureExtractor;
import boofcv.factory.filter.derivative.FactoryDerivative;
import boofcv.factory.transform.pyramid.FactoryPyramid;
import boofcv.struct.image.ImageGray;
import boofcv.struct.pyramid.PyramidFloat;

import javax.annotation.Nullable;

/**
 * 

Factory for creating interest point detectors which conform to the {@link InterestPointDetector} * interface

*

* NOTE: Higher level interface than {@link GeneralFeatureDetector}. This will automatically * compute image derivatives across scale space as needed, unlike GeneralFeatureDetector which * just detects features at a particular scale and requires image derivatives be passed in. *

* * @author Peter Abeles * @see FactoryFeatureExtractor */ public class FactoryInterestPoint { public static , D extends ImageGray> InterestPointDetector generic( ConfigDetectInterestPoint config , Class inputType, @Nullable Class derivType ) { switch(config.type) { case FAST_HESSIAN: return FactoryInterestPoint.fastHessian(config.fastHessian,inputType); case SIFT: return FactoryInterestPoint.sift(config.scaleSpaceSift,config.sift,inputType); case POINT: { if( derivType == null ) derivType = GImageDerivativeOps.getDerivativeType(inputType); GeneralFeatureDetector alg = FactoryDetectPoint.create(config.point,inputType,derivType); return FactoryInterestPoint.wrapPoint(alg, config.point.scaleRadius,inputType, derivType); } default: throw new IllegalArgumentException("Unknown detector"); } } /** * Wraps {@link GeneralFeatureDetector} inside an {@link InterestPointDetector}. * * @param feature Feature detector. * @param scaleRadius Radius of descriptor used by scale invariant features * @param inputType Image type of input image. * @param derivType Image type for gradient. * @return The interest point detector. */ public static , D extends ImageGray> InterestPointDetector wrapPoint(GeneralFeatureDetector feature, double scaleRadius , Class inputType, Class derivType) { if( derivType == null ) derivType = GImageDerivativeOps.getDerivativeType(inputType); ImageGradient gradient = null; ImageHessian hessian = null; if (feature.getRequiresGradient() || feature.getRequiresHessian()) gradient = FactoryDerivative.sobel(inputType, derivType); if (feature.getRequiresHessian()) hessian = FactoryDerivative.hessianSobel(derivType); return new GeneralToInterestPoint<>(feature, gradient, hessian, scaleRadius, derivType); } /** * Wraps {@link FeatureLaplacePyramid} inside an {@link InterestPointDetector}. * * @param feature Feature detector. * @param scales Scales at which features are detected at. * @param pyramid Should it be constructed as a pyramid or scale-space * @param inputType Image type of input image. * @return The interest point detector. */ public static , D extends ImageGray> InterestPointDetector wrapDetector(FeatureLaplacePyramid feature, double[] scales, boolean pyramid, Class inputType) { PyramidFloat ss; if( pyramid ) ss = FactoryPyramid.scaleSpacePyramid(scales, inputType); else ss = FactoryPyramid.scaleSpace(scales, inputType); return new WrapFLPtoInterestPoint<>(feature, ss); } /** * Wraps {@link FeaturePyramid} inside an {@link InterestPointDetector}. * * @param feature Feature detector. * @param scales Scales at which features are detected at. * @param pyramid Should it be constructed as a pyramid or scale-space * @param inputType Image type of input image. * @return The interest point detector. */ public static , D extends ImageGray> InterestPointDetector wrapDetector(FeaturePyramid feature, double[] scales, boolean pyramid, Class inputType) { PyramidFloat ss; if( pyramid ) ss = FactoryPyramid.scaleSpacePyramid(scales, inputType); else ss = FactoryPyramid.scaleSpace(scales, inputType); return new WrapFPtoInterestPoint<>(feature, ss); } /** * Creates a {@link FastHessianFeatureDetector} detector which is wrapped inside * an {@link InterestPointDetector} * * @param config Configuration for detector. Pass in null for default options. * @return The interest point detector. * @see FastHessianFeatureDetector */ public static > InterestPointDetector fastHessian( ConfigFastHessian config, Class imageType ) { return new WrapFHtoInterestPoint(FactoryInterestPointAlgs.fastHessian(config),imageType); } public static > InterestPointDetector sift(ConfigSiftScaleSpace configSS , ConfigSiftDetector configDet , Class imageType ) { if( configSS == null ) configSS = new ConfigSiftScaleSpace(); if( configDet == null ) configDet = new ConfigSiftDetector(); SiftScaleSpace scaleSpace = new SiftScaleSpace(configSS.firstOctave,configSS.lastOctave,configSS.numScales,configSS.sigma0); NonMaxSuppression nonmax = FactoryFeatureExtractor.nonmax(configDet.extract); NonMaxLimiter limiter = new NonMaxLimiter(nonmax,configDet.maxFeaturesPerScale); SiftDetector detector = new SiftDetector(scaleSpace,configDet.edgeR,limiter); return new WrapSiftDetector<>(detector, imageType); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy