Class CameraSighting

java.lang.Object
org.horizon36596.simloop.vision.CameraSighting

public final class CameraSighting extends Object
One game piece as a SimCamera sees it this tick: where its centre lands in the image, how big it looks, how far away it is, and what it is. This is the ground truth a synthetic frame would be rendered from, and it is shaped to line up field-for-field with a typical per-frame detection record (centreXPx, centreYPx, radiusPx, clipped, type) so that a test can feed sightings into a tracker as if a detector had produced them, or compare a detector's output against them.

Pixel frame: (0, 0) top-left, +x right, +y down. Range is measured from the lens to the piece's centre, in inches.

Immutable.

  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the piece centre's image x, pixels from the left edge; may lie outside the image if clipped.
    double
    Returns the piece centre's image y, pixels from the top edge; may lie outside the image if clipped.
    Returns the piece's kind label, e.g. "ball" — the class a detector would have to infer.
    int
    Returns the id of the piece seen — ground truth a real detector never has.
    double
    The piece's apparent radius, pixels, computed as horizontal focal length times real radius over range.
    double
    Returns straight-line distance from the lens to the piece's centre, inches.
    double
    How much of the piece the camera can see past the occluders, 0 to 1: the share of sample rays spread over the piece's disc (as the camera sees it) that reach the piece without passing through a box or a nearer piece.
    boolean
    Returns true when part of the piece's disc falls outside the image edges.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • getPieceId

      public int getPieceId()
      Returns the id of the piece seen — ground truth a real detector never has.
      Returns:
      the id of the piece seen — ground truth a real detector never has
    • getKind

      public String getKind()
      Returns the piece's kind label, e.g. "ball" — the class a detector would have to infer.
      Returns:
      the piece's kind label, e.g. "ball" — the class a detector would have to infer
    • getCentreXPx

      public double getCentreXPx()
      Returns the piece centre's image x, pixels from the left edge; may lie outside the image if clipped.
      Returns:
      the piece centre's image x, pixels from the left edge; may lie outside the image if clipped
    • getCentreYPx

      public double getCentreYPx()
      Returns the piece centre's image y, pixels from the top edge; may lie outside the image if clipped.
      Returns:
      the piece centre's image y, pixels from the top edge; may lie outside the image if clipped
    • getRadiusPx

      public double getRadiusPx()
      The piece's apparent radius, pixels, computed as horizontal focal length times real radius over range.

      This is an approximation, and it is the one a simple synthetic renderer draws. A real sphere seen through a pinhole projects exactly to a circle only on the optical axis, and even there its image radius is f * radius / sqrt(range^2 - radius^2), about 1% larger than this at a range of 7 radii and less beyond. Off the axis the image becomes an ellipse stretched away from the image centre, by roughly 1 / cos of the angle off the axis (about 30% in the corner of a 70-degree-wide 640x400 image). A test that compares a detector's blob size with this number should allow for that.

      Returns:
      the apparent radius, pixels
    • getRangeInches

      public double getRangeInches()
      Returns straight-line distance from the lens to the piece's centre, inches.
      Returns:
      straight-line distance from the lens to the piece's centre, inches
    • isClipped

      public boolean isClipped()
      Returns true when part of the piece's disc falls outside the image edges.
      Returns:
      true when part of the piece's disc falls outside the image edges
    • getVisibleFraction

      public double getVisibleFraction()
      How much of the piece the camera can see past the occluders, 0 to 1: the share of sample rays spread over the piece's disc (as the camera sees it) that reach the piece without passing through a box or a nearer piece. Always 1 from SimCamera.observe(java.util.List, double, double, double), which has no occluders; from the overload that takes CameraOccluders it is the fraction of SimCamera.OCCLUSION_SAMPLES rays. The image edge does not count here: that is isClipped().
      Returns:
      the visible fraction, 0 to 1
    • toString

      public String toString()
      Overrides:
      toString in class Object