from __future__ import annotations import cv2 import numpy as np TARGET_WIDTH = 1280 TARGET_HEIGHT = 720 def resize_to_target(image: np.ndarray, width: int = TARGET_WIDTH, height: int = TARGET_HEIGHT) -> np.ndarray: h, w = image.shape[:2] if w == width and h == height: return image return cv2.resize(image, (width, height)) def bgr_to_rgba(bgr: np.ndarray) -> np.ndarray: return cv2.cvtColor(bgr, cv2.COLOR_BGR2RGBA) def bgr_to_rgb(bgr: np.ndarray) -> np.ndarray: return cv2.cvtColor(bgr, cv2.COLOR_BGR2RGB)