2

I'm trying to install OpenCV for python with extra modules on my raspberry pi. The OpenCV website has a set of instructions that I have tried with different variations for the past several months. I have concluded over ~25 attempts that these will not work. Since I'm only going to be using OpenCV in python, I have changed tactics to just using pip to install opencv with modules.

However when I try I get this:

The error I receive

Opencv-contrib-python is in the pip packages list, as well as on the PyPI website. I have run pip(3) install --upgrade pip as the PyPI page suggests. If I link directly to the PyPI page download link, I receive this error.

The next error I recieve

This issue is only with the contrib modules. pip(3) install opencv-python works.

How do I install the package successfully?

1

opencv-contrib-python contains pre-compiled binaries, which, by their nature, only work for a specific architecture. Pip only has builds for x86 and x86_64 (no ARM builds, which is what you'd need on a Pi).

You will need to compile OpenCV yourself instead, since there aren't any available binaries for ARM processors. Be aware that since the Pi isn't very beefy, this will likely take a non-trivial amount of time (this site claims 2.8 hours for the Pi 2 and 9.5 hours for the original B+, and this site estimates about 1.5 hours for a Pi 3).

For instructions on compiling OpenCV, see: How to install OpenCV on Raspberry Pi 3 in Raspbian Jessie?

  • Ah. That's what I feared. Unfortunately I've tried that guide and the cmake compilation always freezes at the end and fails, or it succeeds but without compiling the extra modules. At this point I feel like Sisyphus, but I suppose I'll just try again. – Falcondance Jan 5 '18 at 18:29
  • @Falcondance You could try cross-compiling OpenCV (this involves you compiling on your normal PC, which should be significantly faster, but telling the compiler to compile for the Pi's architecture). That might help (see also this question) but unfortunately I haven't tried it myself, so I can't comment on whether it'd even work. Good luck. – Aurora0001 Jan 5 '18 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.