import cv2 import os import numpy as np os.environ["QT_QPA_PLATFORM"] = "xcb" MARKER_SIZE = 5 # centimeters # LỰa chọn độ phân giải bằng cách thay đổi set_resolution set_resolution = 'original' RESOLUTION_STANDARDS = {'540p': 540, '720p': 720, '1080p': 1080, 'original': None} # The size of Square in the checker board. SQUARE_SIZE = 2.1 # centimeters # Thay đổi độ phân giải phù hợp với yêu cầu ban đầu def change_resolution(capture: cv2.VideoCapture, new_height): old_height = int(capture.get(cv2.CAP_PROP_FRAME_HEIGHT)) old_width = int(capture.get(cv2.CAP_PROP_FRAME_WIDTH)) if new_height is not None: new_width = int(old_width* new_height/old_height) capture.set(cv2.CAP_PROP_FRAME_WIDTH, new_width) capture.set(cv2.CAP_PROP_FRAME_HEIGHT, new_height) else: new_width = old_width new_height = old_height return (new_width, new_height) # Thiết lập vị trí các marker trên bản đồ default_positions = np.array([ [0., 0., 0.], # marker 0 [11.4, -6.5, 0.], # marker 1 [-11.4, -6.5, 0.], # marker 2 [-8.8, 6.5, 0.], # marker 3 [10.2, 5.5, 0.] # marker 4 ])