Skip to content

Commit

Permalink
DOCS-2036: Add vision service example snippets (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
JessamyT authored Jun 17, 2024
1 parent e5a7063 commit 7059814
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion lib/src/services/vision.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,24 @@ class VisionClient extends Resource implements ResourceRPCClient {
VisionClient(this.name, this.channel);

/// Get a list of [Detection]s from the camera named [cameraName].
///
/// ```
/// // Example:
/// var detections = await myVisionService.detectionsFromCamera('myWebcam');
/// ```
Future<List<Detection>> detectionsFromCamera(String cameraName, {Map<String, dynamic>? extra}) async {
final request = GetDetectionsFromCameraRequest(name: name, cameraName: cameraName, extra: extra?.toStruct());
final response = await client.getDetectionsFromCamera(request);
return response.detections;
}

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

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

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

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

0 comments on commit 7059814

Please sign in to comment.