Raspberry Pi 3 and OpenCV installation

I just got my new Raspberry Pi 3 and want to check if it is fast enough to finally bring some computer vision to my autonomous quadrocopter.

After a fresh Raspbian installation I followed the tutorial to install OpenCV 3.0 on Debian Jessie. For all those who did not yet use virtual environments with python, the tutorial covers the basic usage. Really nice! Unfortunately, the tutorial did not work for me with the newest OpenCV 3.1: CMake refused to recognize Python3, so I specifically added parameters for this:

cmake -D CMAKE_BUILD_TYPE=RELEASE \
 -D CMAKE_INSTALL_PREFIX=/usr/local \
 -D INSTALL_C_EXAMPLES=OFF \
 -D INSTALL_PYTHON_EXAMPLES=ON \
 -D OPENCV_EXTRA_MODULES_PATH=/home/pi/opencv_contrib/modules \
 -D BUILD_EXAMPLES=ON \
 -D PYTHON3_LIBRARY=/usr/lib/arm-linux-gnueabihf/libpython3.4m.so \
 -D PYTHON3_PACKAGES_PATH=/home/pi/.virtualenvs/cv/lib/python3.4/site-packages/ \
 -D PYTHON3_INCLUDE_DIR=/home/pi/.virtualenvs/cv/include/python3.4m \
 -D PYTHON3_EXECUTABLE=/home/pi/.virtualenvs/cv/bin/python3 \
 -D BUILD_opencv_python3=ON \
 ..

opencv_python3

Now CMake did find Python3 and OpenCV was installed on my Raspberry Pi 3:)

I did not see the exact timing, but the make -j4 call took at most 1h 22min. Really fast when I compare it to my early tryouts with the Raspberry Pi 1 and OpenCV!

After the compilation, I found out that the additional step in the tutorial to create a symbolic link in the virtualenv from ~/.virtualenvs/cv/lib/python3.4/sitepackages/ to /usr/local/lib/python3.4/sitepackages/cv2.so was not needed because the installation was already inside the virtualenv folder.Now that my installation is finished, stay tuned for some experiments with the new setup…

Advertisements

3 thoughts on “Raspberry Pi 3 and OpenCV installation

  1. Tim,
    Here working on the same exact thing (CV quadcopter)… and ran into problems with the tutorial. I get the gtk error when running the test_image.py I’m suspecting something went wrong back in the -j4. I watched it go by pretty quick and I did notice a couple lines that said “failed” at the end. I ignored it.
    Jessie Lite on R.Pi 3. Selected Python 3 route in the tutorial. I’m thinking about documenting this process because so many problems came along the way. This will be my 7th time re-imaging the sd card and starting over. I think this time I’ll just try regular Jessie. Curious to see how your quadcopter comes along

    Like

  2. Hi Jeremy,
    really bad to see that you have so big problems! In my experience it really helps to document the steps in a blog, several times I spotted my own errors just by writing about it. I have not yet tried Jessie Lite, but I would have assumed that it doesn’t create any additional problems.
    Unfortunately there have been a few delays with my quadcopter work and I may not have time to continue my from-scratch approach – so I decided to use the APM codebase with a Navio 2 shield on my raspberry Pi. However, I am unsure how the raspberry pi is able to handle CV code and the flight loop in parallel, so I started to build a car first. There I have less risk and can work on CV stuff which I can then translate to the copter without problems.

    Like

    1. It’s been a while, I completely forgot about this post and then I just found it by accident again. Update: I’m using Raspbian with openCV and Python 2.7 and a store bought cheap quadcopter. Successfully tracking objects and controlling the flight by using digital potentiometers in place of the joysticks in the remote control. Realizing that testing is proving to be a challenge since you want to let the thing fly but you also don’t want to throw it away. Tethering the drone is not working because the internal gyro wants to take over when the control is telling it to fly one way but the tether holds it back. Maybe I need to remove the props and monitor each motors rpm’s. I don’t know, I’ll think about it for a while.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s