Skip to content

Commit 7059814

Browse files
authored
DOCS-2036: Add vision service example snippets (#232)
1 parent e5a7063 commit 7059814

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

lib/src/services/vision.dart

+28-1
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,24 @@ class VisionClient extends Resource implements ResourceRPCClient {
2323
VisionClient(this.name, this.channel);
2424

2525
/// Get a list of [Detection]s from the camera named [cameraName].
26+
///
27+
/// ```
28+
/// // Example:
29+
/// var detections = await myVisionService.detectionsFromCamera('myWebcam');
30+
/// ```
2631
Future<List<Detection>> detectionsFromCamera(String cameraName, {Map<String, dynamic>? extra}) async {
2732
final request = GetDetectionsFromCameraRequest(name: name, cameraName: cameraName, extra: extra?.toStruct());
2833
final response = await client.getDetectionsFromCamera(request);
2934
return response.detections;
3035
}
3136

32-
/// Get a list of [Detection]s from the provided [image].
37+
/// Get a list of [Detection]s from the provided [ViamImage].
38+
///
39+
/// ```
40+
/// // Example:
41+
/// var latestImage = await myWebcam.image();
42+
/// var detections = await myVisionService.detections(latestImage);
43+
/// ```
3344
Future<List<Detection>> detections(ViamImage image, {Map<String, dynamic>? extra}) async {
3445
final request = GetDetectionsRequest(
3546
name: name,
@@ -44,6 +55,11 @@ class VisionClient extends Resource implements ResourceRPCClient {
4455

4556
/// Get a list of [Classification]s from the camera named [cameraName].
4657
/// The maximum number of [Classification]s returned is [count].
58+
///
59+
/// ```
60+
/// // Example:
61+
/// var classifications = await myVisionService.classificationsFromCamera('myWebcam', 2);
62+
/// ```
4763
Future<List<Classification>> classificationsFromCamera(String cameraName, int count, {Map<String, dynamic>? extra}) async {
4864
final request = GetClassificationsFromCameraRequest(name: name, cameraName: cameraName, n: count, extra: extra?.toStruct());
4965
final response = await client.getClassificationsFromCamera(request);
@@ -52,6 +68,12 @@ class VisionClient extends Resource implements ResourceRPCClient {
5268

5369
/// Get a list of [Classification]s from the provided [image].
5470
/// The maximum number of [Classification]s returned is [count].
71+
///
72+
/// ```
73+
/// // Example:
74+
/// var latestImage = await myWebcam.image();
75+
/// var classifications = await myVisionService.classifications(latestImage, 2);
76+
/// ```
5577
Future<List<Classification>> classifications(ViamImage image, int count, {Map<String, dynamic>? extra}) async {
5678
final request = GetClassificationsRequest(
5779
name: name,
@@ -66,6 +88,11 @@ class VisionClient extends Resource implements ResourceRPCClient {
6688
}
6789

6890
/// Get a list of [PointCloudObject]s from the camera named [cameraName].
91+
///
92+
/// ```
93+
/// // Example:
94+
/// var ptCloud = await myVisionService.objectPointClouds('myCamera');
95+
/// ```
6996
Future<List<PointCloudObject>> objectPointClouds(String cameraName, {Map<String, dynamic>? extra}) async {
7097
final request = GetObjectPointCloudsRequest(name: name, cameraName: cameraName, mimeType: MimeType.pcd.name, extra: extra?.toStruct());
7198
final response = await client.getObjectPointClouds(request);

0 commit comments

Comments
 (0)