1

I'm an absolute Raspberry Pi newbie. My intention is to get some camera vision project working for which I need OpenCV3.3's dnn Python module.

I've found here a description of how OpenCV can be installed with pip but I'm getting the following error:

$ pip install opencv-contrib-python
Collecting opencv-contrib-python
  Could not find a version that satisfies the requirement opencv-contrib-python (from versions: )
No matching distribution found for opencv-contrib-python

can anyone help me further here?

  • Are you running Raspbian Stretch or an older version? On Stretch I would expect it to work for python3/pip3. Had a quick look at the tutorial and it seems to be incomplete/incorrect: AFAIK there is not yet a binary version of opencv for Python 2. – Dirk Jan 10 at 23:48
1

You can try the following:

sudo apt-get install libopencv-dev python3-opencv

You might try also to compile the library by yourself by downloading the source code from the git repository. Note that from the link a version 4 is available. You will have to solve a lot of dependencies by yourself by installing apt packages.

Raspberry3 model B should have enough memory to compile it (it requires a lot of time) (RPi2 maybe, RPi1 I do not think so) but it's not garanteed. If I remember correctly I compiled it but after a couple of times it went out of memory).

In this link here is described a much longer step-by-step tutorial for Ubuntu and here specific for the raspberry to compile the library opencv by yourself but I think the first command is enough and dependencies should be installed automatically (if it works on aspbian).

1

You should not have to compile - there should be a package in the repository. I have never used it, but apt-cache search opencv will show all the candidates.

I expect sudo apt install python-opencv is what you want.

If you are a beginner you almost certainly don't want the contrib package.

  • 1
    The Problem is, the repo only containsopencv 2.4 and I need >=3.3 as I require dnn (which only got introduced with 3.3) – cerr Jan 11 at 4:01
0

I ended up compiling OpenCV 3.4.4 from source as described on https://www.pyimagesearch.com/2018/05/28/ubuntu-18-04-how-to-install-opencv/ - the instructions are for Ubuntu but it worked just fine the same way on my Rasperry Pi running Raspian 9. I ended up with:

$ python
Python 3.5.3 (default, Sep 27 2018, 17:25:39) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.4.4'
>>> quit()

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.