Skip to content

Commit

Permalink
DOCS-3354: Add links for vision service methods (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
JessamyT authored Jan 14, 2025
1 parent 39930f8 commit 2d08a2d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/src/services/vision.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class VisionClient extends Resource implements ResourceRPCClient {
/// // Example:
/// var detections = await myVisionService.detectionsFromCamera('myWebcam');
/// ```
///
/// For more information, see the [vision service docs](https://docs.viam.com/dev/reference/apis/services/vision/#getdetectionsfromcamera).
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);
Expand All @@ -46,6 +48,7 @@ class VisionClient extends Resource implements ResourceRPCClient {
/// var latestImage = await myWebcam.image();
/// var detections = await myVisionService.detections(latestImage);
/// ```
/// For more information, see the [vision service docs](https://docs.viam.com/dev/reference/apis/services/vision/#getdetections).
Future<List<Detection>> detections(ViamImage image, {Map<String, dynamic>? extra}) async {
final request = GetDetectionsRequest(
name: name,
Expand All @@ -65,6 +68,8 @@ class VisionClient extends Resource implements ResourceRPCClient {
/// // Example:
/// var classifications = await myVisionService.classificationsFromCamera('myWebcam', 2);
/// ```
///
/// For more information, see the [vision service docs](https://docs.viam.com/dev/reference/apis/services/vision/#getclassificationsfromcamera).
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 @@ -79,6 +84,8 @@ class VisionClient extends Resource implements ResourceRPCClient {
/// var latestImage = await myWebcam.image();
/// var classifications = await myVisionService.classifications(latestImage, 2);
/// ```
///
/// For more information, see the [vision service docs](https://docs.viam.com/dev/reference/apis/services/vision/#getclassifications).
Future<List<Classification>> classifications(ViamImage image, int count, {Map<String, dynamic>? extra}) async {
final request = GetClassificationsRequest(
name: name,
Expand All @@ -98,6 +105,8 @@ class VisionClient extends Resource implements ResourceRPCClient {
/// // Example:
/// var ptCloud = await myVisionService.objectPointClouds('myCamera');
/// ```
///
/// For more information, see the [vision service docs](https://docs.viam.com/dev/reference/apis/services/vision/#getobjectpointclouds).
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 All @@ -114,6 +123,8 @@ class VisionClient extends Resource implements ResourceRPCClient {
/// properties.detections_supported // returns true
/// properties.classifications_supported // returns false
/// ```
///
/// For more information, see the [vision service docs](https://docs.viam.com/dev/reference/apis/services/vision/#getproperties).
Future<VisionProperties> properties({Map<String, dynamic>? extra}) async {
final request = GetPropertiesRequest(name: name, extra: extra?.toStruct());
return await client.getProperties(request);
Expand All @@ -129,11 +140,22 @@ class VisionClient extends Resource implements ResourceRPCClient {
}

/// Get the [ResourceName] for this [VisionClient] with the given [name]
///
/// ```
/// final myVisionServiceResourceName = myVisionService.getResourceName("my_vision_service");
/// ```
///
/// For more information, see the [vision service docs](https://docs.viam.com/dev/reference/apis/services/vision/#getresourcename).
static ResourceName getResourceName(String name) {
return VisionClient.subtype.getResourceName(name);
}

/// Get the [VisionClient] named [name] from the provided robot.
///
/// ```
/// final myVisionService = VisionService.fromRobot(myRobotClient, "my_vision_service");
/// ```
///
static VisionClient fromRobot(RobotClient robot, String name) {
return robot.getResource(VisionClient.getResourceName(name));
}
Expand Down

0 comments on commit 2d08a2d

Please sign in to comment.