Getting Started with OpenCV

2000px-OpenCV_Logo_with_text_svg_version.svg

We first install OpenCV 3.0.0 in Windows 10 64-bit. There are two ways to install OpenCV. One is to download the installer and run it. Other is to build from source.

Installing using Pre-build Libraries:

This is the easiest way to install OpenCV and get started.

  • Just head to Download OpenCV from SourceForge.
  • Click on the Version you want to download. We use 3.0.0 as it is the latest version (till this post was written).
  • After it finishes downloading, extract it and install at the chosen path.
    ProTip: Make sure your OpenCV path doesn’t include any spaces. So, it’s better if you install it in C:\ or D:\ root directory
  • Finally, Add OpenCV include directory to Environment Variables’ PATH variable at the bottom of this post.

Installing by building your own libraries from Source:

For the complete tutorial for this, you can head to this link. Else, you can find a easier way for including opencv_contrib in your build below.

  • Install CMake.
  • Head to https://github.com/Itseez/opencv.git and download zip and extract it in your C:\ root directory.
    cv
  • Now, open CMake and add your source directory to the Sources menu and build directory to the build menu.
    Tip: If there’s no build directory, create one your opencv folder.
    cv
  • Click on Configure and select your Visual Studio compiler version. I had Visual Studio 2013 Professional 32-bit, so I chose Visual Studio 12 compiler.
    cv
    Tip: You can download Visual Studio 2013 Professional from here. It comes with 30 days trial + 90 days extended trail after signing in.
  • Press Finish and CMake will load all the packages automatically. You can add or remove packages. Press Configure again.
  • If you need to build with extra opencv_contrib modules, you need to download them from here. Extract them and add the opencv_contrib/modules directory to your CMake as shown below.vc
  • Now press Configure again and then press Generate.
  • Close CMake. Go to C:\opencv\build folder and open the file named ‘OpenCV.sln’ file.
  • It will open Visual Studio. Now, Run it in both Debug vc  mode and Release vc Mode.
  • Now, in the solution explorer at the top right of your Visual Studio, select INSTALL project and build it.
    UntitledHurray!! You are done. One last step to go.

Adding OpenCV include directory to Environment Variables’ PATH variable:

  • Go to System Properties and Click on Advanced System Settings
    cv
  • Now, Click on Environment Variables >> Path >> Edit.
    vc
  • Add the bin folder located at your

    to this variable. Be careful not to replace the existing Path values.
  • After this, you need to restart your system for the Environment variables to change and now you’re ready to go.

Checkout this tutorial to get started with building OpenCV applications using Visual Studio or Qt.

1 Comment

  1. akash

    good one zeeshan 🙂

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *