Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lbaiyat/computer-vision-distance-detector

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.
https://github.com/lbaiyat/computer-vision-distance-detector

canny-edge-detection color-histogram computer-vision computervision cv2 hough-transform k-means opencv opencv-python python3 sklearn

Last synced: about 1 month ago
JSON representation

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.

Awesome Lists containing this project

README

        

Computer Vision Distance Detector




Table of Contents




Overview:



This is a computer vision project created in Python with computer vision libraries to
determine the distance between two target objects in a given scene. The scenes and training images
are depicted from a popular sandbox game.



Instructions:


Follow the steps below to run the application.


Setup virtual environment




python3 -m venv venv;
pip install -r requirements.txt;


Run the application




python3 modules/main.py;


Steps:


Histogram Training


This step will process training images to get an understanding of
how the target block should look based on color values. The training images have (gold) target blocks shown
from different angles and under different lighting situations. Once the histogram training is complete,
the histogram model can be used to filter for target blocks by its most frequent colors..

For more info about Color Histograms:
Color Histograms


Below are some sample images used to train the histogram model.
There are roughly 50 training images used for the histogram training.








Scene



For the purpose of this walkthrough, the scene image shown below will be used.


Canny Edge Detection


The Canny Edge Detection algorithm is used to detect the edges in a given image.


For more info about the Canny Edge Detection Algorithm:
Canny Edge
Detector


Applying the Canny Edge detector to the scene image gives us this result:



Projective Transformation



The Projective Transformation technique is used to transform an image from a perspective
into a 2D overhead view.

For more info about the Projective Transformations:
Projective Transformations


The bounds for the Projective Transformation are determined and then highlighted in red for a visual representation.



Once the Projective Transformation is completed, the result looks like the image shown below.



K-Means Clustering



K-Means Clustering will be used to find 2 points in the transformed image that
correspond to the center points of each of the target blocks.

For more info about K-Means Clustering:
K-Means Clustering


Setting K=2 and using the pixels in the target blocks as data points, we get two points corresponding to the centers
of the target blocks, which are marked by the red dots.


Hough Transformation


The Hough Transformation is used for the last result image to count the number of horizontal and vertical lines between the two highlight
points. These two values are used with the Euclidean Distance Formula to determine the distance between the two target blocks.

For more info about the Hough Transformation:
Hough Transform