Class VisionPoint
java.lang.Object
com.codename1.ai.vision.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);
}
}
}
-
Constructor Summary
ConstructorsConstructorDescriptionVisionPoint(float x, float y) Creates a point in the oriented input image's top-left coordinate space. -
Method Summary
-
Constructor Details
-
VisionPoint
public VisionPoint(float x, float y) Creates a point in the oriented input image's top-left coordinate space.- Parameters:
x- horizontal coordinatey- 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
Maps this normalized point onto a pixel rectangle.
The mapping stretches the whole 0..1 range across
widthandheight. 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 withScaleType.CROPdoes not: pass the rectangle the frame actually occupies rather than the component's own bounds.- Parameters:
x- left edge of the destination rectangle in pixelsy- top edge of the destination rectangle in pixelswidth- destination width in pixelsheight- destination height in pixels- Returns:
- the corresponding pixel position, rounded to the nearest pixel
-
toPoint
Maps this normalized point onto a component's absolute on-screen bounds, which is the coordinate space apaintmethod draws in.- Parameters:
target- component the analyzed image is displayed in- Returns:
- the corresponding absolute pixel position
- Throws:
NullPointerException- iftargetisnull
-