Search before asking
Bug
supervision package directly depends on opencv-python which means it's being included when installing supervision.
If your project depends on opencv-contrib-python as well then it will cause both opencv-python (as supervision dependency) and opencv-contrib-python to be downloaded.
And opencv-python will override opencv-contrib-python in that scenarion, which will remove access to extra modules from opencv-contrib-python.
Proposition to resolve it is to make opencv-python an optional dependency and another opencv-contrib-python optional dependency, so that user can choose which install.
Environment
- Supervision: 0.27.0rc4
- Python: 3.12
- OS: Linux
Minimal Reproducible Example
In pyproject.toml add both dependencies:
dependencies = [
"supervision==0.27.0rc4",
"opencv-contrib-python-headless>=4.13.0.90",
]
And try to access extra CSRTTracker from contrib package:
import logging
import cv2
def main():
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
try:
logger.info(f"OpenCV version: {cv2.__version__}")
logger.info(f"OpenCV path: {cv2.__file__}")
logger.info(cv2.getBuildInformation())
except Exception as e:
logger.error(f"Failed to get OpenCV version: {e}")
return
try:
tracker = cv2.TrackerCSRT_create()
logger.info("✓ CSRT tracker is available")
logger.info(f"Tracker type: {type(tracker)}")
except AttributeError:
logger.error("✗ CSRT tracker not available - cv2.TrackerCSRT_create missing")
except Exception as e:
logger.error(f"✗ Failed to create CSRT tracker: {e}")
if __name__ == "__main__":
main()
Are you willing to submit a PR?
Search before asking
Bug
supervisionpackage directly depends onopencv-pythonwhich means it's being included when installingsupervision.If your project depends on
opencv-contrib-pythonas well then it will cause bothopencv-python(as supervision dependency) andopencv-contrib-pythonto be downloaded.And
opencv-pythonwill overrideopencv-contrib-pythonin that scenarion, which will remove access to extra modules fromopencv-contrib-python.Proposition to resolve it is to make
opencv-pythonan optional dependency and anotheropencv-contrib-pythonoptional dependency, so that user can choose which install.Environment
Minimal Reproducible Example
In pyproject.toml add both dependencies:
And try to access extra CSRTTracker from contrib package:
Are you willing to submit a PR?