6767 TabularDataSourceType ,
6868 TagsByFilterRequest ,
6969 TagsByFilterResponse ,
70+ UpdateBoundingBoxRequest ,
7071)
7172from viam .proto .app .datapipelines import (
7273 CreateDataPipelineRequest ,
@@ -1131,6 +1132,7 @@ async def add_bounding_box_to_image_by_id(
11311132 y_min_normalized : float ,
11321133 x_max_normalized : float ,
11331134 y_max_normalized : float ,
1135+ confidence : Optional [float ] = None ,
11341136 ) -> str :
11351137 """Add a bounding box to an image.
11361138
@@ -1156,6 +1158,7 @@ async def add_bounding_box_to_image_by_id(
11561158 y_min_normalized (float): Min Y value of the bounding box normalized from 0 to 1.
11571159 x_max_normalized (float): Max X value of the bounding box normalized from 0 to 1.
11581160 y_max_normalized (float): Max Y value of the bounding box normalized from 0 to 1.
1161+ confidence (Optional[float]): The confidence score for the bounding box.
11591162
11601163 Raises:
11611164 GRPCError: If the X or Y values are outside of the [0, 1] range.
@@ -1174,6 +1177,7 @@ async def add_bounding_box_to_image_by_id(
11741177 x_min_normalized = x_min_normalized ,
11751178 y_max_normalized = y_max_normalized ,
11761179 y_min_normalized = y_min_normalized ,
1180+ confidence = confidence ,
11771181 )
11781182 else :
11791183 request = AddBoundingBoxToImageByIDRequest (
@@ -1183,6 +1187,7 @@ async def add_bounding_box_to_image_by_id(
11831187 x_min_normalized = x_min_normalized ,
11841188 y_max_normalized = y_max_normalized ,
11851189 y_min_normalized = y_min_normalized ,
1190+ confidence = confidence ,
11861191 )
11871192 response : AddBoundingBoxToImageByIDResponse = await self ._data_client .AddBoundingBoxToImageByID (request , metadata = self ._metadata )
11881193 return response .bbox_id
@@ -1535,6 +1540,7 @@ async def binary_data_capture_upload(
15351540 tags : Optional [List [str ]] = None ,
15361541 dataset_ids : Optional [List [str ]] = None ,
15371542 data_request_times : Optional [Tuple [datetime , datetime ]] = None ,
1543+ mime_type : Optional [str ] = None ,
15381544 ) -> str :
15391545 """Upload binary sensor data.
15401546
@@ -1573,6 +1579,7 @@ async def binary_data_capture_upload(
15731579 dataset_ids (Optional[List[str]]): Optional list of datasets to add the data to.
15741580 data_request_times (Optional[Tuple[datetime.datetime, datetime.datetime]]): Optional tuple containing datetime objects
15751581 denoting the times this data was requested ``[0]`` by the robot and received ``[1]`` from the appropriate sensor.
1582+ mime_type (Optional[str]): The MIME type of the file.
15761583
15771584 Raises:
15781585 GRPCError: If an invalid part ID is passed.
@@ -1603,6 +1610,7 @@ async def binary_data_capture_upload(
16031610 method_parameters = method_parameters ,
16041611 tags = tags ,
16051612 dataset_ids = dataset_ids ,
1613+ mime_type = mime_type if mime_type else "" ,
16061614 )
16071615 if file_extension :
16081616 metadata .file_extension = file_extension if file_extension [0 ] == "." else f".{ file_extension } "
@@ -1619,6 +1627,7 @@ async def tabular_data_capture_upload(
16191627 data_request_times : List [Tuple [datetime , datetime ]],
16201628 method_parameters : Optional [Mapping [str , Any ]] = None ,
16211629 tags : Optional [List [str ]] = None ,
1630+ mime_type : Optional [str ] = None ,
16221631 ) -> str :
16231632 """Upload tabular sensor data.
16241633
@@ -1658,6 +1667,7 @@ async def tabular_data_capture_upload(
16581667 Pass a list of tabular data and timestamps with length ``n > 1`` to upload ``n`` datapoints, all with the same metadata.
16591668 method_parameters (Optional[Mapping[str, Any]]): Optional dictionary of method parameters. No longer in active use.
16601669 tags (Optional[List[str]]): Optional list of tags to allow for tag-based data filtering when retrieving data.
1670+ mime_type (Optional[str]): The MIME type of the file.
16611671
16621672 Raises:
16631673 GRPCError: If an invalid part ID is passed.
@@ -1700,6 +1710,7 @@ async def tabular_data_capture_upload(
17001710 type = DataType .DATA_TYPE_TABULAR_SENSOR ,
17011711 method_parameters = method_parameters ,
17021712 tags = tags ,
1713+ mime_type = mime_type if mime_type else "" ,
17031714 )
17041715 response = await self ._data_capture_upload (metadata = metadata , sensor_contents = sensor_contents )
17051716 return response .file_id
@@ -1721,6 +1732,7 @@ async def streaming_data_capture_upload(
17211732 data_request_times : Optional [Tuple [datetime , datetime ]] = None ,
17221733 tags : Optional [List [str ]] = None ,
17231734 dataset_ids : Optional [List [str ]] = None ,
1735+ mime_type : Optional [str ] = None ,
17241736 ) -> str :
17251737 """Uploads the metadata and contents of streaming binary data.
17261738
@@ -1753,6 +1765,7 @@ async def streaming_data_capture_upload(
17531765 denoting the times this data was requested ``[0]`` by the robot and received ``[1]`` from the appropriate sensor.
17541766 tags (Optional[List[str]]): Optional list of tags to allow for tag-based filtering when retrieving data.
17551767 dataset_ids (Optional[List[str]]): Optional list of datasets to add the data to.
1768+ mime_type (Optional[str]): The MIME type of the file.
17561769
17571770 Raises:
17581771 GRPCError: If an invalid part ID is passed.
@@ -1773,6 +1786,7 @@ async def streaming_data_capture_upload(
17731786 file_extension = file_ext if file_ext [0 ] == "." else f".{ file_ext } " ,
17741787 tags = tags ,
17751788 dataset_ids = dataset_ids ,
1789+ mime_type = mime_type if mime_type else "" ,
17761790 )
17771791 sensor_metadata = SensorMetadata (
17781792 time_requested = datetime_to_timestamp (data_request_times [0 ]) if data_request_times else None ,
@@ -1802,6 +1816,7 @@ async def file_upload(
18021816 file_extension : Optional [str ] = None ,
18031817 tags : Optional [List [str ]] = None ,
18041818 dataset_ids : Optional [List [str ]] = None ,
1819+ mime_type : Optional [str ] = None ,
18051820 ) -> str :
18061821 """Upload arbitrary file data.
18071822
@@ -1832,6 +1847,7 @@ async def file_upload(
18321847 isn't provided. Files with a ``.jpeg``, ``.jpg``, or ``.png`` extension will be saved to the **Images** tab.
18331848 tags (Optional[List[str]]): Optional list of tags to allow for tag-based filtering when retrieving data.
18341849 dataset_ids (Optional[List[str]]): Optional list of datasets to add the data to.
1850+ mime_type (Optional[str]): The MIME type of the file.
18351851
18361852 Raises:
18371853 GRPCError: If an invalid part ID is passed.
@@ -1852,6 +1868,7 @@ async def file_upload(
18521868 file_extension = file_extension if file_extension else "" ,
18531869 tags = tags ,
18541870 dataset_ids = dataset_ids ,
1871+ mime_type = mime_type if mime_type else "" ,
18551872 )
18561873 response : FileUploadResponse = await self ._file_upload (metadata = metadata , file_contents = FileData (data = data ))
18571874 return response .binary_data_id
@@ -1866,6 +1883,7 @@ async def file_upload_from_path(
18661883 method_parameters : Optional [Mapping [str , Any ]] = None ,
18671884 tags : Optional [List [str ]] = None ,
18681885 dataset_ids : Optional [List [str ]] = None ,
1886+ mime_type : Optional [str ] = None ,
18691887 ) -> str :
18701888 """Upload arbitrary file data.
18711889
@@ -1890,6 +1908,7 @@ async def file_upload_from_path(
18901908 method_parameters (Optional[str]): Optional dictionary of the method parameters. No longer in active use.
18911909 tags (Optional[List[str]]): Optional list of tags to allow for tag-based filtering when retrieving data.
18921910 dataset_ids (Optional[List[str]]): Optional list of datasets to add the data to.
1911+ mime_type (Optional[str]): The MIME type of the file.
18931912
18941913 Raises:
18951914 GRPCError: If an invalid part ID is passed.
@@ -1917,6 +1936,7 @@ async def file_upload_from_path(
19171936 file_extension = file_extension if file_extension else "" ,
19181937 tags = tags ,
19191938 dataset_ids = dataset_ids ,
1939+ mime_type = mime_type if mime_type else "" ,
19201940 )
19211941 response : FileUploadResponse = await self ._file_upload (metadata = metadata , file_contents = FileData (data = data if data else bytes ()))
19221942 return response .binary_data_id
@@ -2229,3 +2249,67 @@ def create_filter(
22292249 bbox_labels ,
22302250 dataset_id ,
22312251 )
2252+
2253+ async def update_bounding_box (
2254+ self ,
2255+ binary_id : Union [BinaryID , str ],
2256+ bbox_id : str ,
2257+ label : Optional [str ] = None ,
2258+ x_min_normalized : Optional [float ] = None ,
2259+ y_min_normalized : Optional [float ] = None ,
2260+ x_max_normalized : Optional [float ] = None ,
2261+ y_max_normalized : Optional [float ] = None ,
2262+ confidence : Optional [float ] = None ,
2263+ ) -> None :
2264+ """Updates a bounding box in an image.
2265+
2266+ ::
2267+
2268+ await data_client.update_bounding_box(
2269+ binary_id="<YOUR-BINARY-DATA-ID>",
2270+ bbox_id="your-bounding-box-id-to-update",
2271+ label="new-label",
2272+ x_min_normalized=0.1,
2273+ y_min_normalized=0.1,
2274+ x_max_normalized=0.3,
2275+ y_max_normalized=0.3,
2276+ confidence=0.9
2277+ )
2278+
2279+ Args:
2280+ binary_id (Union[~viam.proto.app.data.BinaryID, str]): The binary data ID or :class:`BinaryID` of the image containing the bounding
2281+ box to update. *DEPRECATED:* :class:`BinaryID` *is deprecated and will be removed in a future release. Instead, pass binary data IDs as a
2282+ list of strings.*
2283+ bbox_id (str): The ID of the bounding box to update.
2284+ label (Optional[str]): The new label for the bounding box.
2285+ x_min_normalized (Optional[float]): New min X value of the bounding box normalized from 0 to 1.
2286+ y_min_normalized (Optional[float]): New min Y value of the bounding box normalized from 0 to 1.
2287+ x_max_normalized (Optional[float]): New max X value of the bounding box normalized from 0 to 1.
2288+ y_max_normalized (Optional[float]): New max Y value of the bounding box normalized from 0 to 1.
2289+ confidence (Optional[float]): The new confidence score for the bounding box.
2290+
2291+ Raises:
2292+ GRPCError: If the X or Y values are outside of the [0, 1] range.
2293+
2294+ For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#updateboundingbox>`_.
2295+ """
2296+ request = UpdateBoundingBoxRequest (bbox_id = bbox_id )
2297+ if isinstance (binary_id , str ):
2298+ request .binary_data_id = binary_id
2299+ else :
2300+ request .binary_id = binary_id
2301+
2302+ if label is not None :
2303+ request .label = label
2304+ if x_min_normalized is not None :
2305+ request .x_min_normalized = x_min_normalized
2306+ if y_min_normalized is not None :
2307+ request .y_min_normalized = y_min_normalized
2308+ if x_max_normalized is not None :
2309+ request .x_max_normalized = x_max_normalized
2310+ if y_max_normalized is not None :
2311+ request .y_max_normalized = y_max_normalized
2312+ if confidence is not None :
2313+ request .confidence = confidence
2314+
2315+ await self ._data_client .UpdateBoundingBox (request , metadata = self ._metadata )
0 commit comments