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:
2929 AprilTagDetection::Point pt{x, y};
3030 return std::make_unique<AprilTagDetection::Point>(std::move(pt));
3131 }), 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+ })
3243 .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);
3445 })
Original file line number Diff line number Diff line change 77import pytest
88
99
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+
1019def _load_grayscale_image (fname ):
1120 full_path = pathlib .Path (__file__ ).parent / fname
1221 img = cv2 .imread (str (full_path ))
You can’t perform that action at this time.
0 commit comments