Close

Software Update: Raspian Stretch and openCV 3.3

A project log for Assistance System for Vein Detection

Using NIR (near infrared) Illumination and real-time image processing, we can make the veins more visible!

myrijamMyrijam 10/20/2017 at 12:480 Comments

Build-Log: Adapt to new Raspian Strech and openCV3.3

We started from scratch following mostly Adrian’s superb tutorial.

In a nutshell, it is a couple of commands you need to get the necessary packages and install open CV (and later Skimage) from source:

sudo raspi-config

Following the advise in the forum, we changed the swapsize accordingly and rebooted afterwards – just after we did the reboot to expands root-FS. Then we followed  Adrians’s blog, but again did not install the virtual environments, because in all the other tests we could not get Python 3 to work with Sci-Image-Filters and CV2.

Before doing anything else change an important bit in the config to make compiling with 4 cores possible: Edit /etc/dphys-swapfile and change CONF_SWAPSIZE to 2048 and reboot. You can then do make -j4 (tip from Stephen Hayes on Adrians Blog)

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install build-essential cmake pkg-config
sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libxvidcore-dev libx264-dev
sudo apt-get install libgtk2.0-dev libgtk-3-dev
sudo apt-get install libatlas-base-dev gfortran
sudo apt-get install python2.7-dev python3-dev
cd ~
wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.3.0.zip
unzip opencv.zip
 
wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.3.0.zip
unzip opencv_contrib.zip
 
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
pip install numpy

 

cd ~/opencv-3.3.0/
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.3.0/modules \
    -D BUILD_EXAMPLES=ON ..
 
 
make -j4
 
sudo make install
sudo ldconfig

Now you should be able to test that openCV ist successfully installed:

python
Your Pi should “answer” with:
Python 2.7.13 (default, Jan 19 2017, 14:48:08)
[GCC 6.3.0 20170124] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>Now check that OpenCV can be imported:
>>>import cv2
(nothing should happen, just a new line):
>>> cv2.__version__
Your Pi should give you:
'3.3.0'

Your Pi should “answer” with:

Python 2.7.13 (default, Jan 19 2017, 14:48:08)
[GCC 6.3.0 20170124] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>Now check that OpenCV can be imported:
>>>import cv2
(nothing should happen, just a new line):
>>> cv2.__version__
Your Pi should give you:
'3.3.0'

Leave the Python interpreter by quit() – now we are finished 😊

We verified that the latest Version of Venenfinder will work with this Version of OpenCV. 

Discussions