Skip to content

Commit cb8f759

Browse files
committed
Update vision pages
1 parent 05f7e1f commit cb8f759

File tree

13 files changed

+102
-63
lines changed

13 files changed

+102
-63
lines changed

_data/sidebar_tree.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ tree:
109109
tree:
110110
- url: /competitor_resources/microgames
111111
title: Microgames
112+
- url: /competitor_resources/markers
113+
title: Game markers
112114
- url: /team_admin/
113115
title: Team Admin
114116
tree:

competitor_resources/markers.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
layout: page
3+
title: Game markers
4+
---
5+
6+
# Game markers
7+

images/content/vision/marker-0.png

21.7 KB
Loading
94.2 KB
Loading
27.2 KB
Loading
26.9 KB
Loading
26.9 KB
Loading
27 KB
Loading
27 KB
Loading

programming/vision/index.md

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,23 @@ title: Vision
55

66
# Vision
77

8-
Your robot is able to use a webcam to detect [fiducial markers](https://en.wikipedia.org/wiki/Fiducial_marker).
9-
Specifically it can detect [AprilTags](https://april.eecs.umich.edu/software/apriltag), using the `36H11` marker set.
8+
Your robot is able to use a webcam to detect [fiducial markers](https://en.wikipedia.org/wiki/Fiducial_marker) and return their locations relative to the robot.
109

11-
Each marker is unique and encodes a number in a machine-readable way, which means that robots can identify these objects.
10+
Specifically it can detect [AprilTags](https://april.eecs.umich.edu/software/apriltag), using the `36H11` marker set.
11+
Each of these markers acts like a QR-code, encoding a number in a machine-readable way so the robot can identify them.
1212

1313
Using [Pose Estimation](https://en.wikipedia.org/wiki/3D_pose_estimation), it can calculate the orientation and position of the marker relative to the webcam.
1414
Markers are attached to various items in the Student Robotics arena, in known locations.
15-
Using the marker poses and their locations, we can either calculate the location of object relative to the robot or the position of the robot relative to the arena.
15+
Using the marker's poses and their locations, we can either calculate the location of object relative to the robot or the position of the robot relative to the arena.
1616

1717
For information on markers, see the [markers page](./markers).
1818

19-
2019
## Camera
2120

22-
The interface to the vision system is through the camera, accessible through `R.camera`.
21+
The interface to the vision system is through the camera, accessible through `robot.camera`, there are three functions available on the camera object:
2322

2423
see
25-
: Take a photo through the webcam, and return a list of [`Marker`](#marker) instances, each of which describes one of the markers that were found in the image.
24+
: 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.
2625

2726
Here's an example that will repeatedly print out the distance, in meters, to each marker that the robot can see:
2827

@@ -44,7 +43,7 @@ Try pausing movement while taking an image.
4443
</div>
4544

4645
save
47-
: Take a photo through the webcam, and save it to the provided location.
46+
: Take a photo using the webcam, draw a box around the detected markers and save it to the provided location.
4847

4948
~~~~~ python
5049
from sr.robot3 import *
@@ -55,7 +54,7 @@ robot.camera.save(robot.usbkey / "initial-view.png")
5554
~~~~~
5655

5756
capture
58-
: Take a photo through the webcam, and return the image data as an OpenCV array.
57+
: Take a photo using the webcam, and return the image data as an OpenCV array.
5958

6059
~~~~~ python
6160
import cv2
@@ -64,15 +63,14 @@ robot = Robot()
6463

6564
frame = robot.camera.capture()
6665

67-
# Flip the image with OpenCV
68-
flipped = cv2.flip(frame, 0)
66+
# Do some other vision algorithm with the OpenCV frame here
6967
~~~~~
7068

7169

7270
### Frame argument
7371

7472
The slowest part of vision is capturing the image.
75-
You can use a frame with the other vision commands to avoid recapturing.
73+
You can use the output of the `capture` method with the other vision commands to avoid recapturing.
7674
This may be useful if you wish to use both your own vision algorithms and our marker detection on the same frames.
7775

7876
~~~~~ python
@@ -86,81 +84,67 @@ frame = robot.camera.capture()
8684
markers = robot.camera.see(frame=frame)
8785

8886
# Save the frame with marker annotation
89-
robot.camera.save("photo.jpg", frame=frame)
87+
robot.camera.save(robot.usbkey / "photo.jpg", frame=frame)
9088

9189
# Do some other vision algorithm with the OpenCV frame here
9290
~~~~~
9391

9492

95-
### Field of View
96-
97-
The Logitech C500 has a [field of view][fov] of 72&deg; and the C270 has a field of view of 60&deg;.
98-
99-
[fov]: https://en.wikipedia.org/wiki/Field_of_view
100-
101-
<div class="info">
102-
Note that the axes are all defined relative to the camera.
103-
Since we have no way to know how you've mounted your camera, you may need to account for that in your usage of the vision system's data.
104-
</div>
105-
106-
10793
## Marker
10894

109-
A `Marker` object contains information about a *detected* marker.
95+
A `Marker` object contains information about a detected marker.
11096
It has the following attributes:
11197

11298
id
11399
: The id of the marker.
114100

115101
size
116-
: The physical size of the marker, as the vision system expects it.
102+
: The physical size of the marker in millimetres, as the vision system expects it.
117103

118104
pixel_centre
119-
: A [`PixelCoordinates`](#pixelcoordinates) describing the position of the centre of the marker in the image.
105+
: A [`PixelCoordinates`](#pixel-coordinates) object describing the position of the centre of the marker in the image.
120106

121107
pixel_corners
122-
: A list of 4 [`PixelCoordinates`](#pixelcoordinates) instances, each representing the position of a corner of the marker in the image.
108+
: A list of 4 [`PixelCoordinates`](#pixel-coordinates) objects, each representing the position of a corner of the marker in the image.
123109

124110
position
125-
: A `Position` instance describing the position of the marker.
111+
: A `Position` object describing the position of the marker.
126112
See the [Position page](./position) for detailed definitions and diagrams.
127113

128114
distance
129115
: The distance between the camera and the centre of the marker, in millimetres.
130116

131117
horizontal_angle
132-
: Horizontal angle from the camera to the marker, in radians.
118+
: Horizontal angle from the centre of the camera's view to the marker, in radians.
133119
Ranges -&pi; to &pi;.
134-
Positive to the right.
135-
Directly in front is 0.
120+
Directly in front is zero, positive to the right.
136121

137122
vertical_angle
138-
: Vertical angle from the camera to the marker, in radians.
123+
: Vertical angle from the centre of the camera's view to the marker, in radians.
139124
Ranges -&pi; to &pi;.
140-
Positive values upwards.
141-
Directly in front is 0.
125+
Directly in front is zero, positive values upwards.
142126

143127
orientation
144128
: An `Orientation` instance describing the orientation of the marker.
145129
See the [Orientation page](./orientation) for detailed definitions and diagrams.
146130

147131
yaw
148-
: The Yaw of the marker, a rotation about the vertical axis, in radians.
132+
: The yaw of the marker, a rotation about the vertical axis, in radians.
149133
Positive values indicate a rotation clockwise from the perspective of the marker.
150134
Zero values have the marker facing the camera square-on.
151135

152136
pitch
153-
: The Pitch of the marker, a rotation about the transverse axis, in radians.
137+
: The pitch of the marker, a rotation about the transverse axis, in radians.
154138
Positive values indicate a rotation upwards from the perspective of the marker.
155139
Zero values have the marker facing the camera square-on.
156140

157141
roll
158-
: The Roll of the marker, a rotation about the longitudinal axis, in radians.
142+
: The roll of the marker, a rotation about the longitudinal axis, in radians.
159143
Positive values indicate a rotation clockwise from the perspective of the marker.
160144
Zero values have the marker facing the camera square-on.
161145

162146

163-
### PixelCoordinates
147+
### Pixel Coordinates
164148

165149
A named tuple of `x` and `y` coordinates for the point, in pixels relative to the top left of the image.
166150

0 commit comments

Comments
 (0)