Skip to main content

AddBoundingBox

Add a new Bounding Box and properties associated with it.

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.
  • rectangle
  • [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 bounding box automatically. If the reference points to multiple Image object, an error is returned.

A rectangle parameter is required, as it indicates the boundaries of the bounding box.

Examples

Insert an Image, re-encoding it as a "png", and 2 BoundingBox objects, and create a connection between the 2 BoundingBox objects and the Image:


[{
"AddImage": {
"_ref": 1,
"format": "png",
"properties": {
"description": "dog playing in a park"
}
}
}, {
"AddBoundingBox": {
"image_ref": 1,
"label": "Dog",
"rectangle": {
"x": 120,
"y": 50,
"width": 40,
"height": 40
},
"properties": {
"label_id": 32
}
}
}, {
"AddBoundingBox": {
"image_ref": 1,
"label": "Park",
"rectangle": {
"x": 10,
"y": 20,
"width": 400,
"height": 400
},
"properties": {
"label_id": 6
}
}
}]

Successful response:


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

Insert an Image and a BoundingBox, and create a connection between the 2 objects, and connect the BoundingBox to an existing Entity of the class "Person" with a specific "unique_id" property:


[{
"FindEntity": {
"_ref": 1,
"with_class": "Person",
"unique": true,
"constraints": {
"unique_id": ["==", 2341]
}
}
}, {
"AddImage": {
"_ref": 2,
"properties": {
"description": "dog playing in a park"
}
}
}, {
"AddBoundingBox": {
"image_ref": 2,
"label": "Dog",
"rectangle": {
"x": 120,
"y": 50,
"width": 40,
"height": 40
},
"properties": {
"label_id": 32
},
"connect": {
"ref": 1,
"class": "PersonInImage"
}
}
}]

Successful response:


[{
"FindEntity": {
"returned": 0,
"status": 0
}
}, {
"AddImage": {
"status": 0
}
}, {
"AddBoundingBox": {
"status": 0
}
}]