Skip to content

Commit 3021182

Browse files
committed
Update camera docs for new API
1 parent 6116328 commit 3021182

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

programming/vision/index.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ For information on markers, see the [markers page](./markers).
2020

2121
## Camera
2222

23-
The interface to the vision system is through the camera, accessible through `robot.camera`, there are three functions available on the camera object:
23+
The interface to the vision system is through the camera, accessible through `robot.camera`, there are two functions available on the camera object:
2424

2525
see
2626
: Take a photo using the webcam, and return a list of [`Marker`](#marker) instances, each of which describes one of the markers that were found in the image.
@@ -47,17 +47,6 @@ Taking images while moving will cause them to be blurry, which will cause marker
4747
Try pausing movement while taking an image.
4848
</div>
4949

50-
save
51-
: Take a photo using the webcam, draw a box around the detected markers and save it to the provided location.
52-
53-
~~~~~ python
54-
from sr.robot3 import *
55-
robot = Robot()
56-
57-
# `robot.usbkey` is the path to your USB drive
58-
robot.camera.save(robot.usbkey / "initial-view.jpg")
59-
~~~~~
60-
6150
capture
6251
: Take a photo using the webcam, and return the image data as an OpenCV array.
6352

@@ -95,6 +84,31 @@ robot.camera.save(robot.usbkey / "photo.jpg", frame=frame)
9584
~~~~~
9685

9786

87+
### Saving camera output
88+
89+
You can also save a snapshot of what your webcam is currently seeing. This can be useful to debug your code.
90+
91+
This is done by adding the `save` parameter to the `see` or `capture` functions.
92+
The parameter should be the filename to where you want to save the image.
93+
94+
If used with the `see` function, every marker that your robot can see will have a square annotated around it, with a red dot indicating the top left corner of the marker.
95+
The ID of every marker is also written next to it.
96+
97+
Snapshots are saved to your USB drive, and can be viewed on another computer.
98+
99+
```python
100+
from sr.robot3 import *
101+
102+
robot = Robot()
103+
104+
# Save a snapshot of what the camera is currently seeing
105+
frame = robot.camera.capture(save="snapshot.jpg")
106+
107+
# Save a snapshot of what the camera is currently seeing with markers annotated
108+
markers = robot.camera.see(save="annotated-snapshot.jpg")
109+
```
110+
111+
98112
## Marker
99113

100114
A `Marker` object contains information about a detected marker.

0 commit comments

Comments
 (0)