Il tutorial è questo:
http://www.pyimagesearch.com/2015/07/27/...erry-pi-2/
Tra l'altro ho provato a rifare i seguenti passaggi:
Section 2: Compiling
OpenCV 3.0 with Python 2.7+ support
Install the Python 2.7 header files so we can compile the
OpenCV 3.0 bindings:
Installing
OpenCV 3.0 for both Python 2.7 and Python 3+ on your Raspberry Pi 2
Shell
$ sudo apt-get install python2.7-dev
1
$ sudo apt-get install python2.7-dev
Timings: 1m 20s
Install pip , a Python package manager that is compatible with Python 2.7:
Installing
OpenCV 3.0 for both Python 2.7 and Python 3+ on your Raspberry Pi 2
Shell
$ wget
https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py
1
2
$ wget
https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py
Timings: 33s
Just as we did in the original tutorial on installing
OpenCV 2.4.X on your Raspberry Pi, we are going to utilize virtualenv and virtualenvwrapper which allow us to create separate Python environments for each of our Python projects. Installing virtualenv and virtualenvwrapper is certainly not a requirement when installing
OpenCV and Python bindings; however, it’s a standard Python development practice, one that I highly recommend, and the rest of this tutorial will assume you are using them!
Installing virtualenv and virtualenvwrapper is as simple as using the pip command:
Installing
OpenCV 3.0 for both Python 2.7 and Python 3+ on your Raspberry Pi 2
Shell
$ sudo pip install virtualenv virtualenvwrapper
$ sudo rm -rf ~/.cache/pip
1
2
$ sudo pip install virtualenv virtualenvwrapper
$ sudo rm -rf ~/.cache/pip
Timings: 17s
Next up, we need to update our ~/.profile file by opening it up in your favorite editor and adding the following lines to the bottom of the file.
Installing
OpenCV 3.0 for both Python 2.7 and Python 3+ on your Raspberry Pi 2
Shell
# virtualenv and virtualenvwrapper
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2.7
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
1
2
3
4
# virtualenv and virtualenvwrapper
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2.7
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
And if your ~/.profile file does not exist, create it.
Now that your ~/.profile file has been updated, you need to reload it so the changes take affect. To force a reload of the . profile , you can: logout and log back in; close your terminal and open up a new one; or the most simple solution is to use the source command:
Installing
OpenCV 3.0 for both Python 2.7 and Python 3+ on your Raspberry Pi 2
Shell
$ source ~/.profile
1
$ source ~/.profile
Time to create the cv3 virtual environment where we’ll do our computer vision work:
Installing
OpenCV 3.0 for both Python 2.7 and Python 3+ on your Raspberry Pi 2
Shell
$ mkvirtualenv cv3
1
$ mkvirtualenv cv3
Timings: 19s
If you ever need to access the cv3 virtual environment (such as after you logout or reboot your Pi), just source your ~/.profile file (to ensure it has been loaded) and use the workon command:
Installing
OpenCV 3.0 for both Python 2.7 and Python 3+ on your Raspberry Pi 2
Shell
$ workon cv3
1
$ workon cv3
And your shell will be updated to only use packages in the cv3 virtual environment.
Moving on, the only Python dependency we need is NumPy, so ensure that you are in the cv3 virtual environment and install NumPy:
Installing
OpenCV 3.0 for both Python 2.7 and Python 3+ on your Raspberry Pi 2
Shell
$ pip install numpy
1
$ pip install numpy
Timings 13m 47s
While unlikely, I have seen instances where the .cache directory gives a “Permission denied” error since we used the sudo command to install pip . If that happens to you, just remove the .cache/pip directory and re-install NumPy:
Installing
OpenCV 3.0 for both Python 2.7 and Python 3+ on your Raspberry Pi 2
Shell
$ sudo rm -rf ~/.cache/pip/
$ pip install numpy
1
2
$ sudo rm -rf ~/.cache/pip/
$ pip install numpy
Awesome, we’re making progress! You should now have NumPy installed on your Raspberry Pi in the cv3 virtual environment, as shown below:
Figure 1: NumPy has been successfully installed into our virtual environment for Python 2.7+.
Figure 1: NumPy has been successfully installed into our virtual environment for Python 2.7+.
Note: Performing all these steps can be time consuming, so it’s perfectly normal to logout/reboot and come back later to finish the install. However, if you have logged out or rebooted your Pi then you will need to drop back into your cv3 virtual environment prior to moving on with this guide. If you do not,
OpenCV 3.0 will not compile and install correctly and you’ll likely run into import errors.
So I’ll say this again, before you run any other command, you’ll want to ensure that you are in the cv3 virtual environment:
Installing
OpenCV 3.0 for both Python 2.7 and Python 3+ on your Raspberry Pi 2
Shell
$ workon cv3
1
$ workon cv3
And once you are in cv3 virtual environment, you can use cmake to setup the build:
Installing
OpenCV 3.0 for both Python 2.7 and Python 3+ on your Raspberry Pi 2
Shell
$ cd ~/
opencv
$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D
OPENCV_EXTRA_MODULES_PATH=~/
opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ..
1
2
3
4
5
6
7
8
9
$ cd ~/
opencv
$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D
OPENCV_EXTRA_MODULES_PATH=~/
opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ..
Update (3 January 2016): In order to build
OpenCV 3.1.0 , you need to set -D INSTALL_C_EXAMPLES=OFF (rather than ON ) in the cmake command. There is a bug in the
OpenCV v3.1.0 CMake build script that can cause errors if you leave this switch on. Once you set this switch to off, CMake should run without a problem.
Ma quando arrivo al cmake inizio ad avere una serie di problemi.....
Uno dei problemi è questo:
pi@raspberrypi:~/
opencv/build $ cmake -D CMAKE_BUILD_TYPE=RELEASE \
> -D CMAKE_INSTALL_PREFIX=/usr/local \
> -D INSTALL_C_EXAMPLES=ON \
> -D INSTALL_PYTHON_EXAMPLES=ON \
> -D
OPENCV_EXTRA_MODULES_PATH=~/
opencv_contrib/modules \
> -D BUILD_EXAMPLES=ON ..
CMake Error: The source directory "/home/pi/
opencv" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
Sinceramente però, il mio Raspberry mi sembra un po' troppo incasinato.
Forse mi conviene reinstallare il Raspbian e ripartire da 0.
Che tutorial mi suggerite per installare una versione di
opencv che giri al meglio sul mi Raspberry Pi 2 B?