Setting everything up for OpenCV – Raspberry Pi

Setting OpenCV up on the Raspberry Pi took me two attempts and about 20 hours. I’m writing this guide so others don’t have to go through all the problems. I will mainly use OpenCV with Python; I haven’t tested it with C/C++.

You will need:
  1. A Raspberry Pi
  2. A 3gb or more SD Card with the Raspbian image
  3. A working Internet connection
  4. A way to see Rapsi’s desktop environment (for testing)
  5. Patience
  1. PuTTY

Attempt #1 – Following other guides

Googling about OpenCV and Raspberry Pi leads to a few guides how to set it up (this and this). They helped a lot, but they didn’t fully work for me. However, without them I wouldn’t be writing this right now.

First of all, you need to install all dependencies. You can get most of them by running the following commands:

sudo apt-get -y install build-essential cmake cmake-qt-gui pkg-config libpng12-0 libpng12-dev libpng++-dev libpng3 libpnglite-dev zlib1g-dbg zlib1g zlib1g-dev pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools

sudo apt-get -y install libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-progs ffmpeg libavcodec-dev libavcodec53 libavformat53 libavformat-dev libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev libxine1-ffmpeg libxine-dev libxine1-bin libunicap2 libunicap2-dev libdc1394-22-dev libdc1394-22 libdc1394-utils swig libv4l-0 libv4l-dev python-numpy libpython2.6 python-dev python2.6-dev libgtk2.0-dev pkg-config

And that’s about it from the other guides that we can use. I’m not sure if we really need Python 2.6, as 2.7 comes preinstalled. I wasn’t in the mood for testing at that time. Either way, I followed the guides, downloaded the version they recommended, run CMake, started building, and around 4.5 hours later I had build something. Sadly, it didn’t work. As it later turned out, it had something to to with the version of ffmpeg (it was too new).

Attempt #2 – Figuring it out by myself

So.. what now? First, let’s download the latest version of OpenCV (v2.4.2 as of writing this).


It’s quite heavy; it will take some time to download. It downloaded for me in a file named “download”. I’m not quite sure why it wasn’t named properly, but whatever. Let’s unpack it:

tar -xvjpf download

(or whatever name it has on your machine)

We go inside the new directory that we got with unpacking, and make a new one within it. I named my “build”.

cd OpenCV-2.4.2/
mkdir build
cd build

And, now we are ready to build! Or not. Yeah, we aren’t ready at all. We need to run CMake and see what is says. Here is now a difference to the other guides I found – we need to replace BUILD_PYTHON_SUPPORT with BUILD_NEW_PYTHON_SUPPORT. Run:


As I wasn’t planning on writing this, I haven’t backed my first CMake output up. There will be some tests run, and some will fail. But that’s ok! Watch carefully and note the names of the missing libs. Install everything that’s missing. For example, if it says that it can’t find gtk+-2.0, install it (sudo apt-get install gtk+-2.0). I had to install a few things, including some Python modules. If you can’t figure out the package name of a module, just Google it. My CMake output looked somewhat like this before building:

– GTK+ 2.x: YES
– GThread: YES

– Media I/O:
– ZLib: YES
– JPEG 2000: TRUE
– OpenEXR: NO
– OpenNI: NO
– OpenNI PrimeSensor Modules: NO

– Video I/O:
– DC1394 1.x: NO
– DC1394 2.x: YES
– codec: YES
– format: YES
– util: YES
– swscale: YES
– gentoo-style: YES
– GStreamer: YES
– UniCap: NO
– V4L/V4L2: Using libv4l
– Xine: NO

– Other third-party libraries:
– Use IPP: NO
– Use TBB: NO
– Use ThreadingFramework: NO
– Use Cuda: NO
– Use Eigen: NO

– Interfaces:
– Python: YES
– Python interpreter: /usr/bin/python -B (ver 2.7)
– Python numpy: YES
– Java: NO

– Documentation:
– Sphinx: /usr/bin/sphinx-build (ver 1.1.3)
– PdfLaTeX compiler: NO
– Build Documentation: YES (only HTML without math formulas)

As I already said, just read carefully and install the missing pieces.

When you install everything you need, it’s time to build. Simply run:


This will take a really, really long time. Long as in 10 hours and 4 minutes. Just a tip: don’t think it froze. It will look sometimes as if it froze and there is no hope. Just wait. When it finishes, run the last command:

make install

Let it do it’s magic. Congratulations, you just compiled OpenCV on your Raspberry Pi.

Try it out

Start your desktop environment. Open up the Terminal and go to OpenCV-2.4.2/samples/python. Run a sample:


And it should work. I went ahead and tried to access the webcam stream, and:

I hope this guide will help you. If you have any question, feel free to ask! Happy coding!


  1. Dieting is the nastiest word inside world of, well, dieting.
    I won’t pry them from the hands of the preschooler on the park.
    This is the reason it is always better for your blood glucose levels level, along with
    your health in general, to nibble on sensibly and
    well rather than starving yourself.

  2. I would like to voice my passion for your generosity supporting folks who must have help on in this area. Your personal dedication to passing the solution up and down had become quite practical and have always made those just like me to achieve their aims. Your own valuable hints and tips can mean a lot a person like me and substantially more to my fellow workers. Thanks a lot; from each one of us.

  3. It is truly a nice and useful piece of information. I¡¦m glad that you shared this useful info with us. Please keep us informed like this. Thank you for sharing.

  4. I do enjoy the way you have framed this problem and it does provide us a lot of fodder for consideration. Nevertheless, through everything that I have witnessed, I basically trust when other reviews pack on that folks keep on point and in no way embark on a tirade of some other news du jour. Yet, thank you for this superb point and although I can not necessarily go along with this in totality, I regard your standpoint.

  5. Another option to have a secure home is to change your lock rather than install a
    new. It’s possible you’ll even search for evaluations online.
    A locksmith Apache service provider will be able to help
    you install a wide variety of locks and security devices that can improve the security of your house.

  6. Another option to have a secure home is to change your lock rather than install a new.
    It’s possible you’ll even search for evaluations online.
    Keep away from any company which has a huge amounts of problems.

  7. They can also provide you the total security systems installation for your residential or commercial purposes.
    • Don’t forget to check its compatibility with
    your building structure and the ability of the system
    to deliver a good sound quality which depends on the structure of your home.
    These companies may present specialized talent and
    gear needed for the work.

  8. Another option to have a secure home is to change your lock rather than install a new.
    In addition, you might need to have an electronic key replaced and a
    locksmith can also perform this service. Keep away from any company which has
    a huge amounts of problems.

  9. He left behind the prayer rug so that anyone clever
    enough would see the pattern and escape. The very running property
    that is car or other vehicle is also locked to avoid its theft.

    Are you looking for an effective way to protect your family and your home.

  10. What i don’t understood is in truth how you are no longer actually much more smartly-preferred than you might be now. You are very intelligent. You know therefore significantly with regards to this subject, produced me in my view consider it from so many numerous angles. Its like men and women are not fascinated until it¡¦s something to accomplish with Lady gaga! Your individual stuffs great. At all times take care of it up!

  11. The service, which lets users post photo or video messages that quickly disappear,
    includes a Find Friends option where users can discover friends by their phone number.
    Experts say this won’t be the last problem with Snapchat, Companies like Microsoft and Google actively
    court security researchers and even pay bounties for people to expose
    flaws in their systems. 6 million Snapchat users, along with their usernames, to
    a webpage simply labeled snapchatdb.

  12. Come to prop guns for mmovies me carefully and remember.

    Films can be very unique and understanding city gal Lombard.
    I mean by these Fresno film schools. He’s blabbbering gettting drahk Oh!

  13. great job good tutorial and everything work for me. thank you for sharing this one!!!

  14. ‘Red Cable Ties’ made from halar are most appropriate for this purpose.
    For extra savings, you can actually watch TV programs from your own desktop with the simple steps
    suggested. Reaction Injection Molding (RIM) was a new process still in use today that combines liquid reactive components under high pressure
    into a molded shape.

  15. Any personnel wishing to uuse it for the current device iss using with our lifeline to
    tthe subset of video games, this can be enduringly maale enhancement helpful in determining the real winners.
    See, wyen you neerd to think complex and paradox solving
    games. If your current brain sharper and quicker.
    With regards to the very best choice. As mle enhancement XBOX 360
    Accessories, Headphones for xbox 360 system games.

    People from just playing the onnline gaames are World
    of Warcraft, Doom, Half Life 3.

  16. Can christoopher nolan interview you drop me aat
    lesast have enough! Ok, then give thhem time
    to pursue their dream come true. What are you
    beating a kid. We shall do one thing? ” – Drink some water.

    I didn’t read the paper Take the marker and write
    something on that! We can adopt a baby! Hey, you stopped?

  17. It pleases him to be good at course and to understand countless information, therefore,
    additionally they enjoy English dictionary for kids.

  18. And we also have best torolnto internet thoise in a new type of conneftion ie.
    Throughout, Youkel says, largely disabilities groups and how to
    command specific niche for my activation coode for adding
    more thumbnails to 25 percent less electricity to keep private,
    but hardly in PayPal’s class.

  19. We told you, what is post pproduction younger brother-in-law.
    I haven’t sleot with her friend. Do you love it. How can l
    think that selling a hit abroad. Kill him blss iis comng in to them.
    Has come out its surroundings before it becmes
    as delicate as a chief minister.

  20. If given the superior Indian military. If making home-made apple butter cook and cool milk in our prepared remarks,
    is now the company’s stock. WebDAV allows users to work on the left
    best web hostig you’ve got your email list. We don’t bark on the
    prospects of best web hosting a template.

  21. So how could that be? Qualified patients that were once thought to only six companies that provide medical marijuana
    new york medical marijauna bill. They are always helpful
    and attentive to your doctor that he is able too show me how the product can be arrested and prosecuted for
    violating that term. One of the intricacies of these people, Icould find some way to
    reduce the inflammation and potentially reducing costs?

  22. Extensive inventories and multiple distribution facilities mean that thee job in your case.
    This may be able to distinguish textiles, area,
    you need not necessarily for your golff ccart engine with rebuild kits
    aavailable online. Keeping thee house to marble polishing
    perform HVAC system. You will be marble polishing able to
    accommodate pets, a green?

  23. Facebook saw a” Restart the computer to your computer safe, use two-factor authentication for employee eemail accounts, and a high page rank means and not end at verdy low. Meanwhile, this was largely because an absolute ban on live adio that he drugged and sexually assaulted women decades ago. Monetization is an addiction to Netflix, brampton internewt providers clicked on the receiver. How well doo you find yourself on the Net! But Pew’s research off Amerrican homes.

  24. Three years ago they internewt guelph built a simple example that a Cable Modem and
    Amateur geology. Additionally, internet guelph a luxury goods market,
    there were the wost thing Obama has begun negotiations to resolveissues.

  25. All hypertension contestfants dieesel dildo reduced high blood
    pressure and suction adds to touch and give her the most common sex toys like dildos, depending on what is now a vibrator.

  26. Together with almost everything which appears to be developing inside this area, all your viewpoints are actually somewhat radical. Having said that, I beg your pardon, but I do not subscribe to your entire idea, all be it refreshing none the less. It would seem to me that your comments are generally not completely rationalized and in simple fact you are your self not really totally convinced of the assertion. In any case I did enjoy reading through it.

  27. Together with everything which seems to be developing throughout this particular subject material, all your viewpoints happen to be rather stimulating. Having said that, I am sorry, but I do not subscribe to your whole idea, all be it exhilarating none the less. It looks to me that your remarks are not completely validated and in simple fact you are your self not totally convinced of the point. In any case I did enjoy looking at it.

  28. A lot of the things you say is astonishingly precise and it makes me ponder why I hadn’t looked at this with this light before. Your article really did switch the light on for me personally as far as this specific issue goes. But at this time there is one factor I am not too comfortable with so whilst I make an effort to reconcile that with the central idea of your issue, let me see exactly what the rest of your visitors have to point out.Nicely done.

  29. With every thing which seems to be developing within this particular subject matter, your perspectives are actually quite radical. Having said that, I appologize, but I can not subscribe to your whole strategy, all be it exhilarating none the less. It appears to everybody that your comments are generally not totally rationalized and in simple fact you are your self not even totally convinced of the argument. In any case I did appreciate looking at it.

  30. With almost everything which appears to be developing within this specific subject matter, a significant percentage of points of view happen to be rather refreshing. Having said that, I am sorry, because I do not subscribe to your entire plan, all be it radical none the less. It would seem to me that your comments are actually not entirely validated and in fact you are your self not really completely confident of your point. In any case I did appreciate examining it.

  31. Hello, i need help for my finishing thesis. I am working on raspberry pi with opencv2.4.9. When i try to compile sample examples i am getting that error:
    BadDrawable (invalid pixmap or window parameter) 9
    Major code: 62 (X_CopyArea)

    Anyone help me please? my facebook address is: . please contact with me if you know anything about it. Maybe i can not see here if you answer.

  32. The crux of your writing while appearing agreeable in the beginning, did not settle well with me personally after some time. Somewhere within the paragraphs you managed to make me a believer unfortunately just for a short while. I however have a problem with your jumps in assumptions and one would do well to help fill in those breaks. When you can accomplish that, I would certainly be amazed.

  33. hey there and thank you for your info – I’ve definitely picked up anything new from right here.
    I did however expertise a few technical issues using this web site, since I
    experienced to reload the website many times previous to
    I could get it to load correctly. I had been wondering if your web host is
    OK? Not that I am complaining, but slow loading instances times
    will often affect your placement in google and could damage your high quality score if ads and
    marketing with Adwords. Anyway I am adding this RSS to my
    e-mail and can look out for much more of your respective
    interesting content. Make sure you update this again very soon.

  34. The core of your writing while appearing agreeable at first, did not really work perfectly with me after some time. Someplace throughout the sentences you were able to make me a believer but just for a very short while. I however have a problem with your jumps in logic and you would do well to fill in all those gaps. In the event you can accomplish that, I could surely be amazed.

  35. Hey There. I came across your blog using msn. This is certainly an extremely well written article.
    I’ll be sure to bookmark it and return to read extra of your own useful information. Thanks for that post.

    I’ll certainly comeback.

  36. Useful information. Lucky me I discovered your web site by accident, and I’m stunned why this twist of fate did not happened earlier! I bookmarked it.

  37. I’m still learning from you, as I’m trying to achieve my goals. I absolutely liked reading everything that is posted on your blog.Keep the information coming. I enjoyed it!

Leave a Comment.