addBoundingBoxToImageById method
Add a bounding box to an image by ID, with x and y coordinates normalized from 0 to 1.
Returns the bounding box ID.
_viam = await Viam.withApiKey(
dotenv.env['API_KEY_ID'] ?? '',
dotenv.env['API_KEY'] ?? ''
);
final dataClient = _viam.dataClient;
// Example binary ID to add a bounding box to
final binaryDataId = '<YOUR-BINARY-DATA-ID>';
try {
await dataClient.addBoundingBoxToImageById(
"label",
binaryDataId,
0,
.1,
.2,
.3
);
print('Successfully added bounding box');
} catch (e) {
print('Error adding bounding box: $e');
}
For more information, see Data Client API.
Implementation
Future<String> addBoundingBoxToImageById(
String label, String binaryDataId, double xMinNormalized, double yMinNormalized, double xMaxNormalized, double yMaxNormalized) async {
final request = AddBoundingBoxToImageByIDRequest()
..label = label
..binaryDataId = binaryDataId
..xMinNormalized = xMinNormalized
..yMinNormalized = yMinNormalized
..xMaxNormalized = xMaxNormalized
..yMaxNormalized = yMaxNormalized;
final response = await _dataClient.addBoundingBoxToImageByID(request);
return response.bboxId;
}