use of boofcv.abst.feature.detect.interest.ConfigGeneralDetector in project narchy by automenta.
the class WebcamTrack method main.
public static void main(String[] args) {
// tune the tracker for the image size and visual appearance
ConfigGeneralDetector configDetector = new ConfigGeneralDetector(-1, 8, 1);
PkltConfig configKlt = new PkltConfig(3, new int[] { 1, 2, 4, 8 });
PointTracker<ImageFloat32> tracker = FactoryPointTracker.klt(configKlt, configDetector, ImageFloat32.class, null);
// Open a webcam at a resolution close to 640x480
Webcam webcam = UtilWebcamCapture.openDefault(640, 480);
// Create the panel used to display the image and
ImagePanel gui = new ImagePanel();
gui.setPreferredSize(webcam.getViewSize());
ShowImages.showWindow(gui, "KLT Tracker");
int minimumTracks = 100;
while (true) {
BufferedImage image = webcam.getImage();
ImageFloat32 gray = ConvertBufferedImage.convertFrom(image, (ImageFloat32) null);
tracker.process(gray);
List<PointTrack> tracks = tracker.getActiveTracks(null);
// Spawn tracks if there are too few
if (tracks.size() < minimumTracks) {
tracker.spawnTracks();
tracks = tracker.getActiveTracks(null);
minimumTracks = tracks.size() / 2;
}
// Draw the tracks
Graphics2D g2 = image.createGraphics();
for (PointTrack t : tracks) {
VisualizeFeatures.drawPoint(g2, (int) t.x, (int) t.y, Color.RED);
}
gui.setBufferedImageSafe(image);
}
}
use of boofcv.abst.feature.detect.interest.ConfigGeneralDetector in project BoofCV by lessthanoptimal.
the class FactoryPointTracker method klt.
/**
* Pyramid KLT feature tracker.
*
* @see boofcv.alg.tracker.klt.PyramidKltTracker
*
* @param config Config for the tracker. Try PkltConfig.createDefault().
* @param configExtract Configuration for extracting features
* @return KLT based tracker.
*/
public static <I extends ImageGray<I>, D extends ImageGray<D>> PointTracker<I> klt(PkltConfig config, ConfigGeneralDetector configExtract, Class<I> imageType, Class<D> derivType) {
if (derivType == null)
derivType = GImageDerivativeOps.getDerivativeType(imageType);
if (config == null) {
config = new PkltConfig();
}
if (configExtract == null) {
configExtract = new ConfigGeneralDetector();
}
GeneralFeatureDetector<I, D> detector = createShiTomasi(configExtract, derivType);
InterpolateRectangle<I> interpInput = FactoryInterpolation.<I>bilinearRectangle(imageType);
InterpolateRectangle<D> interpDeriv = FactoryInterpolation.<D>bilinearRectangle(derivType);
ImageGradient<I, D> gradient = FactoryDerivative.sobel(imageType, derivType);
PyramidDiscrete<I> pyramid = FactoryPyramid.discreteGaussian(config.pyramidScaling, -1, 2, true, ImageType.single(imageType));
return new PointTrackerKltPyramid<>(config.config, config.templateRadius, pyramid, detector, gradient, interpInput, interpDeriv, derivType);
}
use of boofcv.abst.feature.detect.interest.ConfigGeneralDetector in project BoofCV by lessthanoptimal.
the class TestDdaManagerDetectDescribePoint method createTracker.
@Override
public PointTracker<GrayF32> createTracker() {
DescribePointBrief<GrayF32> brief = FactoryDescribePointAlgs.brief(FactoryBriefDefinition.gaussian2(new Random(123), 16, 512), FactoryBlurFilter.gaussian(ImageType.single(GrayF32.class), 0, 4));
GeneralFeatureDetector<GrayF32, GrayF32> corner = FactoryDetectPoint.createShiTomasi(new ConfigGeneralDetector(100, 2, 0, 0, true), false, GrayF32.class);
InterestPointDetector<GrayF32> detector = FactoryInterestPoint.wrapPoint(corner, 1, GrayF32.class, GrayF32.class);
ScoreAssociateHamming_B score = new ScoreAssociateHamming_B();
AssociateDescription2D<TupleDesc_B> association = new AssociateDescTo2D<>(FactoryAssociation.greedy(score, 400, true));
DetectDescribeFusion<GrayF32, TupleDesc_B> fused = new DetectDescribeFusion<>(detector, null, new WrapDescribeBrief<>(brief, GrayF32.class));
DdaManagerDetectDescribePoint<GrayF32, TupleDesc_B> manager;
manager = new DdaManagerDetectDescribePoint<>(fused);
DetectDescribeAssociate<GrayF32, TupleDesc_B> tracker = new DetectDescribeAssociate<>(manager, association, false);
return tracker;
}
use of boofcv.abst.feature.detect.interest.ConfigGeneralDetector in project BoofCV by lessthanoptimal.
the class TestDetectDescribeAssociateTwoPass method createTracker.
@Override
public PointTrackerTwoPass<GrayF32> createTracker() {
DescribePointBrief<GrayF32> brief = FactoryDescribePointAlgs.brief(FactoryBriefDefinition.gaussian2(new Random(123), 16, 512), FactoryBlurFilter.gaussian(ImageType.single(GrayF32.class), 0, 4));
GeneralFeatureDetector<GrayF32, GrayF32> corner = FactoryDetectPoint.createShiTomasi(new ConfigGeneralDetector(-1, 2, 0), false, GrayF32.class);
ScoreAssociateHamming_B score = new ScoreAssociateHamming_B();
// use an association algorithm which uses the track's pose information
AssociateDescription2D<TupleDesc_B> association = new AssociateMaxDistanceNaive<>(score, true, 400, 20);
DescribeRegionPoint<GrayF32, TupleDesc_B> describe = new WrapDescribeBrief<>(brief, GrayF32.class);
EasyGeneralFeatureDetector<GrayF32, GrayF32> easy = new EasyGeneralFeatureDetector<>(corner, GrayF32.class, GrayF32.class);
DdaManagerGeneralPoint<GrayF32, GrayF32, TupleDesc_B> manager;
manager = new DdaManagerGeneralPoint<>(easy, describe, 2);
DetectDescribeAssociateTwoPass<GrayF32, TupleDesc_B> tracker = new DetectDescribeAssociateTwoPass<>(manager, association, association, false);
return tracker;
}
use of boofcv.abst.feature.detect.interest.ConfigGeneralDetector in project BoofCV by lessthanoptimal.
the class TestPointTrackerCombined method createTracker.
@Override
public PointTracker<GrayF32> createTracker() {
DescribePointBrief<GrayF32> brief = FactoryDescribePointAlgs.brief(FactoryBriefDefinition.gaussian2(new Random(123), 16, 512), FactoryBlurFilter.gaussian(ImageType.single(GrayF32.class), 0, 4));
GeneralFeatureDetector<GrayF32, GrayF32> corner = FactoryDetectPoint.createShiTomasi(new ConfigGeneralDetector(100, 2, 0), false, GrayF32.class);
InterestPointDetector<GrayF32> detector = FactoryInterestPoint.wrapPoint(corner, 1, GrayF32.class, GrayF32.class);
ScoreAssociateHamming_B score = new ScoreAssociateHamming_B();
AssociateDescription<TupleDesc_B> association = FactoryAssociation.greedy(score, 400, true);
PointTracker<GrayF32> pointTracker = FactoryPointTracker.combined(detector, null, new WrapDescribeBrief<>(brief, GrayF32.class), association, null, 20, GrayF32.class);
return pointTracker;
}
Aggregations