Skip to content

Commit

Permalink
DOCS-3196: Update vision docs for camera interface update (#4717)
Browse files Browse the repository at this point in the history
  • Loading branch information
sguequierre authored Jan 17, 2025
1 parent 8222d44 commit 4f2b707
Showing 1 changed file with 42 additions and 48 deletions.
90 changes: 42 additions & 48 deletions services/vision/vision.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,29 @@ func init() {
//
// Detections example:
//
// myCam, err := camera.FromRobot(machine, "my_camera")
// if err != nil {
// logger.Error(err)
// return
// }
// // 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()
// // add "go.viam.com/rdk/utils" to imports to use this code snippet
//
// myDetectorService, err := vision.FromRobot(machine, "my_detector")
// if err != nil {
// logger.Error(err)
// return
// }
// // Get the detections from the image
// detections, err := myDetectorService.Detections(context.Background(), img, nil)
// if err != nil {
// logger.Fatalf("Could not get detections: %v", err)
// }
// if len(detections) > 0 {
// logger.Info(detections[0])
// }
// myCam, err := camera.FromRobot(machine, "my_camera")
// if err != nil {
// logger.Error(err)
// return
// }
// // Get an image from the camera decoded as an image.Image
// img, err = camera.DecodeImageFromCamera(context.Background(), utils.MimeTypeJPEG, nil, myCam)
//
// myDetectorService, err := vision.FromRobot(machine, "my_detector")
// if err != nil {
// logger.Error(err)
// return
// }
// // Get the detections from the image
// detections, err := myDetectorService.Detections(context.Background(), img, nil)
// if err != nil {
// logger.Fatalf("Could not get detections: %v", err)
// }
// if len(detections) > 0 {
// logger.Info(detections[0])
// }
//
// For more information, see the [Detections method docs].
//
Expand All @@ -108,34 +107,29 @@ func init() {
//
// Classifications example:
//
// myCam, err := camera.FromRobot(machine, "my_camera")
// if err != nil {
// logger.Error(err)
// return
// }
// // Get the stream from a camera
// camStream, err := myCam.Stream(context.Background())
// if err!=nil {
// // add "go.viam.com/rdk/utils" to imports to use this code snippet
//
// myCam, err := camera.FromRobot(machine, "my_camera")
// if err != nil {
// logger.Error(err)
// return
// }
// // Get an image from the camera stream
// img, release, err := camStream.Next(context.Background())
// defer release()
// }
// // Get an image from the camera decoded as an image.Image
// img, err = camera.DecodeImageFromCamera(context.Background(), utils.MimeTypeJPEG, nil, myCam)
//
// myClassifierService, err := vision.FromRobot(machine, "my_classifier")
// if err != nil {
// logger.Error(err)
// return
// }
// // Get the 2 classifications with the highest confidence scores from the image
// classifications, err := myClassifierService.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])
// }
// myClassifierService, err := vision.FromRobot(machine, "my_classifier")
// if err != nil {
// logger.Error(err)
// return
// }
// // Get the 2 classifications with the highest confidence scores from the image
// classifications, err := myClassifierService.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])
// }
//
// For more information, see the [Classifications method docs].
//
Expand Down

0 comments on commit 4f2b707

Please sign in to comment.