diff --git a/services/datamanager/data_manager.go b/services/datamanager/data_manager.go index bc8d92e37d0..c85e4d48e9e 100644 --- a/services/datamanager/data_manager.go +++ b/services/datamanager/data_manager.go @@ -31,8 +31,14 @@ func init() { } // Service defines what a Data Manager Service should expose to the users. +// +// Sync example: +// +// // Sync data stored on the machine to the cloud. +// err := data.Sync(context.Background(), nil) type Service interface { resource.Resource + // Sync will sync data stored on the machine to the cloud. Sync(ctx context.Context, extra map[string]interface{}) error } diff --git a/services/mlmodel/mlmodel.go b/services/mlmodel/mlmodel.go index 870ec4221ad..08e994131ab 100644 --- a/services/mlmodel/mlmodel.go +++ b/services/mlmodel/mlmodel.go @@ -28,6 +28,16 @@ func init() { // Service defines the ML Model interface, which takes a map of inputs, runs it through // an inference engine, and creates a map of outputs. Metadata is necessary in order to build // the struct that will decode that map[string]interface{} correctly. +// +// Infer example: +// +// input_tensors := ml.Tensors{"0": tensor.New(tensor.WithShape(1, 2, 3), tensor.WithBacking(6))} +// +// output_tensors, err := myMLModel.Infer(context.Background(), input_tensors) +// +// Metadata example: +// +// metadata, err := myMLModel.Metadata(context.Background()) type Service interface { resource.Resource Infer(ctx context.Context, tensors ml.Tensors) (ml.Tensors, error) diff --git a/services/vision/vision.go b/services/vision/vision.go index 9efbe4ba59a..4195f10fe68 100644 --- a/services/vision/vision.go +++ b/services/vision/vision.go @@ -29,24 +29,104 @@ func init() { } // A Service that implements various computer vision algorithms like detection and segmentation. +// +// DetectionsFromCamera example: +// +// // Get detections from the camera output +// detections, err := visService.DetectionsFromCamera(context.Background(), myCam, nil) +// if err != nil { +// logger.Fatalf("Could not get detections: %v", err) +// } +// if len(detections) > 0 { +// logger.Info(detections[0]) +// } +// +// Detections example: +// +// // Get the stream from a camera +// camStream, err := myCam.Stream(context.Background()) +// +// // Get an image from the camera stream +// img, release, err := camStream.Next(context.Background()) +// defer release() +// +// // Get the detections from the image +// detections, err := visService.Detections(context.Background(), img, nil) +// if err != nil { +// logger.Fatalf("Could not get detections: %v", err) +// } +// if len(detections) > 0 { +// logger.Info(detections[0]) +// } +// +// ClassificationsFromCamera example: +// +// // Get the 2 classifications with the highest confidence scores from the camera output +// classifications, err := visService.ClassificationsFromCamera(context.Background(), myCam, 2, nil) +// if err != nil { +// logger.Fatalf("Could not get classifications: %v", err) +// } +// if len(classifications) > 0 { +// logger.Info(classifications[0]) +// } +// +// Classifications example: +// +// // Get the stream from a camera +// camStream, err := myCam.Stream(context.Background()) +// if err!=nil { +// logger.Error(err) +// return +// } +// +// // Get an image from the camera stream +// img, release, err := camStream.Next(context.Background()) +// defer release() +// +// // Get the 2 classifications with the highest confidence scores from the image +// classifications, err := visService.Classifications(context.Background(), img, 2, nil) +// if err != nil { +// logger.Fatalf("Could not get classifications: %v", err) +// } +// if len(classifications) > 0 { +// logger.Info(classifications[0]) +// } +// +// GetObjectPointClouds example: +// +// // Get the objects from the camera output +// objects, err := visService.GetObjectPointClouds(context.Background(), "cam1", nil) +// if err != nil { +// logger.Fatalf("Could not get point clouds: %v", err) +// } +// if len(objects) > 0 { +// logger.Info(objects[0]) +// } type Service interface { resource.Resource + // DetectionsFromCamera returns a list of detections from the next image from a specified camera using a configured detector. DetectionsFromCamera(ctx context.Context, cameraName string, extra map[string]interface{}) ([]objectdetection.Detection, error) + + // Detections returns a list of detections from a given image using a configured detector. Detections(ctx context.Context, img image.Image, extra map[string]interface{}) ([]objectdetection.Detection, error) - // classifier methods + + // ClassificationsFromCamera returns a list of classifications from the next image from a specified camera using a configured classifier. ClassificationsFromCamera( ctx context.Context, cameraName string, n int, extra map[string]interface{}, ) (classification.Classifications, error) + + // Classifications returns a list of classifications from a given image using a configured classifier. Classifications( ctx context.Context, img image.Image, n int, extra map[string]interface{}, ) (classification.Classifications, error) - // segmenter methods + + // GetObjectPointClouds returns a list of 3D point cloud objects and associated metadata in the latest picture from a 3D camera (using a specified segmenter). GetObjectPointClouds(ctx context.Context, cameraName string, extra map[string]interface{}) ([]*viz.Object, error) }