/opencv_projects

OpenCV Projects

Primary LanguageC++

OpenCV Projects

Hi There!

My name is Dr. Frazer K. Noble and I am a lecturer at Massey University's School of Engineering and Advanced Technology (SEAT), Albany, New Zealand.

This repository is a collection of projects and tutorials for getting started and working with the Open Computer Vision (OpenCV) library. I intend this to be an ongoing effort that I will update on a regular basis; I hope that it may be of some use to you.

Best regards,

Frazer

P.S. If you'd like to hear about new projects and tutorials, follow me on Twitter @FrazerNoble.

Table of Contents

  1. Requirements.
  2. Projects.
  3. Tutorials.
  4. Installation.
  5. Contribution.
  6. Credits.

Requirements

I have used the following tools and libraries to create each project:

  1. gflags.
  2. tinyxml2.
  3. CMake.
  4. Microsoft Visual Studio 2017.
  5. OpenCV 3.2.
  6. Logitec c920 USB Camera.

To help ensure everything works, I'd also suggest you create the following enrionmental variables:

  1. OPENCV_DIR C:/opencv/opencv/build. This is where OpenCV is installed.
  2. DEV_LIBRARIES C:/dev_libraries. This is where you, might, have additional libraries you want to use in a project.

Each project has been compiled and run on PCs running Windows 8 x64 and Windows 10 x64 to ensure they work.

Resources

Here is a list of resources, which I think, are helpful for learning OpenCV and coding:

  1. OpenCV Documentation. OpenCV's documentation.
  2. Learning OpenCV 3.0. A book for learning OpenCV.
  3. Learn C++. A great website for learning C++.

Please note, the above list is not exhaustive; more of a minimal set to get started.

Projects

The following is a list of the projects included in this repository:

  1. Getting Started. This project is the 'Hello World!' of OpenCV projects.
  2. Video Player. This project looks at how we can play a video file.
  3. Frame Extractor. This project looks at how to extract frames from a video.
  4. Green Screen. This project looks at how we can detect the colour green in an image, video, or video capture device and replace it with a desired background.

As mentioned, these projects were created using Microsoft's Visual Studio 2017. To facilitate getting each started quickly, I created a number of property sheets: opencv_debug_x64.props, opencv_release_x64.props, dev_libraries_debug_x64, adn dev_libraries_release_x64. These, essentially, tell each project's solution where OpenCV's and useful libraries' include and lib directories are, and which .lib files to use.

In the OpenCV property sheets, I have used the OPENCV_DIR environmental variable, whose value on my PC is C:\opencv\opencv\build, to specify where the include directory ($(OPENCV_DIR)\Include) and the library directory ($(OPENCV_DIR)\x64\vc14\lib) are. Also, in the property sheets, I've made it so that the solution uses opencv_world320d.lib and opencv_wordl320.lib when linking.

If you're OpenCV installation is not in C:\opencv, then you will need to modify the environmental variable accordingly; though, you need only do this once (just be sure that you've got the admin' privaledges to do so).

In the DevLibraries property sheets, I have used the DEV_LIBRARIES environmental variable, whose value on my PC is C:\dev_libraries, to specify where the root folder of useful libraries include and library directories are. One such library is gflags, which I've used to parse the command line for instructions.

Tutorials

The following is a list of the tutorials included in this repository:

  1. How to Install OpenCV. A short tutorial on installing OpenCV.
  2. How to Build an Open Source Project A short video on how to build an open source project with CMake.

Installation

  1. Clone the opencv_projects repo'.
  2. Clone the gflags and tinyxml2 repo's.
  3. If you've not done so already, build gflags and tinyxml2 using CMake and Visual Studio as an Administrator. Also, ensure 'Shared Libraries' are enabled. Once completed, by default, you should find that there is now C:/Program Files/gflags and ./tinyxml2 directories, which contains Include and Lib sub-directories. Move these to C:/dev_libraries.
  4. Create environment variables OPENCV_DIR and DEV_LIBRARIES.
  5. Open a project's solution file.
  6. Change the solution platforms from x86 to x64, if necessary.
  7. Build project.

At this point everything should compile and run.

Contributions

If you feel like you can make a contribution; please, feel free to make a request.

Credits

Dr. Frazer K. Noble 2017