diff --git a/bot.py b/bot.py index cb2d7fe..b699f1f 100644 --- a/bot.py +++ b/bot.py @@ -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,11 +122,12 @@ class Bot: continue # Detect the markers - corners, ids, rejected = a.detectMarkers( + corners, ids, rejected = aruco.detectMarkers( annotated_image, aruco_dict, parameters=aruco_params ) - for corner, i in zip(corners, ids): - aruco_corners[i[0]] = corner + 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 del vcap @@ -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