Book Image

Learning OpenCV 3 Computer Vision with Python

Book Image

Learning OpenCV 3 Computer Vision with Python

Overview of this book

Table of Contents (16 chapters)
Learning OpenCV 3 Computer Vision with Python Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
6
Retrieving Images and Searching Using Image Descriptors
Index

Detecting cars


There is no virtual limit to the type of objects you can detect in your images and videos. However, to obtain an acceptable level of accuracy, you need a sufficiently large dataset, containing train images that are identical in size.

This would be a time consuming operation if we were to do it all by ourselves (which is entirely possible).

We can avail of ready-made datasets; there are a number of them freely downloadable from various sources:

Note

Note that training images and test images are available in separate files.

I'll be using the UIUC dataset in my example, but feel free to explore the Internet for other types of datasets.

Now, let's take a look at an example:

import cv2
import numpy as np
from os.path import join

datapath = "/home/d3athmast3r/dev/python/CarData/TrainImages/"
def path(cls,i):
  return "%s/...