An Easy-To-Use Script to Install OpenCV for C++ and Python

Here to find an easy way to install OpenCV, and don’t care much about the specifics?

Do this:

git clone
cd install-opencv

Here’s the github repo for the installation script.

Why I Wrote This Script and Blog Post

OpenCV is a pain in the ass to install.

The official instructions are decent if you know where to find them, have been doing Linux development for a while, and feel like spending time on the installation process. For everyone else, they’re frustrating. They’re hard to find, they have a whole bunch of steps, substeps, ambiguities, and decisions that are left up to user.

That’s why so many others are writing their own sets of instructions.

Googling “install opencv” yields about 468,000 results as of this writing. The top 4 results have between 4-9 steps (often with substeps), and they are long.

Most of the time when I’m installing a library, I’m thinking about what I want to use it for. What sweet application for computer vision have I thought up now? That’s where I want my mental energy to go - not on figuring out which installation flags I should set and how.

I was recently installing OpenCV on three separate computes within a span of a few weeks and grew frustrated with the process.

About This Script

My motivation was to write something that would be really easy and helpful most of the time for most people.

The instructions to use it are literally one step: run the script.

This should install OpenCV (C++ and Python):

git clone
cd install-opencv

The github repository is here.

The repo has a README, which you should probably skim.

By default, the script installs opencv’s prerequisites, so you should be able to run it on a fresh OS install and it should just work. It runs in python 3.

To see the installation options, run ./ --help.

One flag that may be helpful is -p, which tells the script NOT to install prerequisities.

Also helpful is -b to tell the script to load build and installation flags for cmake from a JSON file. What are all of the available flags? Who knows? The official installation instructions are helpful, but not exhaustively so.

When NOT to Use This Script

Please note that this script is something I originally wrote for myself for my own use case. I think it will be helpful to others, so I’ve decided to share it. However, the script is not thoroughly tested, so use your own judgement. It seems to work fine on Ubuntu 16.04; I haven’t tested it on other configurations.

I can think of a number scenarios for when not to use this script:

Final Notes

The script currently does not install opencv_contrib (OpenCV’s “extra modules”). I haven’t needed them. I will probably add an option to install these to this script… the next time I need those modules. If you need them, why not fork my repo and add it?

If this post has helped you, or if you have suggestions on how to improve it, please let me know by commenting below. Thanks!

read more

A Quick Stop in Czechia

A Quick Stop in Czechia

To take a photo,
capture a moment in time,
and still let it pass.

A young boy in Prachatice, Czechia
After I took this boy's photo, I showed him the picture on my camera's LCD screen. When I turned to leave, he got very upset. He was convinced that because he had seen the toy truck in my camera, I was stealing his truck from him. Pointing out the truck in his hand had no effect - he knew that some version of the truck was there in my camera, and that I was taking it with me when I walked away.

I made a quick stop in Czechia recently, and while walking and driving around took some photos. Here are a few.

read more

Around Santa Cruz

Around Santa Cruz

Snuggled on the coast,
redwoods meet the ocean breeze:
come to Santa Cruz.

Here are some from Santa Cruz and the surrounding area, where “surrounding” is rather loosely defined, as you’ll see.

West Waddell Creek State Wilderness
West Waddell Creek State Wilderness

read more

Catalina 2017

Catalina 2017

Brave seas and mountains,
to get where buffalo roam
and escape the race.

Once again, I camped on Catalina island with some friends over July 4th weekend.

Here are some photos!

read more

Joshua Tree

Years of drought over,
desert flowers bloom among
the Joshua Trees.

I made it out to Joshua Tree National Park for a weekend recently. We had missed the peak blooming season, but to my pleasant surprise, there were still flowers blooming throughout the park!

What a marvelous place.

read more