@Override public void translate(float x, float y) { for (final Point2d v : vertices) v.translate(x, y); }
@Override public void draw( final MBFImage vis, final int xoffset, final int yoffset, final PointList pl ) { for( final Point2d p : pl ) { final Point2d pp = new Point2dImpl( p ); p.translate( xoffset, yoffset ); vis.drawPoint( pp, RGBColour.RED, 2 ); } } };
private static void drawVectors(final FImage[] sequence, final Map<Point2d, Point2d> mv1) { final FImage fr = new FImage(sequence[0].width, sequence[0].height); for (final Entry<Point2d, Point2d> p : mv1.entrySet()) { final Point2d from = p.getKey(); final Point2d to = p.getValue().copy(); to.translate(from); if (!from.equals(to)) fr.drawLine(from, to, 1f); } DisplayUtilities.display(fr); } }
private static void drawVectors(final FImage[] sequence, final Map<Point2d, Point2d> mv1) { final FImage fr = new FImage(sequence[0].width, sequence[0].height); for (final Entry<Point2d, Point2d> p : mv1.entrySet()) { final Point2d from = p.getKey(); final Point2d to = p.getValue().copy(); to.translate(from); if (!from.equals(to)) fr.drawLine(from, to, 1f); } DisplayUtilities.display(fr); } }
for (final Entry<Point2d, Point2d> line : analysis.entrySet()) { final Point2d to = line.getKey().copy(); to.translate(line.getValue()); fImage.drawLine(line.getKey(), to, 1f); fImage.drawPoint(line.getKey(), 1f, 3);
for (final Entry<Point2d, Point2d> line : analysis.entrySet()) { final Point2d to = line.getKey().copy(); to.translate(line.getValue()); fImage.drawLine(line.getKey(), to, 1f); fImage.drawPoint(line.getKey(), 1f, 3);
public static void main(String[] args) throws IOException, InterruptedException { final FImage[] sequence = new FImage[3]; for (int i = 0; i < sequence.length; i++) { sequence[i] = ImageUtilities.readF(new File("/Users/jon/pendulum+circle/frame_" + (i + 10) + ".png")); } final MotionEstimatorAlgorithm.TEMPLATE_MATCH alg = new MotionEstimatorAlgorithm.TEMPLATE_MATCH(); final MotionEstimator e = new GridMotionEstimator(new ArrayBackedVideo<FImage>(sequence), alg, 10, 10, true); e.getNextFrame(); e.getNextFrame(); final Map<Point2d, Point2d> mv1 = e.getMotionVectors(); e.getNextFrame(); final Map<Point2d, Point2d> mv2 = e.getMotionVectors(); drawVectors(sequence, mv1); drawVectors(sequence, mv2); final Map<Point2d, Point2d> accel = new HashMap<Point2d, Point2d>(); for (final Entry<Point2d, Point2d> p : mv1.entrySet()) { final Point2d from = p.getKey(); final Point2d to = p.getValue().copy(); to.translate(from); final Point2d v1 = p.getValue(); Point2d v2 = mv2.get(to); if (v2 == null) v2 = new Point2dImpl(0, 0); final Point2d acc = v2.copy().minus(v1); accel.put(to, acc); } drawVectors(sequence, accel); }
public static void main(String[] args) throws IOException, InterruptedException { final FImage[] sequence = new FImage[3]; for (int i = 0; i < sequence.length; i++) { sequence[i] = ImageUtilities.readF(new File("/Users/jon/pendulum+circle/frame_" + (i + 10) + ".png")); } final MotionEstimatorAlgorithm.TEMPLATE_MATCH alg = new MotionEstimatorAlgorithm.TEMPLATE_MATCH(); final MotionEstimator e = new GridMotionEstimator(new ArrayBackedVideo<FImage>(sequence), alg, 10, 10, true); e.getNextFrame(); e.getNextFrame(); final Map<Point2d, Point2d> mv1 = e.getMotionVectors(); e.getNextFrame(); final Map<Point2d, Point2d> mv2 = e.getMotionVectors(); drawVectors(sequence, mv1); drawVectors(sequence, mv2); final Map<Point2d, Point2d> accel = new HashMap<Point2d, Point2d>(); for (final Entry<Point2d, Point2d> p : mv1.entrySet()) { final Point2d from = p.getKey(); final Point2d to = p.getValue().copy(); to.translate(from); final Point2d v1 = p.getValue(); Point2d v2 = mv2.get(to); if (v2 == null) v2 = new Point2dImpl(0, 0); final Point2d acc = v2.copy().minus(v1); accel.put(to, acc); } drawVectors(sequence, accel); }
/** * Apply the radial and tangential distortion of this camera to the given * projected point (presumably computed by projecting a world point through * the homography defined by the extrinsic parameters of a camera). The * point is modified in-place. * * @param p * the projected point * @return the input point (with the distortion added) */ public Point2d applyDistortion(Point2d p) { final double dx = (p.getX() - getPrincipalPointX()) / getFocalLengthX(); final double dy = (p.getY() - getPrincipalPointY()) / getFocalLengthY(); final double r2 = dx * dx + dy * dy; final double r4 = r2 * r2; final double r6 = r2 * r2 * r2; // radial component double tx = dx * (k1 * r2 + k2 * r4 + k3 * r6); double ty = dy * (k1 * r2 + k2 * r4 + k3 * r6); // tangential component tx += 2 * p1 * dx * dy + p2 * (r2 + 2 * dx * dx); ty += p1 * (r2 + 2 * dy * dy) + 2 * p2 * dx * dy; p.translate((float) tx, (float) ty); return p; }
@Override public synchronized void beforeUpdate(MBFImage frame) { List<? extends DetectedFace> faces = null; if (findKeypoints) { faces = engine .detectFaces(Transforms.calculateIntensityNTSC(frame)); } else { faces = innerEngine.detectFaces(Transforms .calculateIntensityNTSC(frame)); } if (faces.size() > 0) { Rectangle r = faces.get(0).getBounds(); ((HaarCascadeDetector) innerEngine) .setMinSize((int) (r.width * 0.9)); } else { ((HaarCascadeDetector) innerEngine).setMinSize(1); } for (DetectedFace face : faces) { final Shape bounds = face.getBounds(); MBFImageRenderer renderer = frame.createRenderer(); renderer.drawPolygon(bounds.asPolygon(), RGBColour.RED); if (findKeypoints) { for (FacialKeypoint kp : ((KEDetectedFace) face).getKeypoints()) { Point2d pt = kp.position.clone(); pt.translate((float) bounds.minX(), (float) bounds.minY()); renderer.drawPoint(pt, RGBColour.GREEN, 3); } } } }
@Override public synchronized void beforeUpdate(MBFImage frame) { List<? extends DetectedFace> faces = null; if (findKeypoints) { faces = engine .detectFaces(Transforms.calculateIntensityNTSC(frame)); } else { faces = innerEngine.detectFaces(Transforms .calculateIntensityNTSC(frame)); } if (faces.size() > 0) { Rectangle r = faces.get(0).getBounds(); ((HaarCascadeDetector) innerEngine) .setMinSize((int) (r.width * 0.9)); } else { ((HaarCascadeDetector) innerEngine).setMinSize(1); } for (DetectedFace face : faces) { final Shape bounds = face.getBounds(); MBFImageRenderer renderer = frame.createRenderer(); renderer.drawPolygon(bounds.asPolygon(), RGBColour.RED); if (findKeypoints) { for (FacialKeypoint kp : ((KEDetectedFace) face).getKeypoints()) { Point2d pt = kp.position.clone(); pt.translate((float) bounds.minX(), (float) bounds.minY()); renderer.drawPoint(pt, RGBColour.GREEN, 3); } } } }
pt.translate((float) transBounds.minX(), (float) transBounds.minY()); renderer.drawPoint(pt, RGBColour.GREEN, 3);
pt.translate((float) transBounds.minX(), (float) transBounds.minY()); renderer.drawPoint(pt, RGBColour.GREEN, 3);
textPoint.translate(paddingx, paddingy);