/** * Processes the video data and displays it in a Bitmap image. The bitmap is automatically scaled * and translated into the display's center by {@link VideoActivity}. Locking of data structures is * all handled by the parent. * * @author Peter Abeles */ public class ShowGradient extends VideoImageProcessing<GrayU8> { // Storage for the gradient private GrayS16 derivX = new GrayS16(1, 1); private GrayS16 derivY = new GrayS16(1, 1); // computes the image gradient private ImageGradient<GrayU8, GrayS16> gradient = FactoryDerivative.three(GrayU8.class, GrayS16.class); protected ShowGradient() { super(ImageType.single(GrayU8.class)); } @Override protected void declareImages(int width, int height) { // You must call the super or else it will crash horribly super.declareImages(width, height); derivX.reshape(width, height); derivY.reshape(width, height); } @Override protected void process(GrayU8 gray, Bitmap output, byte[] storage) { gradient.process(gray, derivX, derivY); VisualizeImageData.colorizeGradient(derivX, derivY, -1, output, storage); } }
protected void checkMotion(double tranX, double tranY, double rot) { ImageUInt8 frame0 = new ImageUInt8(320, 240); ImageUInt8 frame1 = new ImageUInt8(320, 240); ImageMiscOps.fillUniform(frame0, rand, 0, 256); double c = Math.cos(rot); double s = Math.sin(rot); DistortImageOps.affine(frame0, frame1, TypeInterpolate.BILINEAR, c, -s, s, c, tranX, tranY); SfotConfig config = new SfotConfig(); ImageGradient<ImageUInt8, ImageSInt16> gradient = FactoryDerivative.sobel(ImageUInt8.class, ImageSInt16.class); SparseFlowObjectTracker<ImageUInt8, ImageSInt16> alg = new SparseFlowObjectTracker<ImageUInt8, ImageSInt16>( config, ImageUInt8.class, ImageSInt16.class, gradient); RectangleRotate_F64 region0 = new RectangleRotate_F64(120, 140, 30, 40, 0.1); RectangleRotate_F64 region1 = new RectangleRotate_F64(); alg.init(frame0, region0); assertTrue(alg.update(frame1, region1)); double expectedX = c * region0.cx - s * region0.cy + tranX; double expectedY = s * region0.cx + c * region0.cy + tranY; double expectedYaw = UtilAngle.bound(region0.theta + rot); assertEquals(expectedX, region1.cx, 0.5); assertEquals(expectedY, region1.cy, 0.5); assertEquals(expectedYaw, region1.theta, 0.01); }
public static void evaluate(String dataset) { Class type = ImageFloat32.class; DebugTldTrackerTldData generator = new DebugTldTrackerTldData(ImageType.single(type)); InterpolatePixelS interpolate = FactoryInterpolation.bilinearPixelS(type, BorderType.EXTENDED); ImageGradient gradient = FactoryDerivative.sobel(type, type); TldTracker tracker = new TldTracker(null, interpolate, gradient, type, type); generator.evaluate(dataset, tracker); }
public WrapFusedKltTracker( InterestPointDetector<I> detector, PyramidKltForCombined<I, D> tracker, Class<I> imageType) { this.detector = detector; this.tracker = tracker; derivType = GImageDerivativeOps.getDerivativeType(imageType); gradient = FactoryDerivative.sobel(imageType, derivType); int pyramidScaling[] = tracker.pyramidScaling; pyramid = FactoryPyramid.discreteGaussian(pyramidScaling, -1, 2, true, imageType); }