[Bug]: opencv-python dependency of supervision overrides opencv-contrib-python dependency
bug
### Search before asking
- [x] I have searched the issues and discussions and found no similar bug report.
### 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:
```python
dependencies = [
"supervision==0.27.0rc4",
"opencv-contrib-python-headless>=4.13.0.90",
]
```
And try to access extra CSRTTracker from contrib package:
```python
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?
- [ ] Yes I'd like to help by submitting a PR!
0 条评论