22
33from viam .media .video import CameraMimeType , ViamImage
44from viam .proto .common import DoCommandRequest , DoCommandResponse
5- from viam .proto .component .camera import Image
5+ from viam .proto .component .camera import Format , Image
66from viam .proto .service .vision import (
77 CaptureAllFromCameraRequest ,
88 CaptureAllFromCameraResponse ,
@@ -36,7 +36,7 @@ class VisionRPCService(UnimplementedVisionServiceBase, ResourceRPCServiceBase):
3636 async def CaptureAllFromCamera (self , stream : Stream [CaptureAllFromCameraRequest , CaptureAllFromCameraResponse ]) -> None :
3737 request = await stream .recv_message ()
3838 assert request is not None
39- vision = self .get_resource (request .name )
39+ vision : Vision = self .get_resource (request .name )
4040 extra = struct_to_dict (request .extra )
4141 timeout = stream .deadline .time_remaining () if stream .deadline else None
4242 result = await vision .capture_all_from_camera (
@@ -50,9 +50,15 @@ async def CaptureAllFromCamera(self, stream: Stream[CaptureAllFromCameraRequest,
5050 )
5151 img = None
5252 if result .image is not None :
53- fmt = result .image .mime_type .to_proto ()
53+ # TODO(RSDK-11728): remove this try except logic once we deleted the format field
54+ try :
55+ mime_type = CameraMimeType .from_string (result .image .mime_type ) # this can ValueError if mime_type is not a CameraMimeType
56+ fmt = mime_type .to_proto ()
57+ except ValueError :
58+ mime_type = result .image .mime_type
59+ fmt = Format .FORMAT_UNSPECIFIED
5460 img_bytes = result .image .data
55- img = Image (source_name = request .camera_name , format = fmt , image = img_bytes )
61+ img = Image (source_name = request .camera_name , mime_type = result . image . mime_type , format = fmt , image = img_bytes )
5662 response = CaptureAllFromCameraResponse (
5763 image = img ,
5864 detections = result .detections ,
0 commit comments