Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Learning OpenCV 3 Computer Vision with Python (Update)
  • Toc
  • feedback
Learning OpenCV 3 Computer Vision with Python (Update)

Learning OpenCV 3 Computer Vision with Python (Update)

By : Joe Minichino, Joseph Howse
2.1 (7)
close
Learning OpenCV 3 Computer Vision with Python (Update)

Learning OpenCV 3 Computer Vision with Python (Update)

2.1 (7)
By: Joe Minichino, Joseph Howse

Overview of this book

OpenCV 3 is a state-of-the-art computer vision library that allows a great variety of image and video processing operations. Some of the more spectacular and futuristic features such as face recognition or object tracking are easily achievable with OpenCV 3. Learning the basic concepts behind computer vision algorithms, models, and OpenCV's API will enable the development of all sorts of real-world applications, including security and surveillance. Starting with basic image processing operations, the book will take you through to advanced computer vision concepts. Computer vision is a rapidly evolving science whose applications in the real world are exploding, so this book will appeal to computer vision novices as well as experts of the subject wanting to learn the brand new OpenCV 3.0.0. You will build a theoretical foundation of image processing and video analysis, and progress to the concepts of classification through machine learning, acquiring the technical know-how that will allow you to create and use object detectors and classifiers, and even track objects in movies or video camera feeds. Finally, the journey will end in the world of artificial neural networks, along with the development of a hand-written digits recognition application.
Table of Contents (11 chapters)
close
6
6. Retrieving Images and Searching Using Image Descriptors
10
Index

Running samples

Running a few sample scripts is a good way to test whether OpenCV is correctly set up. The samples are included in OpenCV's source code archive.

On Windows, we should have already downloaded and unzipped OpenCV's self-extracting ZIP. Find the samples in <unzip_destination>/opencv/samples.

On Unix-like systems, including Mac, download the source code archive from https://github.com/Itseez/opencv/archive/3.0.0.zip and unzip it to any location (if we have not already done so). Find the samples in <unzip_destination>/OpenCV-3.0.0/samples.

Some of the sample scripts require command-line arguments. However, the following scripts (among others) should work without any arguments:

  • python/camera.py: This script displays a webcam feed (assuming that a webcam is plugged in).
  • python/drawing.py: This script draws a series of shapes, such as a screensaver.
  • python2/hist.py: This script displays a photo. Press A, B, C, D, or E to see the variations of the photo along with a corresponding histogram of color or grayscale values.
  • python2/opt_flow.py (missing from the Ubuntu package): This script displays a webcam feed with a superimposed visualization of an optical flow (such as the direction of motion). For example, slowly wave your hand at the webcam to see the effect. Press 1 or 2 for alternative visualizations.

To exit a script, press Esc (not the window's close button).

If we encounter the ImportError: No module named cv2.cv message, then this means that we are running the script from a Python installation that does not know anything about OpenCV. There are two possible explanations for this:

  • Some steps in the OpenCV installation might have failed or been missed. Go back and review the steps.
  • If we have multiple Python installations on the machine, we might be using the wrong version of Python to launch the script. For example, on Mac, it might be the case that OpenCV is installed for MacPorts Python, but we are running the script with the system's Python. Go back and review the installation steps about editing the system path. Also, try launching the script manually from the command line using commands such as this:
    $ python python/camera.py
    

    You can also use the following command:

    $ python2.7 python/camera.py
    

    As another possible means of selecting a different Python installation, try editing the sample script to remove the #! lines. These lines might explicitly associate the script with the wrong Python installation (for our particular setup).

bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete