Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/examples/_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ async def TagsByFilter(self, stream: Stream[TagsByFilterRequest, TagsByFilterRes
async def AddBoundingBoxToImageByID(self, stream: Stream[AddBoundingBoxToImageByIDRequest, AddBoundingBoxToImageByIDResponse]) -> None:
pass

async def UpdateBoundingBoxToImageByID(self, stream: Stream[UpdateBoundingBoxRequest, UpdateBoundingBoxResponse]) -> None:
async def UpdateBoundingBox(self, stream: Stream[UpdateBoundingBoxRequest, UpdateBoundingBoxResponse]) -> None:
pass

async def RemoveBoundingBoxFromImageByID(
Expand Down
59 changes: 2 additions & 57 deletions src/viam/app/data_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
AddBinaryDataToDatasetByIDsRequest,
AddBoundingBoxToImageByIDRequest,
AddBoundingBoxToImageByIDResponse,
UpdateBoundingBoxRequest,
AddTagsToBinaryDataByFilterRequest,
AddTagsToBinaryDataByIDsRequest,
BinaryData,
Expand Down Expand Up @@ -1144,6 +1145,7 @@ async def add_bounding_box_to_image_by_id(
x_min_normalized=0,
y_min_normalized=.1,
x_max_normalized=.2,

y_max_normalized=.3,
confidence_score=.95
)
Expand Down Expand Up @@ -1193,63 +1195,6 @@ async def add_bounding_box_to_image_by_id(
response: AddBoundingBoxToImageByIDResponse = await self._data_client.AddBoundingBoxToImageByID(request, metadata=self._metadata)
return response.bbox_id

async def update_bounding_box_to_image_by_id(
self,
binary_id: str,
bbox_id: str,
label: str,
x_min_normalized: float,
y_min_normalized: float,
x_max_normalized: float,
y_max_normalized: float,
confidence_score: Optional[float] = None,
) -> None:
"""Update a bounding box in an image.

::

bbox_id = await data_client.update_bounding_box_to_image_by_id(
binary_id="<YOUR-BINARY-DATA-ID>",
bbox_id="2"
label="label",
x_min_normalized=0,
y_min_normalized=.1,
x_max_normalized=.2,
y_max_normalized=.3,
confidence_score=.95
)

Args:
binary_id (str): The binary data ID of the image to add the bounding
box to.
bbox_id (str): The ID of the bounding box to be updated
label (str): A label for the bounding box.
x_min_normalized (float): Min X value of the bounding box normalized from 0 to 1.
y_min_normalized (float): Min Y value of the bounding box normalized from 0 to 1.
x_max_normalized (float): Max X value of the bounding box normalized from 0 to 1.
y_max_normalized (float): Max Y value of the bounding box normalized from 0 to 1.
confidence_score (float): Confidence level of the bounding box being correct.

Raises:
GRPCError: If the X or Y values are outside of the [0, 1] range.

Returns:
N/A

For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#updateboundingboxtoimagebyid>`_.
"""
request = UpdateBoundingBoxRequest(
binary_data_id=binary_id,
bbox_id=bbox_id,
label=label,
x_max_normalized=x_max_normalized,
x_min_normalized=x_min_normalized,
y_max_normalized=y_max_normalized,
y_min_normalized=y_min_normalized,
confidence=confidence_score,
)
await self._data_client.UpdateBoundingBox(request, metadata=self._metadata)

async def remove_bounding_box_from_image_by_id(self, bbox_id: str, binary_id: Union[BinaryID, str]) -> None:
"""Removes a bounding box from an image.

Expand Down
2 changes: 2 additions & 0 deletions tests/mocks/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@
AddBoundingBoxToImageByIDRequest,
AddBoundingBoxToImageByIDResponse,
AddTagsToBinaryDataByFilterRequest,
UpdateBoundingBoxRequest,
UpdateBoundingBoxResponse,
AddTagsToBinaryDataByFilterResponse,
AddTagsToBinaryDataByIDsRequest,
AddTagsToBinaryDataByIDsResponse,
Expand Down
Loading