@@ -3,7 +3,9 @@ import type { CallOptions, PromiseClient } from '@connectrpc/connect';
3
3
import { GetPropertiesRequest } from '../../gen/component/base/v1/base_pb' ;
4
4
import { CameraService } from '../../gen/component/camera/v1/camera_connect' ;
5
5
import {
6
+ Format ,
6
7
GetImageRequest ,
8
+ GetImagesRequest ,
7
9
GetPointCloudRequest ,
8
10
RenderFrameRequest ,
9
11
} from '../../gen/component/camera/v1/camera_pb' ;
@@ -15,6 +17,27 @@ import { GetGeometriesRequest } from '../../gen/common/v1/common_pb';
15
17
16
18
const PointCloudPCD : MimeType = 'pointcloud/pcd' ;
17
19
20
+ // TODO(RSDK-11729): remove helper and format field once removed from proto
21
+ const formatToMimeType = ( format : Format ) : MimeType => {
22
+ switch ( format ) {
23
+ case Format . RAW_RGBA : {
24
+ return 'image/vnd.viam.rgba' ;
25
+ }
26
+ case Format . JPEG : {
27
+ return 'image/jpeg' ;
28
+ }
29
+ case Format . PNG : {
30
+ return 'image/png' ;
31
+ }
32
+ case Format . RAW_DEPTH : {
33
+ return 'image/vnd.viam.depth' ;
34
+ }
35
+ case Format . UNSPECIFIED : {
36
+ return '' ;
37
+ }
38
+ }
39
+ }
40
+
18
41
/**
19
42
* A gRPC-web client for the Camera component.
20
43
*
@@ -59,6 +82,28 @@ export class CameraClient implements Camera {
59
82
return resp . image ;
60
83
}
61
84
85
+ async getImages (
86
+ filterSourceNames : string [ ] = [ ] ,
87
+ extra = { } ,
88
+ callOptions = this . callOptions
89
+ ) {
90
+ const request = new GetImagesRequest ( {
91
+ name : this . name ,
92
+ filterSourceNames,
93
+ extra : Struct . fromJson ( extra ) ,
94
+ } ) ;
95
+
96
+ this . options . requestLogger ?.( request ) ;
97
+
98
+ const resp = await this . client . getImages ( request , callOptions ) ;
99
+
100
+ return resp . images . map ( ( image ) => ( {
101
+ sourceName : image . sourceName ,
102
+ image : image . image ,
103
+ mimeType : image . mimeType || formatToMimeType ( image . format ) ,
104
+ } ) ) ;
105
+ }
106
+
62
107
async renderFrame (
63
108
mimeType : MimeType = '' ,
64
109
extra = { } ,
0 commit comments