Skip to content

Python Implementation of Bag of Features for Image Recongnition using OpenCV and sklearn

Notifications You must be signed in to change notification settings

hugos94/bag-of-features

Repository files navigation

Bag of Features

Python Implementation of Bag of Words for Image Recongnition using OpenCV and sklearn

Original author

This is a clean fork of bikz05's work.

Installation

Dependencies:

  • Python (>= 3.3)
  • Numpy (>= 1.6.1)
  • Scipy (>= 0.9)
  • Scikit Learn

Note

I am using OpenCV3 and a number of things have been moved to the opencv_contrib repo. Make sure you install the xfeatures2d module to be able to use SIFT.

Training the Classifier

python learn.py -t dataset/train -c dataset/model

Testing the Classifier

  • Testing a single image
python predict.py -t dataset/test/class/image.extension --show
  • Testing a testing dataset
python predict.py -t ../dataset/test/ -m ../dataset/model -r ../dataset/results --verbose

The --visualize flag will display the image with the corresponding label printed on the image/

Troubleshooting

If you get

AttributeError: 'LinearSVC' object has no attribute 'classes_'

error, the simply retrain the model.

About

Python Implementation of Bag of Features for Image Recongnition using OpenCV and sklearn

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages