public final class VisionPoint
- Object
- VisionPoint
Immutable point in a normalized, top-left-origin coordinate space. X grows right and Y grows down; 0 and 1 correspond to image edges, independent of source pixel dimensions.
toPoint(int, int, int, int) converts one back to pixels for
drawing:
public void paint(Graphics g) {
super.paint(g);
g.setColor(0xff3b30);
for (Face face : lastFaces) {
VisionPoint eye = face.getLandmark(FaceLandmarks.LEFT_EYE);
if (eye != null) {
Point p = eye.toPoint(this);
g.fillArc(p.getX() - 8, p.getY() - 8, 16, 16, 0, 360);
}
}
}
Constructors
public VisionPoint(float x, float y) | Creates a point in the oriented input image’s top-left coordinate space. |
Methods
public float getX() | |
public float getY() | |
public Point toPoint(int x, int y, int width, int height) | Maps this normalized point onto a pixel rectangle. |
public Point toPoint(Component target) | Maps this normalized point onto a component’s absolute on-screen bounds, which is the coordinate space a paint method draws in. |
Inherited methods
Constructor details
VisionPoint
public VisionPoint(float x, float y)Creates a point in the oriented input image’s top-left coordinate space.
Parameters
xfloat- horizontal coordinate
yfloat- vertical coordinate
Method details
getX
public float getX()Returns
horizontal coordinate normalized to the oriented input width
getY
public float getY()Returns
downward vertical coordinate normalized to input height
toPoint
public Point toPoint(int x, int y, int width, int height)Maps this normalized point onto a pixel rectangle.
The mapping stretches the whole 0..1 range across width and
height. That is correct when the destination has the same
aspect ratio as the analyzed image, which is the usual case for an
image drawn to fit. A live preview scaled with
ScaleType.CROP does not: pass the
rectangle the frame actually occupies rather than the component’s own
bounds.
Parameters
xint- left edge of the destination rectangle in pixels
yint- top edge of the destination rectangle in pixels
widthint- destination width in pixels
heightint- destination height in pixels
Returns
the corresponding pixel position, rounded to the nearest pixel
toPoint
public Point toPoint(Component target)Maps this normalized point onto a component’s absolute on-screen
bounds, which is the coordinate space a
paint method draws in.Parameters
targetComponent- component the analyzed image is displayed in
Returns
the corresponding absolute pixel position
Throws
NullPointerException- if
targetisnull