@Test public void initialLearning() { DummyVariance variance = new DummyVariance(); DummyFern fern = new DummyFern(); DummyTemplate template = new DummyTemplate(); DummyDetection detection = new DummyDetection(); TldLearning alg = new TldLearning(rand, config, template, variance, fern, detection); FastQueue<ImageRectangle> regions = new FastQueue<ImageRectangle>(ImageRectangle.class, true); regions.grow(); regions.grow(); regions.grow(); alg.initialLearning(new RectangleCorner2D_F64(10, 20, 30, 40), regions); // Check to see if the variance threshold was set assertEquals(1, variance.calledSelect); // There should be a positive example assertEquals(1, fern.calledP); assertEquals(1, template.calledP); // several negative examples too assertEquals(3, fern.calledN); // only negative template for ambiguous, which there are none since I'm being lazy assertEquals(0, template.calledN); assertEquals(1, detection.calledDetection); }
/** * Starts tracking the rectangular region. * * @param image First image in the sequence. * @param x0 Top-left corner of rectangle. x-axis * @param y0 Top-left corner of rectangle. y-axis * @param x1 Bottom-right corner of rectangle. x-axis * @param y1 Bottom-right corner of rectangle. y-axis */ public void initialize(T image, int x0, int y0, int x1, int y1) { if (imagePyramid == null || imagePyramid.getInputWidth() != image.width || imagePyramid.getInputHeight() != image.height) { int minSize = (config.trackerFeatureRadius * 2 + 1) * 5; int scales[] = selectPyramidScale(image.width, image.height, minSize); imagePyramid = FactoryPyramid.discreteGaussian(scales, -1, 1, true, (Class<T>) image.getClass()); } imagePyramid.process(image); reacquiring = false; targetRegion.set(x0, y0, x1, y1); createCascadeRegion(image.width, image.height); template.reset(); fern.reset(); tracking.initialize(imagePyramid); variance.setImage(image); template.setImage(image); fern.setImage(image); adjustRegion.init(image.width, image.height); learning.initialLearning(targetRegion, cascadeRegions); strongMatch = true; previousTrackArea = targetRegion.area(); }