Skip to main content

polygons

The polygons parameter is used to describe the geometry of Polygon RoI, as follows:

[{
"AddImage": {
"_ref": 1,
"properties": {
"description": "dog playing in a park"
}
}
}, {
"AddPolygon": {
"image_ref": 1,
"label": "Dog",
"polygons": [
[
[387.99, 176.5],
[398.34, 164.68],
[405.73, 156.55],
[412.38, 141.77],
[419.77, 136.6],
[424.94, 125.51],
[432.33, 116.64],
[434.55, 102.6],
[436.77, 97.43],
[441.94, 102.6],
[453.76, 101.12],
[459.68, 109.99],
[457.46, 115.9],
[463.37, 124.03],
[470.76, 128.47],
[472.98, 137.34],
[465.59, 143.25],
[447.11, 137.34],
[444.9, 142.51],
[442.68, 156.55],
[444.9, 163.2],
[446.37, 176.5],
[444.9, 178.72]
]
],
"properties": {
"label_id": 32
}
}
}]

Successful response:

[{
"AddImage": {
"status": 0
}
}, {
"AddPolygon": {
"status": 0
}
}]

Each element of a "polygons" array is itself an array of (x,y) coordinates that describes a contiguous region. The polygon boundary is formed by drawing a straight edge between each consecutive pair of (x,y) vertices, and a final edge connecting the last and first vertices. A polygon region is all of the area enclosed by such a boundary. A single "polygons" parameter can include multiple disconnected regions.

polygon geometry

ApertureDB makes several assumptions about the geometry of a polygon. To be considered a valid polygon, the following conditions must all be met:

  • A polygon must not be empty. There must be some area inside the polygon. By extension, this means a polygon must have at least 3 vertices.
  • A polygon must be bounded. In other words, it must form a closed loop and can't extend indefinitely in any direction.
    • If the polygon is associated with an image, it also must be fully contained within the image.
  • A polygon boundary must not cross itself. In other words, if you were to walk along the polygon boundary, the inside of the polygon must always be on the same side of you.
    • Note that a polygon boundary may touch itself, as long as it doesn't cross. The polygon boundary can arrive at the same location twice, and even trace along itself, so long as it doesn't cross. This can be used, for example, to describe regions with "holes" in them.
  • Polygon vertex coordinate values must be in pixels. For example, the center of a 200 x 300 image has the coordinates (100.0, 150.0).