Giter VIP home page Giter VIP logo

haar-classifier-video-object-detection's Introduction

Haar Classifier Video Object Detection

Haar cascade classifiers detecting cars and persons in videos with OpenCV.


Problem Overview

One of the main challenges in the computer vision field has been working with videos. Essentially being methods of processing sequences of images, video processing demands a lot more resources than regular image processing. A video of just one second may contain more than 100 images in sequence, depending on the frame rate. Long before the computer vision field was dominated by convolutional neural networks (CNNs), other image processing mechanisms were already developed trying to reduce the amount of resources needed to detect objects in images. One relevant example is the Haar cascade classifier.

A Haar cascade classifier is composed of a sequence of haar filters that aim to identify patterns in images. These filters go through the image as sliding windows, in a similar operation to the one performed by the convolutions of CNNs. They summarize variations in pixel color intensity on different image regions. With this summary, it is possible to efficiently compare any region of an image with any other summaries that represent a desired pattern. If the region has a particular pattern of intensity variation, this region goes through a series of haar filters to check if that pattern is indeed the searched pattern. Since we are talking about classifiers, they need to be trained to learn the pattern of interest. Usually, thousands of small variations of filters are put in sequence to form the cascade. The next figure has an illustration on the Haar classifier process. It shows some of these filters, basically matrices, where the black and white portions are being compared against each other to check for changes in pixel intensity:

facial_feature_haar_detection_haar_features

Analysis Introduction

Being highly optimized, Haar cascade classifiers were the way to go for many years since its proposal in 2001. Many camera algorithms used to adjust focus were based on this solution, since the camera hardware needed a fast method to find faces, the object of interest in the image. In this analysis, we work with two pretrained Haar cascade classifiers, on a transfer learning fashion, where we load the pretrained classifiers using OpenCV's CascadeClassifier class. One classifier looks for persons on a video. The other looks for cars on another video. OpenCV is the backbone of this project as we use many of its functions to handle the videos during the whole process.

While struggling with false positives, we were able to fine tune our method's parameters to detect almost all persons and cars, in their respective videos. The training process of the Haar classifiers are not discussed in the notebook for this repository, only their usage and tuning. Therefore, the parameters we fit are not training parameters but rather image processing parameters, namely the image scale factor and the minimum number of candidate neighbors every candidate region needs to have. A candidate is a region of the image that was classified as having the object.

In the end, the classifiers were able to achieve reasonable success not only detecting the objects in the videos but also tracking them as they move in the scene. In the notebook, we briefly discuss some challenges, such as image quality, artifacts on the images and object scales. These issues were mostly worked around using just parameter adjustments. This highlights the quality of this classical image processing algorithm that was a standard for many years.

haar_classifier_video_object_detection_car_traffic

haar-classifier-video-object-detection's People

Contributors

guilhermedom avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.