{"id":14979624,"url":"https://github.com/asadullah-dal17/distance_measurement_using_single_camera","last_synced_at":"2025-04-06T01:10:35.606Z","repository":{"id":41472821,"uuid":"312910118","full_name":"Asadullah-Dal17/Distance_measurement_using_single_camera","owner":"Asadullah-Dal17","description":"using single camera to measure the distance opencv python, ","archived":false,"fork":false,"pushed_at":"2024-05-24T13:02:54.000Z","size":192223,"stargazers_count":293,"open_issues_count":3,"forks_count":94,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-03-30T00:09:01.190Z","etag":null,"topics":["distance-calculation","distance-estimation","distance-estimation-opencv","distance-estimator-opencv","distance-measurement","distance-measurement-using-camera","distance-measurements","distance-speed-estimation-opencv","distnace-calculation-opencv","face-detection-distance-estimation","linux","opencv-python","yolov4-detector-distance-estimation","youtube-video"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Asadullah-Dal17.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-14T22:04:54.000Z","updated_at":"2025-03-21T21:59:41.000Z","dependencies_parsed_at":"2024-09-28T03:21:08.670Z","dependency_job_id":"41f268d1-395a-45c5-8cf8-d3070f253610","html_url":"https://github.com/Asadullah-Dal17/Distance_measurement_using_single_camera","commit_stats":{"total_commits":96,"total_committers":3,"mean_commits":32.0,"dds":"0.47916666666666663","last_synced_commit":"3b13d7888ffcaee0528ff129cc386bc481309593"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asadullah-Dal17%2FDistance_measurement_using_single_camera","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asadullah-Dal17%2FDistance_measurement_using_single_camera/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asadullah-Dal17%2FDistance_measurement_using_single_camera/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asadullah-Dal17%2FDistance_measurement_using_single_camera/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Asadullah-Dal17","download_url":"https://codeload.github.com/Asadullah-Dal17/Distance_measurement_using_single_camera/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419861,"owners_count":20936012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["distance-calculation","distance-estimation","distance-estimation-opencv","distance-estimator-opencv","distance-measurement","distance-measurement-using-camera","distance-measurements","distance-speed-estimation-opencv","distnace-calculation-opencv","face-detection-distance-estimation","linux","opencv-python","yolov4-detector-distance-estimation","youtube-video"],"created_at":"2024-09-24T14:00:24.968Z","updated_at":"2025-04-06T01:10:35.586Z","avatar_url":"https://github.com/Asadullah-Dal17.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Distance measurement using single:one:camera :camera:\r\n\r\n![GitHub Repo stars](https://img.shields.io/github/stars/Asadullah-Dal17/Distance_measurement_using_single_camera?style=social) ![GitHub forks](https://img.shields.io/github/forks/Asadullah-Dal17/Distance_measurement_using_single_camera?style=social) ![YouTube Channel Subscribers](https://img.shields.io/youtube/channel/subscribers/UCc8Lx22a5OX4XMxrCykzjbA?style=social)\r\n\r\nIf 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**\r\n\r\nHere in this readme file you will get short description, if need more details, then you can watch video tutorial on YouTube as well.\r\n\r\n## Distance \u0026 Speed Estimation Demo\r\n\r\nhttps://user-images.githubusercontent.com/66181793/122644855-bb8ac000-d130-11eb-85c3-c7ff4bd6474c.mp4\r\n\r\n### Video Tutorials\r\n\r\n[**Distance Estimation Youtube Tutorail**](https://youtu.be/zzJfAw3ASzY) ![YouTube Video Views](https://img.shields.io/youtube/views/zzJfAw3ASzY?style=social)\r\n\r\n[**Distance \u0026 Speed Estimation Youtube Tutorial**](https://youtu.be/DIxcLghsQ4Q) ![YouTube Video Views](https://img.shields.io/youtube/views/DIxcLghsQ4Q?style=social)\r\n\r\n[**YoloV4 Object Detection \u0026 Distance Estimation**](https://youtu.be/FcRCwTgYXJw) ![YouTube Video Views](https://img.shields.io/youtube/views/FcRCwTgYXJw?style=social)\r\n[*Project GitHub Repository*](https://github.com/Asadullah-Dal17/Yolov4-Detector-and-Distance-Estimator)\r\n\r\n## YoloV4 Distance Estimation\r\n\r\nhttps://user-images.githubusercontent.com/66181793/124917186-f5066b00-e00c-11eb-93cf-24d84e9c2e7a.mp4\r\n\r\n## Distance Estimation on Raspberry Pi 🍓 \r\n\r\nhttps://user-images.githubusercontent.com/66181793/138200943-74d28b4d-bd0e-49fd-8836-4a01b35118eb.mp4\r\n\r\n✔️ here is source code and details for Instllation of Opencv-python on 🍓 Pi 😃 [Distance Estimation on Raspberry pi 🍓](https://github.com/Asadullah-Dal17/Distance_measurement_using_single_camera/tree/main/Raspberry_pi) \r\n\r\n\r\n:heavy_check_mark: I have included [**Speed Estimation**](https://github.com/Asadullah-Dal17/Distance_measurement_using_single_camera/tree/main/Speed) code is well check that out.\r\n\r\n:heavy_check_mark: You can find the implementation of  [**Distance estimation of multiple objects using Yolo V4**](https://github.com/Asadullah-Dal17/Yolov4-Detector-and-Distance-Estimator) Object Detector Opencv-python\r\n\r\n## Clone this Repo:\r\n\r\ngit clone https://github.com/Asadullah-Dal17/Distance_measurement_using_single_camera\r\n\r\n## install Opencv-python\r\n\r\n- Windows\r\n\r\n  pip install opencv-python\r\n\r\n- _install Opencv-python on Linux or Mac_\r\n\r\n  pip3 install opencv-python\r\n\r\n## Run the code\r\n\r\n- windows: :point_down:\r\n\r\n  python distance.py\r\n\r\n  ------ OR ---------\r\n\r\n  python Updated_distance.py\r\n\r\n- linux or Mac :point_down:\r\n\r\n  python3 distance.py\r\n\r\n  ------ OR ---------\r\n\r\n  python3 Updated_distance.py\r\n\r\n### :bulb:_Focal Length Finder Function Description_ :bulb:\r\n\r\n```python\r\n# focal length finder function\r\ndef focal_length(measured_distance, real_width, width_in_rf_image):\r\n\r\n    focal_length_value = (width_in_rf_image * measured_distance) / real_width\r\n    #return focal length.\r\n    return focal_length_value\r\n\r\n```\r\n\r\nThe Focal Length finder Function has three Arguments:\r\n\r\n`measured_distance` is the distance which we have measured while capturing the reference image:straight*ruler:. \\*\\*\\_From object to Camera*\\*\\* which is `Known_distance = 72.2 #centimeter`\r\n\r\n`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`\r\n\r\n`width_in_rf_image` is the width of the object in the image/frame it will be in **pixels**\r\n\r\n### :bulb:_Distance Finder Function Description_ :bulb:\r\n\r\n```python\r\n# Distance estimation function\r\n\r\ndef distance_finder(focal_length, real_face_width, face_width_in_frame):\r\n\r\n    distance = (real_face_width * focal_length)/face_width_in_frame\r\n    return distance\r\n\r\n```\r\n\r\nThis Function takes three Arguments,\r\n\r\n` Focal_Length` is the focal length, out of the **FocalLength** finder function.\r\n\r\n`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`\r\n\r\n`face_width_in_frame` is the width of the face in the frame, the unit will be pixels here.\r\n\r\n\r\n\r\nI have also created \u003ca href =\"https://github.com/Asadullah-Dal17/Face-Following-Robot-using-Distance-Estimation\"\u003e \u003cstrong\u003eFace Following Robot \u003c/strong\u003e \u003c/a\u003e which uses distance Estimation If you are interested you can Watch my\u003ca href =\"https://youtu.be/5FSOZe96kNg\"\u003e \u003cstrong\u003eYoutube Video\u003c/strong\u003e \u003c/a\u003e \r\nYou can create the following Robot with Raspberry That would be easy then, using Arduino Stuff, Raspberry 🍓 Pi will make it a system on Robot 🤖\r\n\r\nIf you found this helpful, please star :star: it.\r\n\r\nYou can Watch my Video Tutorial on Computer Vision Topics, just check out my YouTube Channel \u003ca href=\"https://www.youtube.com/c/aiphile\"\u003e  \u003cimg alt=\"AiPhile Youtube\" src=\"https://user-images.githubusercontent.com/66181793/131223988-882d53a0-4882-468f-9bd7-46b46466baae.png\"  width=\"20\"\u003e \u003c/a\u003e\r\n\r\n\r\nIf You have any questions or need help in CV Project, Feel free to DM on Instagram  \u003ca href=\"https://www.instagram.com/aiphile17/\"\u003e  \u003cimg alt=\"Instagram\" src=\"https://user-images.githubusercontent.com/66181793/131223931-32d84c10-88b4-4cd6-8eb8-89f06c3b5b51.png\"  width=\"20\"\u003e \u003c/a\u003e\r\n\r\nI am avalaible for paid work here \u003ca href=\"https://www.fiverr.com/asadullah_ar\"\u003e Fiverr \u003cimg alt=\"fiverr\" src=\"https://user-images.githubusercontent.com/66181793/163767548-9a68e1c1-341a-4b07-9e35-042c35694c08.png\"  width=\"15\"\u003e  \r\n\r\n## 💚🖤 Join me on Social Media 🖤💚 \r\n   \u003cdiv id=\"badges\"\u003e\r\n\r\n \u003c!-- Youtube Badge --\u003e\r\n  \u003ca href=\"https://www.youtube.com/c/aiphile\"\u003e\r\n    \u003cimg src=\"https://img.shields.io/badge/YouTube-red?style=for-the-badge\u0026logo=youtube\u0026logoColor=white\" alt=\"Youtube Badge\"/\u003e\r\n  \u003c/a\u003e\r\n\r\n\u003c!-- Instagram Badge  --\u003e\r\n  \u003ca href=\"https://www.instagram.com/aiphile17\"\u003e\r\n    \u003cimg src=\"https://img.shields.io/badge/Instagram-purple?style=for-the-badge\u0026logo=Instagram\u0026logoColor=white\" alt=\"Medium Badge\"/\u003e\r\n\r\n\u003c!-- Medium Badge  --\u003e\r\n  \u003ca href=\"https://medium.com/@aiphile\"\u003e\r\n    \u003cimg src=\"https://img.shields.io/badge/Medium-black?style=for-the-badge\u0026logo=Medium\u0026logoColor=white\" alt=\"Medium Badge\"/\u003e\r\n  \u003c/a\u003e\r\n\r\n\u003c!-- LinkedIn Badge --\u003e\r\n  \u003ca href=\"https://www.linkedin.com/company/aiphile\"\u003e\r\n    \u003cimg src=\"https://img.shields.io/badge/LinkedIn-blue?style=for-the-badge\u0026logo=linkedin\u0026logoColor=white\" alt=\"LinkedIn Badge\"/\u003e\r\n  \u003c/a\u003e\r\n  \u003c!-- Face book badge  --\u003e\r\n\u003ca href=\"https://asadullah.super.site\"\u003e\r\n    \u003cimg src=\"https://img.shields.io/badge/My%20Profile-black?style=for-the-badge\u0026logo=Profile\u0026logoColor=Green\" alt=\"Facebook Badge\"/\u003e\r\n  \u003c/a\u003e \r\n  \u003c!-- Twitter Badge  --\u003e\r\n  \u003ca href=\"https://twitter.com/ai_phile\"\u003e\r\n    \u003cimg src=\"https://img.shields.io/badge/Twitter-blue?style=for-the-badge\u0026logo=twitter\u0026logoColor=white\" alt=\"Twitter Badge\"/\u003e\r\n  \u003c/a\u003e\r\n\u003c/div\u003e\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasadullah-dal17%2Fdistance_measurement_using_single_camera","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasadullah-dal17%2Fdistance_measurement_using_single_camera","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasadullah-dal17%2Fdistance_measurement_using_single_camera/lists"}