This commit is contained in:
Davide Depau 2024-02-22 01:10:33 +01:00
parent ba3c9369e1
commit 92240741cc

10
bot.py
View file

@ -12,6 +12,7 @@ import cv2
import numpy as np
import telegram
from aiohttp import BasicAuth
from cv2 import aruco
from pytapo import Tapo
from telegram import Update, Message
from telegram.ext import Updater
@ -94,8 +95,8 @@ class Bot:
# Iterate until we find all 4 aruco markers or timeout
aruco_corners = {}
annotated_image = None
aruco_dict = a.getPredefinedDictionary(a.DICT_6X6_250)
aruco_params = a.DetectorParameters()
aruco_dict = aruco.getPredefinedDictionary(aruco.DICT_6X6_250)
aruco_params = aruco.DetectorParameters()
t0 = time.time()
print("Taking image with ArUco markers...")
@ -121,9 +122,10 @@ class Bot:
continue
# Detect the markers
corners, ids, rejected = a.detectMarkers(
corners, ids, rejected = aruco.detectMarkers(
annotated_image, aruco_dict, parameters=aruco_params
)
if corners is not None and ids is not None:
for corner, i in zip(corners, ids):
aruco_corners[i[0]] = corner
assert annotated_image is not None
@ -138,7 +140,7 @@ class Bot:
corners = [aruco_corners[i] for i in range(1, 5)]
ids = np.array([[i] for i in range(1, 5)])
a.drawDetectedMarkers(annotated_image, corners, ids)
aruco.drawDetectedMarkers(annotated_image, corners, ids)
# Annotate the image with the detected markers and apply the perspective transform to the pretty image