from __future__ import annotations def require_module(module_name: str, install_hint: str): try: return __import__(module_name) except ModuleNotFoundError as exc: if exc.name == module_name: raise RuntimeError( f"Missing dependency '{module_name}'. Install it with: {install_hint}" ) from exc raise def require_cv2(): return require_module("cv2", "pip install opencv-python")