Git Product home page Git Product logo

asadullah-dal17 / distance_measurement_using_single_camera Goto Github PK

View Code? Open in Web Editor NEW
274.0 10.0 89.0 187.72 MB

using single camera to measure the distance opencv python,

Python 100.00%
opencv-python linux distance-calculation distance-measurement-using-camera distnace-calculation-opencv distance-estimation distance-estimation-opencv distance-measurement youtube-video face-detection-distance-estimation

distance_measurement_using_single_camera's Introduction

Distance measurement using single:one:camera :camera:

GitHub Repo stars GitHub forks YouTube Channel Subscribers

If you want to estimate distance of objects with your simple webcam, then this algorithm(Triangle similarity) would be helpful for you to find Distance from object to camera, I have provide to two examples, one is simple face detection and distance Estimation, other is Yolo4 object detection and distance Estimation

Here in this readme file you will get short description, if need more details, then you can watch video tutorial on YouTube as well.

Distance & Speed Estimation Demo

Distance.and.Speed.Estimation.Demo.mp4

Video Tutorials

Distance Estimation Youtube Tutorail YouTube Video Views

Distance & Speed Estimation Youtube Tutorial YouTube Video Views

YoloV4 Object Detection & Distance Estimation YouTube Video Views Project GitHub Repository

YoloV4 Distance Estimation

YoloV4.Distance.Estimation.mp4

Distance Estimation on Raspberry Pi ๐Ÿ“

Distnace.Estiamtion.on.Pi.mp4

โœ”๏ธ here is source code and details for Instllation of Opencv-python on ๐Ÿ“ Pi ๐Ÿ˜ƒ Distance Estimation on Raspberry pi ๐Ÿ“

โœ”๏ธ I have included Speed Estimation code is well check that out.

โœ”๏ธ You can find the implementation of Distance estimation of multiple objects using Yolo V4 Object Detector Opencv-python

Clone this Repo:

git clone https://github.com/Asadullah-Dal17/Distance_measurement_using_single_camera

install Opencv-python

  • Windows

    pip install opencv-python

  • install Opencv-python on Linux or Mac

    pip3 install opencv-python

Run the code

  • windows: ๐Ÿ‘‡

    python distance.py

    ------ OR ---------

    python Updated_distance.py

  • linux or Mac ๐Ÿ‘‡

    python3 distance.py

    ------ OR ---------

    python3 Updated_distance.py

๐Ÿ’กFocal Length Finder Function Description ๐Ÿ’ก

# focal length finder function
def focal_length(measured_distance, real_width, width_in_rf_image):

    focal_length_value = (width_in_rf_image * measured_distance) / real_width
    #return focal length.
    return focal_length_value

The Focal Length finder Function has three Arguments:

measured_distance is the distance which we have measured while capturing the reference image:straightruler:. **_From object to Camera** which is Known_distance = 72.2 #centimeter

real_width It's measured as the width of the object in the real world, here I measured the width of the face in real-world which was Known_width =14.3 # centimetre

width_in_rf_image is the width of the object in the image/frame it will be in pixels

๐Ÿ’กDistance Finder Function Description ๐Ÿ’ก

# Distance estimation function

def distance_finder(focal_length, real_face_width, face_width_in_frame):

    distance = (real_face_width * focal_length)/face_width_in_frame
    return distance

This Function takes three Arguments,

Focal_Length is the focal length, out of the FocalLength finder function.

real_face_width measures the width of an object in the real world, here I measured the width of a face in real-world which was Known_width =14.3 #centimeter

face_width_in_frame is the width of the face in the frame, the unit will be pixels here.

I have also created Face Following Robot which uses distance Estimation If you are interested you can Watch my Youtube Video You can create the following Robot with Raspberry That would be easy then, using Arduino Stuff, Raspberry ๐Ÿ“ Pi will make it a system on Robot ๐Ÿค–

If you found this helpful, please star โญ it.

You can Watch my Video Tutorial on Computer Vision Topics, just check out my YouTube Channel AiPhile Youtube

If You have any questions or need help in CV Project, Feel free to DM on Instagram Instagram

I am avalaible for paid work here Fiverr fiverr

๐Ÿ’š๐Ÿ–ค Join me on Social Media ๐Ÿ–ค๐Ÿ’š

distance_measurement_using_single_camera's People

Contributors

asadullah-dal17 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

distance_measurement_using_single_camera's Issues

About the return values of face_detector.detectMultiScale

I took a glance on your Updated_distance.py file, and I had a little problem on line 93.
Should the values in faces be (x, y, w, h) instead of (x, y, h, w)?
Also thanks to your project!
I'm currently working on single-camera applications, the efforts you paid helps me a lot!

Raspberry Pi

Hello! I'd like to ask if you have tried using this on Raspberry Pi? Would it work?

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.