Sie sind auf Seite 1von 23

Car and Pedestrian Motion Detection

Submitted in partial fulfillment of the requirements for the award of degree of

BACHELOR OF ENGINEERING
IN
COMPUTER SCIENCE & ENGINEERING

Submitted By:

ANKUSH
15BCS2318

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

Chandigarh University, Gharuan


December 2018
ACKNOWLEDGEMENT

I have taken efforts in this project. However, it would not have been possible without the
kind support and help of many individuals and organizations. I would like to extend my
sincere thanks to all of them. I am highly indebted to Mr Rahul for his guidance and constant
supervision as well as for providing necessary information regarding the project & also for
their support in completing the project.I would like to express my special gratitude and
thanks to industry persons for giving me such attention and time.

ANKUSH(15BCS2318)

i
ABSTRACT
Object detection is an important feature of computer science. The benefits of object
detection is however not limited to someone with a doctorate of informatics. Instead,
object detection is growing deeper and deeper into the common parts of the information
society, lending a helping hand wherever needed. This project will address one such
possibility, namely the help of a Haar-cascade classifier. The main focus will be on the
case study of a vehicle detection and pedestrian detection and the possibilities it will
provide in a semi-enclosed area - both the statistical kind and also for the common man.
The goal of the system to be developed is to further ease and augment the everyday part
of our lives.

ii
List of Figures

Fig no Title Page No.


1.1 Block diagram of implemented algorithm
1.2 Flow diagram
2.1 Development Block
3.1 Pedestrian Detection
3.2 Car Detection

iii
Table of Contents

Sr. No. Topic Page No.


Chapter 1 INTRODUCTION
Chapter 2 SOFWARE SYSTEM REQUIREMENTS
Chapter 3 FLOW AND BLOCK DIAGRAM
Chapter 4 IMPLEMENTATION
Chapter 5 RESULTS AND SCREENSHOTS
Chapter 6 CONCLUSION AND FUTURE SCOPE
REFRENCES

1
Chapter 1

INTRODUCTION

Car and Pedestrian detection is part of the object detection techniques sing OPENCV and
Python.We are using the Cascade classifiers in this project to train the classifiers that detect
the cars and pedestrian using Open CV and Python .A video is trained on this Casscade
classifier that that different sample images from the video and train the classifier so that it
can detect the cars and pedestrians in the video with the use of the open cv libraries. Object
Detection systems use high GPU power .Amazon web services are used for the
computation in the training of the classifiers. It is because of the amount of data to be
processed is large and processing this data in real time is a tedious task. Surveillance of
traffic area is essential nowadays, because of rapid increase in the number of vehicles but
road area remains the same causing congestion. Determining the density of the vehicles in
the road and analysis of the surveillance of the video help a lot in traffic management
systems. The main objective of this project different techniques have been proposed to
detect the vehicles and track them on desktop computers. It detect vehicles on the HOG
images that are created by the use of the classifiers. The system uses stationary camera to
capture the traffic video. They extract frames from the video sequences and work on each
frame of the video. Different techniques are being considered to detect rear lamp and
license plate. Once after the localization of the vehicle parts, these parts are combined using
Markov Random Field to model the relationship.

1.1 Casscade Classifier

The cascade classifier consists of a list of stages, where each stage consists of a list of weak
learners. The system detects objects in question by moving a window over the image. Each
stage of the classifier labels the specific region defined by the current location of the

2
window as either positive or negative – positive meaning that an object was found or
negative means that the specified object was not found in the image.If the labelling yields
a negative result, then the classification of this specific region is hereby complete and the
location of the window is moved to the next location. If the labelling gives a positive result,
then the region moves of to the next stage of classification. The classifier yields a final
verdict of positive, when all the stages, including the last one, yield a result, saying that
the object is found in the image

1.2 Problem Statement

Many problems in computer vision were saturating on their accuracy before a decade.
How-ever, with the rise of deep learning techniques, the accuracy of these problems
drastically improved. One of the major problem was that of image classification, which is
ned as predicting the class of the image. A slightly complicated problem is that of image
localization, where the image contains a single object and the system should predict the
class of the location of the object in the image (a bounding box around the object). The
more complicated problem (this project), of object detection involves both classification
and localization. In this case, the input to the system will be a image, and the output will
be a bounding box corresponding to all the objects in the image, along with the class of
object in each box.

1.3 Applications

A well known application of object detection is face detection, that is used in almost all
the
mobile cameras. A more generalized (multi-class) application can be used in autonomous
driving where a variety of objects need to be detected. Also it has a important role to
play in surveillance systems. These systems can be integrated with other tasks such as pose
estimation where the rst stage in the pipeline is to detect the object, and then the second

3
stage will be to estimate pose in the detected region. It can be used for tracking objects and
thus can be used in robotics and medical applications. Thus this problem serves a multitude
of applications.

4
Chapter 2
SYSTEM REQUIREMENT SPECIFICATION
To be used efficiently, all computer software needs certain hardware components
or other software resources to be present on a computer. These prerequisites are known as
(computer) system requirements and are often used as a guideline as opposed to an absolute
rule. Most software defines two sets of system requirements: minimum and recommended.
With increasing demand for higher processing power and resources in newer versions of
software, system requirements tend to increase over time. Industry analysts suggest that
this trend plays a bigger part in driving upgrades to existing computer systems than
technological advancements.
Software requirements specification establishes the basis for an agreement between
customers and contractors or suppliers on how the software product should function (in a
market-driven project, these roles may be played by the marketing and development
divisions). The software requirements specification lays out functional and non-functional
requirements, and it may include a set of use cases that describe user interactions that the
software must provide.

2.1 Non-functional requirements

Non-functional requirements are the functions offered by the system. It includes


time constraints and constraints on the development process and standards. The non-
functional requirements are as follows:

 Speed: The system should process the given input into output within
appropriate time.
 Ease of use: The software should be user friendly. Then the customers can
use easily, so it doesn’t require much training time.
 Reliability: The rate of failures should be less then only the system is more
reliable

5
Portability: It should be easy to implement in any system.

2.1.1 Specific Requirements

The specific requirements are:

 User Interfaces: The external users are the clients. All the clients can use
this software for indexing and searching.
 Hardware Interfaces: The external hardware interface used for indexing and
searching is personal computers of the clients. Software Interfaces: The
Operating Systems can be any version of Windows.
 Performance Requirements: The PC’s used must be atleast Inter I 7
machines so that they can give optimum performance of the product.

2.2 Software requirements

Software requirements deal with defining software resource requirements and


prerequisites that need to be installed on a computer to provide optimal functioning of an
application.

These requirements or prerequisites are generally not included in the software


installation package and need to be installed separately before the software is installed.

Operating System Window/ Ubuntu Linux

Programming Language Python

IDE/Editor Jupyter Notebook

Required Python Packages Opencv,Tensorflow

6
2.3 Hardware requirements

The most common set of requirements defined by any operating system or software
application is the physical computer resources, also known as hardware, A hardware
requirements list is often accompanied by a hardware compatibility list, especially in case
of operating systems. An HCL lists tested, compatible, and sometimes incompatible
hardware devices for a particular operating system or application. The following sub-
sections discuss the various aspects of hardware requirements.

All computer operating systems are designed for a particular computer architecture.
Most software applications are limited to particular operating systems running on particular
architectures. Although architecture-independent operating systems and applications exist,
most need to be recompiled to run on a new architecture.

The power of the central processing unit (CPU) is a fundamental system requirement
for any software. Most software running on x86 architecture define processing power as
the model and the clock speed of the CPU. Many other features of a CPU that influence its
speed and power, like bus speed, cache, and MIPS are often ignored.

This definition of power is often erroneous, as AMD Athlon and Intel Pentium
CPUs at similar clock speed often have different throughput speeds.

System/Processor Intel Core i7, 2.4-3.7 GHz

HDD and RAm 500 GB and Ram 16GB or more

7
CHAPTER 3

Flow Diagram, Block Diagram

System design is the process of defining the architecture, components, modules,


interfaces and data for a system to satisfy specified requirements. One could see it as the
application of systems theory to product development. There is some overlap with the
disciplines of systems analysis, systems architecture and systems engineering. If the
broader topic of product development "blends the perspective of marketing, design, and
manufacturing into a single approach to product development," then design is the act of
taking the marketing information and creating the design of the product to be
manufactured. Systems design is therefore the process of defining and developing systems
to satisfy specified requirements of the user.

3.1 Block Diagram

Figure 1.1. Block diagram of implemented algorithm

8
3.2 FLOW DIAGRAM

Fig 1.2 Flow Diagram

9
CHAPTER 4
IMPLEMENTATION

4.1 TRAINING THE CLASSSIFIER

OpenCV offers two different applications for training a Haar classifier: opencv_haar
training and opencv_train cascade. We are going to use opencv_train cascade since it
allows the training process to be multi-threaded, reducing the time it takes to finish, and is
compatible with the newer Open CV 2.x API. Whenever you run into a problem when
loading your classifier, make sure the application knows how to handle the format of the
cascade file, since cascade files generated by opencv_haar training and opencv_train
cascade differ in format.

Many tools and libraries out there (including jsfeat, which is used in the example in the
first paragraph) only accept classifiers in the old format. The reason for this is most likely
that the majority of the easily available classifiers (e.g. the ones that ship with OpenCV)
still use that format. So if you want to use these libraries and tools you should
use opencv_haartraining to train your classifier.

So let’s point opencv_traincascade at our positive samples (samples.vec), negative images,


tell it to write its output into the classifier directory of our repository and the sample size
(-w and -h). -numNeg specifies how many negative samples are there and -
precalcValBufSize and -precalcIdxBufSize how much memory to use while training. -
numPos should be lower than the positive samples we generated.

opencv_traincascade -data classifier -vec samples.vec -bg negatives.txt\

-numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 1000\

10
-numNeg 600 -w 80 -h 40 -mode ALL -precalcValBufSize 1024\

-precalcIdxBufSize 1024

You don’t have to keep the process running without any interruptions though: you can stop
and restart it at any time and it will proceeded from the latest training stage it finished.

OUTPUT DURING OPENCV TRAINING

.After starting the training program it will print back its parameters and then start
training. Each stage will print out some analysis as it is trained:

===== TRAINING 0-stage =====

<BEGIN

POS count : consumed 1000 : 1000

NEG count : acceptanceRatio 600 : 1

Precalculation time: 11

+----+---------+---------+

| N| HR | FA |

+----+---------+---------+

| 1| 1| 1|

+----+---------+---------+

11
| 2| 1| 1|

+----+---------+---------+

| 3| 1| 1|

+----+---------+---------+

| 4| 1| 1|

+----+---------+---------+

| 5| 1| 1|

+----+---------+---------+

| 6| 1| 1|

+----+---------+---------+

| 7| 1| 0.711667|

+----+---------+---------+

| 8| 1| 0.54|

+----+---------+---------+

| 9| 1| 0.305|

+----+---------+---------+

END>

12
Training until now has taken 0 days 3 hours 19 minutes 16 seconds.

Each row represents a feature that is being trained and contains some output about its
HitRatio and FalseAlarm ratio. If a training stage only selects a few features (e.g. N = 2)
then its possible something is wrong with your training data.

At the end of each stage the classifier is saved to a file and the process can be stopped and
restarted. This is useful if you are tweaking a machine/settings to optimize training speed.

When the process is finished we’ll find a file called classifier.xml in


the classifier directory. This is the one, this is our classifier we can now use to detect
bananas with OpenCV! Only the sky is the limit now.

4.2 DEVELOPMENT

The essential part of the work is the implementation of the HOG descriptor with the
support vector machine. The code to achieve the pedestrian detection has been
considerably reduced by the OpenCV library. The detection will also consider that there
is some space in the image that doesn’t have to be analyzed, for this I have made a simple
method to select the region of interest.

Firstly, I will explain the process to get the HOG Descriptor. The HOG descriptor
(Histogram of Oriented Gradient) is based on the gradient orientation of regions in the
image. Basically, this is the procedure.

1. The image is divided in cells.

2. Compute gradient orientation of each pixel.

13
3. The cells are discretized taking into account the gradient orientation.

4. Each cell’s pixel votes for the orientation based on the gradient orientation.

5. The cells are grouped in blocks.

6. Histograms are normalized for each block.

Fig 2.1 Development Block

14
CHAPTER 5

SCREENSHOTS

Pedestrian Detection

Fig 3.1 Pedestrian Detection

15
Car Detection

Fig 3.2 Car Detection

16
CHAPTER 6

Conclusion and Future Scope

6.1 Conclusion

A arrangement able to constantly perceive and track vehicle rears in images from a sole
camera was accessible. The collection showed good recital in terms of recollect, exactness
and false constructive rates even in bad illumination situation. The estimate was accepted
out on a new dataset that will be at large to the scientific neighborhood. Recent evaluations
of profit-making VIPS found the obtainable systems have troubles with blockage,
occlusion, lighting transitions between night/day and day/night, camera tremor due to
wind, and long darkness linking vehicles mutually. We have accessible a vehicle detection
and tracking structure that is considered to control under these difficult conditions. in its
place of tracking complete vehicles, vehicle features are tracked, which makes the
arrangement less perceptive to the dilemma of partial occlusion. The similar algorithm is
used for tracking in daylight, twilight and nighttime surroundings, it is autonomous by
selecting the majority important features for the given situation. Common action over entire
attribute tracks is used to group features from being vehicles and diminish the chance that
long darkness will link vehicles in concert. Finally, camera motion through elevated storm
is accounted for by tracking a small number of fiducial points

Pedestrian detection is a useful tool for different applications, however there are still a lot
ofissues that should be solved in order to get the best results. The occlusion, accessories
and clothes are some of the problems that are experienced trying to detect human bodies.
Using background subtraction and techniques for noise reduction did not yield better
results.CASSCADE CLASSIFIER descriptors along with support vector machines work
very well trying to detect people but it still has to be improved in the areas mentioned
above.

17
6.2 Future Enhancement

Pure Tech Systems Car Counting

The system uses images received from IP and analog video cameras it to detect and count
vehicles. Advanced background algorithms then filter any unnecessary and probable
interference, such as shadows or lighting changes. When an object in detected, special
filters make sure to minimize the chance to count nonvehicle items, for example humans
and luggage. The finalized count is then outputted, based on the initial configuration - by
floor or special zone.The video is processed at a central monitoring location, which means
there is no need to make cuts into pavementor similarly preinfluence the environment in
such a way, which is commonly needed for inductive loop traffic detectors, where the
detectors need to be placed inside the pavement, which is a fairly common method of
detecting vehicles behind traffic lights.One problem with this system is, however, that it
only detects cars as they enter or leave the parking lot. This in turn means that there needs
to be such a camera or counter in front of every entrance and exit point, in order to ensure
that none of the vehicles are missed, which means that all these cameras need to be bought,
installed and serviced, which means that the specific client will face a possibly substantial
expenditure in order to keep all the devices up and running.

Pedestrain Detection
This approach to pedestrian detection needs to be improved to handle occlusion and
improve the performance. Also it is a good idea to track the detected people. Although
OpenCV has the coefficients for an already trained SVM, there are SVMs better trained
that can deal with occlusion and other problems in the input image. Regarding the user
interface, it should be improved to provide a better user experience, adding a toolbar with
the necessary functions

18
REFERENCES
1) www.opencv.com

2) Rosebrock, A. (2015, March 9). Capturing mouse click events with Python and
OpenCV - PyImageSearch. Retrieved May 25, 2015, from
http://www.pyimagesearch.com/2015/03/09/capturing-mouse-click-events-with-pyt
ho n-and-opencv/
3) www.pyimagesearch.com
4) OpenCV, “Cascade Classifier
Training — OpenCV 2.4.9.0 documentation,” [Online].

19

Das könnte Ihnen auch gefallen