Skip to content

Using yolov3 & yolov4 weights objects are being detected from live video frame along with the measurement of the object from the camera without the support of any extra hardware device.

Notifications You must be signed in to change notification settings

paul-pias/Object-Detection-and-Distance-Measurement

Repository files navigation

Object Detection and Distance Measurement

N|Solid

Introduction

This repo contains object_detection.py which is able to perform the following task -

  • Object detection from live video frame, in any video file or in a image
  • Counting the number of objects in a frame
  • Measuring the distance of object using depth information

Instalation

    $ pip install requirements.txt
        or
    $ pip install opencv_python
    $ pip install numpy
    $ pip install pandas
    $ pip install matplotlib
    $ pip install Pillow

For the installation of torch using "pip"

$pip3 install torch===1.2.0 torchvision===0.4.0 -f https://download.pytorch.org/whl/torch_stable.html
or please follow the instruction from [Pytorch](https://pytorch.org/)

Theory

In a traditional image classification approach for object detection there are two well-known strategies. For single object in a image there are two scenarios.

  • Classification
  • Localization For multiple objects in a image there are two scenarios.
  • Object detection and localization
  • Object segmentation

For Single Objects

For Multiple Objects

Distance Measurement

N|Multiple Object


Traditionally we measure distance of any object using Ultrasonic sensors such as HC-sr04 or other any high frquency devices which generates sound waves to calculates the distance it covers. However, when you are working with a embedded device to make a compact design which has functionalities such as
  • Object detection (with camera) and
  • Distance measurement

you don't always want to make your device heavier by adding unnnecessary hardware modules. To avoid such cases you can follow another more convinent and feasible apporoach. As you have already integrated a camera for object detection you can use the depth information that camera uses to draw the bounding boxes for localizing objects.