Skip to content

Commit

Permalink
fix(ar_tracker): use Python3.6 (old cv2) syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
onkoe committed May 21, 2024
1 parent 30f3b6c commit 5c1e37e
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions libs/aruco_tracker.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import cv2
import cv2.aruco as aruco
import configparser
import os
from time import sleep
from typing import List

import cv2
import cv2.aruco as aruco
from loguru import logger
from time import sleep


# TODO(bray): `dataclasses`
Expand Down Expand Up @@ -59,7 +60,7 @@ def __init__(
if self.write:
self.video_writer = cv2.VideoWriter(
"autonomous.avi",
cv2.VideoWriter.fourcc(
cv2.VideoWriter_fourcc(
self.format[0], self.format[1], self.format[2], self.format[3]
),
5,
Expand All @@ -68,7 +69,7 @@ def __init__(
)

# Set the ARUCO marker dictionary
self.marker_dict = aruco.DICT_4X4_50
self.marker_dict = aruco.Dictionary_get(aruco.DICT_4X4_50)

# Initialize cameras
# TODO: Could this be in a function
Expand All @@ -94,7 +95,7 @@ def __init__(
# fourcc is the codec used to encode the video (generally)
cam.set(
cv2.CAP_PROP_FOURCC,
cv2.VideoWriter.fourcc(
cv2.VideoWriter_fourcc(
self.format[0], self.format[1], self.format[2], self.format[3]
),
)
Expand Down Expand Up @@ -128,11 +129,9 @@ def marker_found(self, id1: int, image, id2: int = -1) -> bool:
for i in range(40, 221, 60):
# FIXME(bray): use logan's pr man!
bw = cv2.threshold(grayscale, i, 255, cv2.THRESH_BINARY)[1]
detector = aruco.ArucoDetector(
aruco.getPredefinedDictionary(self.marker_dict)
(self.corners, self.marker_IDs, self.rejected) = aruco.detectMarkers(
bw, self.marker_dict
)

(self.corners, self.marker_IDs, self.rejected) = detector.detectMarkers(bw)
if self.marker_IDs is not None:
self.index1 = -1
# this just checks to make sure that it found the right marker
Expand Down

0 comments on commit 5c1e37e

Please sign in to comment.