/** * Rotate the {@link Rectangle} about the given pivot with the given angle * (in radians) * * @param p * the pivot of the rotation * @param angle * the angle in radians * @return the rotated rectangle */ public RotatedRectangle rotate(Point2d p, double angle) { final Point2dImpl c = (Point2dImpl) this.calculateCentroid(); final float sin = (float) Math.sin(angle); final float cos = (float) Math.cos(angle); c.translate(-p.getX(), -p.getY()); final float xnew = c.x * cos - c.y * sin; final float ynew = c.x * sin + c.y * cos; c.x = xnew; c.y = ynew; c.translate(p); return new RotatedRectangle(c.x, c.y, width, height, angle); }
@Override public void renderOrtho(Matrix transform, int tx, int ty, MBFImage image) { final Point2dImpl p1 = projectOrtho(transform.times(pt1)); p1.translate(tx, ty); p1.y = image.getHeight() - p1.y; final Point2dImpl p2 = projectOrtho(transform.times(pt2)); p2.translate(tx, ty); p2.y = image.getHeight() - p2.y; image.drawLine(p1, p2, thickness, colour); }
@Override public void renderOrtho(Matrix transform, int tx, int ty, MBFImage image) { final Point2dImpl p1 = projectOrtho(transform.times(pt1)); p1.translate(tx, ty); p1.y = image.getHeight() - p1.y; final Point2dImpl p2 = projectOrtho(transform.times(pt2)); p2.translate(tx, ty); p2.y = image.getHeight() - p2.y; image.drawLine(p1, p2, thickness, colour); }
@Override public void doTutorial(MBFImage toDraw) { List<KEDetectedFace> faces = this.detector.detectFaces(toDraw.flatten()); for (KEDetectedFace detectedFace : faces) { Rectangle b = detectedFace.getBounds(); Point2dImpl bp = new Point2dImpl(b.x,b.y); toDraw.drawShape(b, RGBColour.RED); FacialKeypoint[] kpts = detectedFace.getKeypoints(); List<Point2d> fpts = new ArrayList<Point2d>(); for(FacialKeypoint kpt : kpts){ Point2dImpl p = kpt.position; p.translate(bp); fpts.add(p); } toDraw.drawPoints(fpts, RGBColour.GREEN, 3); } } }
@Override public void drawDetectedFace(MBFImage image, int thickness, KEDetectedFace f) { Rectangle bounds = f.getBounds(); image.drawShape(bounds,thickness, boundingBoxColour); FacialKeypoint[] kp = f.getKeypoints(); for (FacialKeypoint facialKeypoint : kp) { Point2dImpl position = facialKeypoint.position.clone(); position.translate(bounds.x, bounds.y); image.drawPoint(position,pointColour,thickness); } }
p.translate(c.transform(U.inverse())); px = (int) p.x; py = (int) p.y;
p.translate(c.transform(U.inverse())); px = (int) p.x; py = (int) p.y;