Saturday, December 30, 2017

Installing OpenCV 3.3.1 with Python 3.5 bindings on a Raspberry Pi Zero running Raspbian Stretch

I've been experimenting with some basic computer vision concepts on a Raspberry Pi as part of a small mobile robot project. Fundamental to this was getting OpenCV compiled and set up in Python, a process that took 5 or 6 tries over the majority of my Christmas/New Year break. Hopefully this guide will save you some proportion of that time when you have a go at it...

I'm working off the assumption that you are using Python 3.5 and are working within an activated virtual environment for your project. I am also going to use "~/myproject" as a stand in for your specific project path. This means you will have already done something like:

You need to stay in that activated virtual environment for the duration of this guide.
This install will be missing ffmpeg due to a bug in the current version.

Virtual memory
I needed to add more virtual memory to get this to work, using the following steps:

Now, the fun part. These are the steps you need to run, in order. The 'make' step will take 6-ish hours so is a good candidate for leaving overnight.

Virtual memory - again
It is important that you undo the virtual memory change above or you will risk corrupting you SD card. Just revert the value to 100 and start and stop the service.

From here you should be able to import 'cv2' from within the virtual environment's Python, and get on with actual development :)

This guide couldn't have been made without the efforts of:


  1. thanks this post really helped. I was painfully trying out different options for a week or so.

  2. I appreciate everything you have added to my knowledge base.Admiring the time and effort you put into your blog and detailed information you offer.Thanks. my website

  3. This is what I need to find. Thank you so much!


  4. With our Call Girls in Lucknowand escorts services, you may really improve stage of fun by its quality services different. Sure! This assists its people to victory over all the gloom and depressive disorders from your lifestyle and appeases your delicate wishes specifically.So, you may do a trip at web page and can get your wish suggested with an outstanding woman escort. Check our other services also...
    Call Girls in Lucknow
    Call Girls in Lucknow
    Call Girls in Lucknow
    Call Girls in Ahmedabad
    Call Girls in Ahmedabad