Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCS-3354: Add links for vision service methods #327

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading