Skip to content

Commit bdf14e4

Browse files
committed
Keep format
1 parent dc6b22f commit bdf14e4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/viam/components/camera/service.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from viam.proto.common import DoCommandRequest, DoCommandResponse, GetGeometriesRequest, GetGeometriesResponse
77
from viam.proto.component.camera import (
88
CameraServiceBase,
9+
Format,
910
GetImageRequest,
1011
GetImageResponse,
1112
GetImagesRequest,
@@ -19,6 +20,7 @@
1920
)
2021
from viam.resource.rpc_service_base import ResourceRPCServiceBase
2122
from viam.utils import dict_to_struct, struct_to_dict
23+
from viam.media.video import CameraMimeType
2224

2325
from . import Camera
2426

@@ -56,8 +58,14 @@ async def GetImages(self, stream: Stream[GetImagesRequest, GetImagesResponse]) -
5658
)
5759
img_bytes_lst = []
5860
for img in images:
61+
mime_type = CameraMimeType.from_string(img.mime_type)
62+
if isinstance(mime_type, CameraMimeType):
63+
fmt = mime_type.to_proto()
64+
else:
65+
fmt = Format.FORMAT_UNSPECIFIED
66+
5967
img_bytes = img.data
60-
img_bytes_lst.append(Image(source_name=name, mime_type=img.mime_type, image=img_bytes))
68+
img_bytes_lst.append(Image(source_name=name, mime_type=img.mime_type, format=fmt, image=img_bytes))
6169
response = GetImagesResponse(images=img_bytes_lst, response_metadata=metadata)
6270
await stream.send_message(response)
6371

0 commit comments

Comments
 (0)