{"id":21952174,"url":"https://github.com/lbaiyat/computer-vision-distance-detector","last_synced_at":"2026-05-10T09:46:47.054Z","repository":{"id":240805499,"uuid":"798011193","full_name":"lbaiyat/computer-vision-distance-detector","owner":"lbaiyat","description":"This is a computer vision project using python3 and conventional computer vision techniques to determine a relative distance between two points in a given scene. ","archived":false,"fork":false,"pushed_at":"2024-05-28T19:04:02.000Z","size":48485,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-29T07:52:35.738Z","etag":null,"topics":["canny-edge-detection","color-histogram","computer-vision","computervision","cv2","hough-transform","k-means","opencv","opencv-python","python3","sklearn"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"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/lbaiyat.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":"2024-05-08T23:14:14.000Z","updated_at":"2024-05-29T00:45:32.000Z","dependencies_parsed_at":"2024-11-29T06:36:51.601Z","dependency_job_id":null,"html_url":"https://github.com/lbaiyat/computer-vision-distance-detector","commit_stats":null,"previous_names":["lbaiyat/cv-distance-detector"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbaiyat%2Fcomputer-vision-distance-detector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbaiyat%2Fcomputer-vision-distance-detector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbaiyat%2Fcomputer-vision-distance-detector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbaiyat%2Fcomputer-vision-distance-detector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lbaiyat","download_url":"https://codeload.github.com/lbaiyat/computer-vision-distance-detector/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244999417,"owners_count":20544873,"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":["canny-edge-detection","color-histogram","computer-vision","computervision","cv2","hough-transform","k-means","opencv","opencv-python","python3","sklearn"],"created_at":"2024-11-29T06:24:03.359Z","updated_at":"2026-05-10T09:46:42.010Z","avatar_url":"https://github.com/lbaiyat.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1\u003eComputer Vision Distance Detector\u003c/h1\u003e\n\u003chr\u003e\n\n\u003cdiv style=\"border-left: 1px solid #ccc; padding-left: 12px;\"\u003e\n\u003ch2\u003eTable of Contents\u003c/h2\u003e\n\u003cul\u003e\n    \u003cli\u003e\u003ca href=\"#overview\"\u003eOverview\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#instructions\"\u003eInstructions\u003c/a\u003e\n        \u003cul\u003e\n            \u003cli\u003e\u003ca href=\"#setup-virtual-environment\"\u003eSetup virtual environment\u003c/a\u003e\u003c/li\u003e\n            \u003cli\u003e\u003ca href=\"#run-app\"\u003eRun the Application\u003c/a\u003e\u003c/li\u003e\n        \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#steps\"\u003eSteps\u003c/a\u003e\n        \u003cul\u003e\n            \u003cli\u003e\u003ca href=\"#histogram-training\"\u003eHistogram Training\u003c/a\u003e\u003c/li\u003e\n            \u003cli\u003e\u003ca href=\"#scene\"\u003eScene\u003c/a\u003e\u003c/li\u003e\n            \u003cli\u003e\u003ca href=\"#canny-edge\"\u003eCanny Edge Detection\u003c/a\u003e\u003c/li\u003e\n            \u003cli\u003e\u003ca href=\"#projective-transformation\"\u003eProjective Transformation\u003c/a\u003e\u003c/li\u003e\n            \u003cli\u003e\u003ca href=\"#k-means\"\u003eK-Means Clustering\u003c/a\u003e\u003c/li\u003e\n            \u003cli\u003e\u003ca href=\"#hough-transform\"\u003eHough Transformation\u003c/a\u003e\u003c/li\u003e\n        \u003c/ul\u003e\n    \u003c/li\u003e\n\n\n\u003c/ul\u003e\n\u003c/div\u003e\n\n\u003cdiv style=\"border-left: 1px solid #ccc; padding-left: 12px;\" id=\"overview\"\u003e\n\u003ch2\u003eOverview:\u003c/h2\u003e\n\u003cp\u003e\nThis is a computer vision project created in Python with computer vision libraries to\ndetermine the distance between two target objects in a given scene. The scenes and training images\nare depicted from a popular sandbox game.\n\u003c/p\u003e\n\u003c/div\u003e\n\n\n\u003cdiv style=\"border-left: 1px solid #ccc; padding-left: 12px;\" id=\"instructions\"\u003e\n\u003ch2\u003eInstructions:\u003c/h2\u003e\n\n\u003cp\u003e\nFollow the steps below to run the application.\n\u003c/p\u003e\n\n\u003ch3 id=\"setup-virtual-environment\"\u003e\nSetup virtual environment\n\u003c/h3\u003e\n\u003cpre\u003e\u003ccode class=\"language-bash\"\u003e\npython3 -m venv venv;\npip install -r requirements.txt;\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003ch3 id=\"run-app\"\u003e\nRun the application\n\u003c/h3\u003e\n\u003cpre\u003e\u003ccode class=\"language-bash\"\u003e\npython3 modules/main.py;\n\u003c/code\u003e\u003c/pre\u003e\n\n\u003c/div\u003e\n\n\u003cdiv style=\"border-left: 1px solid #ccc; padding-left: 12px;\" id=\"steps\"\u003e\n\u003ch2\u003eSteps:\u003c/h2\u003e\n\n\u003ch3 id=\"histogram-training\"\u003e\nHistogram Training\n\u003c/h3\u003e\n\n\u003cp\u003e\nThis step will process training images to get an understanding of\nhow the target block should look based on color values. The training images have (gold) target blocks shown\nfrom different angles and under different lighting situations. Once the histogram training is complete,\nthe histogram model can be used to filter for target blocks by its most frequent colors..\n\u003c/p\u003e\n\n\u003cp\u003eFor more info about Color Histograms:\n    \u003ca href=\"https://en.wikipedia.org/wiki/https://en.wikipedia.org/wiki/Color_histogram\" target=\"_blank\"\u003eColor Histograms\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp\u003e\nBelow are some sample images used to train the histogram model.\nThere are roughly 50 training images used for the histogram training.\n\u003c/p\u003e\n\n\n\u003cdiv style=\"display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;\"\u003e\n  \u003cdiv style=\"border: 1px solid #dddd; padding: 5px;\"\u003e\n    \u003ca href=\"histogram_training/raw/41.png\"\u003e\n    \u003cimg src=\"histogram_training/raw/41.png\" alt=\"Histogram Image 1\" style=\"width: 100%;\"\u003e\n    \u003c/a\u003e\n  \u003c/div\u003e\n \u003cdiv style=\"border: 1px solid #ddd; padding: 5px;\"\u003e\n    \u003ca href=\"histogram_training/raw/42.png\"\u003e\n    \u003cimg src=\"histogram_training/raw/42.png\" alt=\"Histogram Image 2\" style=\"width: 100%;\"\u003e\n    \u003c/a\u003e\n  \u003c/div\u003e\n \u003cdiv style=\"border: 1px solid #ddd; padding: 5px;\"\u003e\n    \u003ca href=\"histogram_training/raw/43.png\"\u003e\n    \u003cimg src=\"histogram_training/raw/43.png\" alt=\"Histogram Image 3\" style=\"width: 100%;\"\u003e\n    \u003c/a\u003e\n  \u003c/div\u003e\n \u003cdiv style=\"border: 1px solid #ddd; padding: 5px;\"\u003e\n    \u003ca href=\"histogram_training/raw/14.png\"\u003e\n    \u003cimg src=\"histogram_training/raw/14.png\" alt=\"Histogram Image 4\" style=\"width: 100%;\"\u003e\n    \u003c/a\u003e\n  \u003c/div\u003e\n \u003cdiv style=\"border: 1px solid #ddd; padding: 5px;\"\u003e\n    \u003ca href=\"histogram_training/raw/22.png\"\u003e\n    \u003cimg src=\"histogram_training/raw/22.png\" alt=\"Histogram Image 5\" style=\"width: 100%;\"\u003e\n    \u003c/a\u003e\n  \u003c/div\u003e\n \u003cdiv style=\"border: 1px solid #ddd; padding: 5px;\"\u003e\n    \u003ca href=\"histogram_training/raw/33.png\"\u003e\n    \u003cimg src=\"histogram_training/raw/33.png\" alt=\"Histogram Image 6\" style=\"width: 100%;\"\u003e\n    \u003c/a\u003e\n  \u003c/div\u003e\n\n\u003c/div\u003e\n\n\n\u003ch3 id=\"scene\"\u003e\nScene\n\u003c/h3\u003e\n\u003cp\u003e\nFor the purpose of this walkthrough, the scene image shown below will be used.\n\u003c/p\u003e\n\n\u003cimg src=\"scene/14.png\"\u003e\n\n\n\u003ch3 id=\"canny-edge\"\u003e\nCanny Edge Detection\n\u003c/h3\u003e\n\u003cp\u003eThe Canny Edge Detection algorithm is used to detect the edges in a given image.\u003c/p\u003e\n\u003cp\u003eFor more info about the Canny Edge Detection Algorithm:\n    \u003ca href=\"https://en.wikipedia.org/wiki/Canny_edge_detector\" target=\"_blank\"\u003eCanny Edge\n        Detector\u003c/a\u003e\n\u003c/p\u003e\n\u003cp\u003eApplying the Canny Edge detector to the scene image gives us this result:\u003c/p\u003e\n\u003cimg src=\"step_results/r.png\"\u003e\n\n\u003ch3 id=\"projective-transformation\"\u003e\nProjective Transformation\n\u003c/h3\u003e\n\u003cp\u003e                        \nThe Projective Transformation technique is used to transform an image from a perspective\ninto a 2D overhead view.\n\u003c/p\u003e\n\n\u003cp\u003eFor more info about the Projective Transformations:\n    \u003ca href=\"https://www.graphicsmill.com/docs/gm5/Transformations.htm\" target=\"_blank\"\u003eProjective Transformations\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp\u003e                        \nThe bounds for the Projective Transformation are determined and then highlighted in red for a visual representation.\n\u003c/p\u003e\n\u003cimg src=\"step_results/r_lined.png\"\u003e\n\n\u003cp\u003e                        \nOnce the Projective Transformation is completed, the result looks like the image shown below.\n\u003c/p\u003e\n\u003cimg src=\"step_results/transformed.png\"\u003e\n\n\n\u003ch3 id=\"k-means\"\u003e\nK-Means Clustering\n\u003c/h3\u003e\n\u003cp\u003e\nK-Means Clustering will be used to find 2 points in the transformed image that\ncorrespond to the center points of each of the target blocks.\n\u003c/p\u003e\n\n\u003cp\u003eFor more info about K-Means Clustering:\n    \u003ca href=\"https://en.wikipedia.org/wiki/K-means_clustering\" target=\"_blank\"\u003eK-Means Clustering\u003c/a\u003e\n\u003c/p\u003e\n\u003cp\u003eSetting K=2 and using the pixels in the target blocks as data points, we get two points corresponding to the centers \nof the target blocks, which are marked by the red dots.\n\u003c/p\u003e\n\n\u003cimg src=\"step_results/kmeans_centers.png\"\u003e\n\n\u003ch3 id=\"hough-transform\"\u003e\nHough Transformation\n\u003c/h3\u003e\n\n\u003cp\u003e\nThe Hough Transformation is used for the last result image to count the number of horizontal and vertical lines between the two highlight\npoints. These two values are used with the Euclidean Distance Formula to determine the distance between the two target blocks.\n\u003c/p\u003e\n\n\u003cp\u003eFor more info about the Hough Transformation:\n    \u003ca href=\"https://en.wikipedia.org/wiki/Hough_transform\" target=\"_blank\"\u003eHough Transform\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cimg src=\"step_results/hough_lined.png\"\u003e\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flbaiyat%2Fcomputer-vision-distance-detector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flbaiyat%2Fcomputer-vision-distance-detector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flbaiyat%2Fcomputer-vision-distance-detector/lists"}