This commit is contained in:
NikolajDanger
2022-09-21 11:34:36 +02:00
parent 2977c5a45d
commit f2e8628a32
2 changed files with 15 additions and 7 deletions

View File

@ -36,10 +36,10 @@ def find_aruco(arlo):
def main():
arlo = robot.Robot()
for _ in range(5):
find_aruco(arlo)
for i in range(5):
image = find_aruco(arlo)
sleep(1)
# cv2.imwrite("test.png", image)
cv2.imwrite(f"test_{i}.png", image)
if __name__ == "__main__":
main()

View File

@ -8,6 +8,8 @@ START_VALUES = [60, 60]
THRESHOLD = 1.05
SLEEP_TIME = 2
FOCAL_LENGTH = 0
def test_forward(arlo, l_power, r_power):
arlo.reset_encoder_counts()
arlo.go_diff(l_power, r_power, 1, 1)
@ -81,9 +83,10 @@ class Arlo():
sleep((angle * self.timing[3])/1000)
self.robot.stop()
def find_aruco(self):
image = self.robot.take_photo()
def estimate_distance(self, bounding_box):
average_left = bounding_box[0][0]
def find_aruco(self, image):
aruco_dict = cv2.aruco.Dictionary_get(cv2.aruco.DICT_6X6_250)
aruco_params = cv2.aruco.DetectorParameters_create()
corners, ids, _ = cv2.aruco.detectMarkers(
@ -92,8 +95,13 @@ class Arlo():
parameters=aruco_params
)
for bounding, n in zip(corners, ids):
bounding_box = [(int(x), int(y)) for x, y in bounding.reshape((4,2))]
return zip(corners, ids)
def draw_arucos(self, image, bounding_boxes):
for bounding, n in bounding_boxes:
bounding_box = [
(int(x), int(y)) for x, y in bounding.reshape((4,2))
]
print(bounding_box)
cv2.line(image, bounding_box[0], bounding_box[1], (0,255,0), 2)