File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
subprojects/robotpy-apriltag Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,17 @@ classes:
29
29
AprilTagDetection::Point pt{x, y};
30
30
return std::make_unique<AprilTagDetection::Point>(std::move(pt));
31
31
}), py::arg("x"), py::arg("y"))
32
+ .def("__len__", [](const AprilTagDetection::Point &self) { return 2; })
33
+ .def("__getitem__", [](const AprilTagDetection::Point &self, int index) {
34
+ switch (index) {
35
+ case 0:
36
+ return self.x;
37
+ case 1:
38
+ return self.y;
39
+ default:
40
+ throw std::out_of_range("AprilTagDetection.Point index out of range");
41
+ }
42
+ })
32
43
.def("__repr__", [](const AprilTagDetection::Point &self) {
33
- return py::str("Point(x={}, y={})").format(self.x, self.y);
44
+ return py::str("AprilTagDetection. Point(x={}, y={})").format(self.x, self.y);
34
45
})
Original file line number Diff line number Diff line change 7
7
import pytest
8
8
9
9
10
+ def test_point ():
11
+ point = robotpy_apriltag .AprilTagDetection .Point ()
12
+
13
+ x , y = point
14
+
15
+ assert x == 0
16
+ assert y == 0
17
+
18
+
10
19
def _load_grayscale_image (fname ):
11
20
full_path = pathlib .Path (__file__ ).parent / fname
12
21
img = cv2 .imread (str (full_path ))
You can’t perform that action at this time.
0 commit comments