Our task was to build a machine learning algorithim that could determine if a square was in an image. We decided to use a linear support vector machine as our classifier, that ingested feature vectors extracted using the histogram of gradients algorithim (also known as H.O.G).
Examples of our test data set taken from (https://data.mendeley.com/datasets/wzr2yv7r53/1):
Since the square we were trying to classifiy varied in shape, location, and rotation we had to incorporate additonal techniques such as a sliding window and the image pyramid in order for our histogram of gradient algorithim to correctly extract the feature vectors from the image.
The result of our classifier yielded a 91% success rate. We noticed that the classifer failed to classifiy very small squares correctly. This is due to the image pyramid scaling down the image (zooming out) which works to fit squares that are larger than the sliding window, but not smaller squares. In order to correct this we would need to introduce an image pyramid that also scales the image up, such that smaller squares fill up a larger portion of the sliding window, and more features are extracted.
Example histogram of gradients, prediction label, actual label, and bounding box selected by the algorithim:
Install Python 3 if you have not already (https://www.python.org/downloads/).
When you are ready run the following commands in the terminal at the root folder containing the project.
Install Python packages (only need to run once): pip install -r requirements.txt
python square_detection.py
.
- Run this line in your terminal at the root folder:
jupyter notebook
. It will open up a window in your browser. Look forsquare_detection.ipynb
file and click on it.