AddPolygon
Add a new Polygon region of interest (RoI) within an image.
Parameters
- image_ref: Reference to single image within the transaction (either the result of a FindImage or an AddImage), which will be used to create a connection to.
- polygons
- [optional] _ref: Reference to be used within the transaction.
- [optional] label
- [optional] properties
- [optional] if_not_found
- [optional] connect
Details
properties are key-value pairs associated with the entity. Check properties for more details.
if_not_found can be used to turn this command into "conditional add". Check if_not_found for more details.
connect can be used to create a connection between the added object and other object(s). Check connect for more details.
The image_ref parameter is a reference to a single Image object that will be connected to the created polygon automatically. If the reference points to multiple Image object, an error is returned.
polygons describes the boundaries of one or more
contiguous regions. If polygons
contains multiple regions, they must be
mutually disjoint.
Examples
Insert an Image and a Polygon object within that image:
[{
"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
}
}]
Insert an Image with a Polygon inside it, and connect the Polygon to an existing Entity of the class "Person" with a specific "name" property:
[{
"FindEntity": {
"_ref": 1,
"with_class": "Person",
"unique": true,
"constraints": {
"name": ["==", "John Doe"]
}
}
}, {
"AddImage": {
"_ref": 2,
"properties": {
"description": "person sitting"
}
}
}, {
"AddPolygon": {
"image_ref": 2,
"label": "Person",
"polygons": [
[
[526.77, 355.76],
[489.28, 355.76],
[476.28, 352.74],
[469.33, 343.66],
[473.86, 316.45],
[479.3, 310.41],
[480.21, 301.64],
[479.91, 292.57],
[476.88, 286.83],
[467.81, 292.57],
[464.19, 291.06],
[482.33, 275.94],
[504.7, 280.78],
[515.58, 287.13],
[542.49, 284.1],
[557.91, 273.52],
[539.47, 315.55],
[527.37, 355.15]
]
],
"properties": {
"label_id": 6
},
"connect": {
"ref": 1,
"class": "PersonInImage"
}
}
}]
Successful response:
[{
"FindEntity": {
"returned": 0,
"status": 0
}
}, {
"AddImage": {
"status": 0
}
}, {
"AddPolygon": {
"status": 0
}
}]