I’m trying to test out some code using opencv for AprilTag detection. However, I’ve been unable to get past the robotpy sync stage with this. I know for a fact that I have opencv installed:
I’ve tried to add this to the requires = list in pyproject.toml using “cv2” and “opencv-python”. No matter what I try, I get something like this during the sync step:
Does anybody have some suggestions for how to get around this?
Use robotpy-opencv
.
requires = [
"robotpy-opencv; platform_machine == 'roborio'",
"opencv-python; platform_machine != 'roborio'"
]
… we should probably document that somewhere.
Thank you for your help, and adding that to the toml file did fix the problem. I’m just trying to understand one thing now. If I take out the platform_machine part and just include “robotpy-opencv” in the requires list, I get the following error.
Just for my own understanding, why does including plaform_machine make a difference?
The platform_machine thing is a python environment marker (PEP 508 – Dependency specification for Python Software Packages | peps.python.org) that tells pip to use a package in a particular case.
In this case, robotpy-opencv
is only available for roborio, we don’t publish it for other platforms. In the same way, opencv-python
is not available for roborio, but it is available for desktop platforms.