You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This documentation refers to a feature which is only available on the physical robot kits.
11
11
</div>
12
12
13
-
The `sr.robot` library contains support for detecting libkoki markers with the provided webcam.
13
+
The `sr.robot` library contains support for detecting fiducial markers with the provided webcam.
14
14
Markers are attached to various items in the Student Robotics arena.
15
15
Each marker encodes a number in a machine-readable way, which means that robots can identify these objects.
16
-
For information on which markers codes are which, see the [markers page](/docs/programming/sr/vision/markers).
16
+
For information on which markers codes are which, see the [markers page](./markers).
17
17
18
18
Using knowledge of the physical size of the different markers and the characteristics of the webcam,
19
-
libkoki can calculate the position of markers in 3D space relative to the camera.
19
+
your robot can calculate the position of markers in 3D space relative to the camera.
20
20
Therefore, if the robot can see a marker that is at a fixed location in the arena,
21
21
a robot can calculate its exact position in the arena.
22
22
23
-
The `sr.robot` library provides all of this power through a single function, `R.see`:
23
+
Under the hood, the vision system is based on [Zoloto](https://zoloto.readthedocs.io/), a wrapper around [OpenCV's ArUco library](https://docs.opencv.org/4.5.4/d5/dae/tutorial_aruco_detection.html), using the `36H11` marker set from [April](https://april.eecs.umich.edu/software/apriltag)
24
24
25
-
~~~~~python
26
-
from sr.robot import*
27
-
R = Robot()
28
-
markers = R.see()
29
-
~~~~~
25
+
[Camera](#camera) {#camera}
26
+
===========================
27
+
28
+
The interface to the vision system is through the camera, accessible through `r.camera`.
30
29
31
-
When called, this function takes a photo through the webcam and searches for markers within it.
32
-
It returns a list of `Marker` objects, each of which describes one of the markers that were found in the image.
33
-
A detailed description of the attributes of Marker objects is provided [later in this page](#Marker).
30
+
see
31
+
: 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.
34
32
35
33
Here's an example that will repeatedly print out the distance to each arena marker that the robot can see:
36
34
37
35
~~~~~python
38
-
from sr.robotimport*
36
+
from sr.robot3import*
39
37
R = Robot()
40
38
41
39
whileTrue:
42
-
markers = R.see()
40
+
markers = R.camera.see()
43
41
print("I can see", len(markers), "markers:")
44
42
45
43
for m in markers:
46
-
if m.info.marker_type ==MARKER_ARENA:
47
-
print(" - Marker #{0} is {1} metres away".format(m.info.code, m.dist))
44
+
print(" - Marker #{0} is {1} metres away".format(m.id, m.distance))
: Take a photo through the webcam, and return a list of marker ids (**not** full `Marker` objects). This doesn't do the same orientation calculations as `see`, and so is much faster to run.
49
+
50
+
~~~~~python
51
+
from sr.robot3 import*
52
+
R = Robot()
53
+
54
+
whileTrue:
55
+
marker_ids = R.camera.see_ids()
52
56
53
-
By default, the `R.see` function will take a photo at a resolution of 800x600.
54
-
The resolution that this image is taken at can be changed using the optional `res` argument:
57
+
if0in marker_ids:
58
+
print("I can see marker 0!")
59
+
else:
60
+
print("I cannot see marker 0!")
61
+
~~~~~
62
+
63
+
save
64
+
: Take a photo through the webcam, and save it to the provided location.
0 commit comments