default_config.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import cv2
  2. import os
  3. import numpy as np
  4. os.environ["QT_QPA_PLATFORM"] = "xcb"
  5. MARKER_SIZE = 5 # centimeters
  6. # LỰa chọn độ phân giải bằng cách thay đổi set_resolution
  7. set_resolution = 'original'
  8. RESOLUTION_STANDARDS = {'540p': 540, '720p': 720, '1080p': 1080, 'original': None}
  9. # The size of Square in the checker board.
  10. SQUARE_SIZE = 2.1 # centimeters
  11. # Thay đổi độ phân giải phù hợp với yêu cầu ban đầu
  12. def change_resolution(capture: cv2.VideoCapture, new_height):
  13. old_height = int(capture.get(cv2.CAP_PROP_FRAME_HEIGHT))
  14. old_width = int(capture.get(cv2.CAP_PROP_FRAME_WIDTH))
  15. if new_height is not None:
  16. new_width = int(old_width* new_height/old_height)
  17. capture.set(cv2.CAP_PROP_FRAME_WIDTH, new_width)
  18. capture.set(cv2.CAP_PROP_FRAME_HEIGHT, new_height)
  19. else:
  20. new_width = old_width
  21. new_height = old_height
  22. return (new_width, new_height)
  23. # Thiết lập vị trí các marker trên bản đồ
  24. default_positions = np.array([
  25. [0., 0., 0.], # marker 0
  26. [15.0, -21.5, 0.], # marker 1
  27. [-22., -21., 0.], # marker 2
  28. [-26.0, 15.5, 0.], # marker 3
  29. [23, 13, 0.] # marker 4
  30. ])