Skip to main content

PolygonDataCSV

PolygonDataCSV Objects

class PolygonDataCSV(CSVParser.CSVParser)

ApertureDB Polygon Data.

This class loads the Polygon Data which is present in a CSV file, and converts it into a series of ApertureDB queries.

Is backed by a CSV file with the following columns:

IMG_KEY, [POLYGON_PROPERTY_1, ... POLYGON_PROPERTY_N,][``constraint_POLYGON_PROPERTY_1``, ... ``constraint_POLYGON_PROPERTY_N``,] [_label,] polygons

IMG_KEY: identifies the name of the image property that will identify the image with which to associate each polygon object. This property should reliably identify at most a single image, like a unique id. The value in each row will be used to look up the image to which the polygon will attach.

POLYGON_PROPERTY_I: declares the name of a property that will be assigned to all polygon objects. Any number of properties can be declared in this way.

constraint_POLYGON_PROPERTY_I: declares that POLYGON_PROPERTY_I should be unique, and that a new polygon will not be added if there already exists one with the same value for this property. For each row, the value in this column should match the value in column POLYGON_PROPERTY_I.

_label: optionally applies a label to the polygon objects.

polygons: a JSON array of polygon regions. Each polygon region is itself an array of [x,y] vertices that describe the boundary of a single contiguous polygon. See also Polygon API parameter.

Example CSV file::

image_id,polygon_id,constraint_polygon_id,category_id,_label,polygons
397133,82445,82445,44,bottle,"[[[224.24, 297.18], [228.29, 297.18], ...]]"
397133,119568,119568,67,dining table,"[[[292.37, 425.1], [340.6, 373.86], ...]]"
...

Example usage:


data = PolygonDataCSV("/path/to/PolygonData.csv")
loader = ParallelLoader(db)
loader.ingest(data)