@@ -61,30 +61,29 @@ func init() {
61
61
//
62
62
// Detections example:
63
63
//
64
- // myCam, err := camera.FromRobot(machine, "my_camera")
65
- // if err != nil {
66
- // logger.Error(err)
67
- // return
68
- // }
69
- // // Get the stream from a camera
70
- // camStream, err := myCam.Stream(context.Background())
71
- // // Get an image from the camera stream
72
- // img, release, err := camStream.Next(context.Background())
73
- // defer release()
64
+ // // add "go.viam.com/rdk/utils" to imports to use this code snippet
74
65
//
75
- // myDetectorService, err := vision.FromRobot(machine, "my_detector")
76
- // if err != nil {
77
- // logger.Error(err)
78
- // return
79
- // }
80
- // // Get the detections from the image
81
- // detections, err := myDetectorService.Detections(context.Background(), img, nil)
82
- // if err != nil {
83
- // logger.Fatalf("Could not get detections: %v", err)
84
- // }
85
- // if len(detections) > 0 {
86
- // logger.Info(detections[0])
87
- // }
66
+ // myCam, err := camera.FromRobot(machine, "my_camera")
67
+ // if err != nil {
68
+ // logger.Error(err)
69
+ // return
70
+ // }
71
+ // // Get an image from the camera decoded as an image.Image
72
+ // img, err = camera.DecodeImageFromCamera(context.Background(), utils.MimeTypeJPEG, nil, myCam)
73
+ //
74
+ // myDetectorService, err := vision.FromRobot(machine, "my_detector")
75
+ // if err != nil {
76
+ // logger.Error(err)
77
+ // return
78
+ // }
79
+ // // Get the detections from the image
80
+ // detections, err := myDetectorService.Detections(context.Background(), img, nil)
81
+ // if err != nil {
82
+ // logger.Fatalf("Could not get detections: %v", err)
83
+ // }
84
+ // if len(detections) > 0 {
85
+ // logger.Info(detections[0])
86
+ // }
88
87
//
89
88
// For more information, see the [Detections method docs].
90
89
//
@@ -108,34 +107,29 @@ func init() {
108
107
//
109
108
// Classifications example:
110
109
//
111
- // myCam, err := camera.FromRobot(machine, "my_camera")
112
- // if err != nil {
113
- // logger.Error(err)
114
- // return
115
- // }
116
- // // Get the stream from a camera
117
- // camStream, err := myCam.Stream(context.Background())
118
- // if err!=nil {
110
+ // // add "go.viam.com/rdk/utils" to imports to use this code snippet
111
+ //
112
+ // myCam, err := camera.FromRobot(machine, "my_camera")
113
+ // if err != nil {
119
114
// logger.Error(err)
120
115
// return
121
- // }
122
- // // Get an image from the camera stream
123
- // img, release, err := camStream.Next(context.Background())
124
- // defer release()
116
+ // }
117
+ // // Get an image from the camera decoded as an image.Image
118
+ // img, err = camera.DecodeImageFromCamera(context.Background(), utils.MimeTypeJPEG, nil, myCam)
125
119
//
126
- // myClassifierService, err := vision.FromRobot(machine, "my_classifier")
127
- // if err != nil {
128
- // logger.Error(err)
129
- // return
130
- // }
131
- // // Get the 2 classifications with the highest confidence scores from the image
132
- // classifications, err := myClassifierService.Classifications(context.Background(), img, 2, nil)
133
- // if err != nil {
134
- // logger.Fatalf("Could not get classifications: %v", err)
135
- // }
136
- // if len(classifications) > 0 {
137
- // logger.Info(classifications[0])
138
- // }
120
+ // myClassifierService, err := vision.FromRobot(machine, "my_classifier")
121
+ // if err != nil {
122
+ // logger.Error(err)
123
+ // return
124
+ // }
125
+ // // Get the 2 classifications with the highest confidence scores from the image
126
+ // classifications, err := myClassifierService.Classifications(context.Background(), img, 2, nil)
127
+ // if err != nil {
128
+ // logger.Fatalf("Could not get classifications: %v", err)
129
+ // }
130
+ // if len(classifications) > 0 {
131
+ // logger.Info(classifications[0])
132
+ // }
139
133
//
140
134
// For more information, see the [Classifications method docs].
141
135
//
0 commit comments