Git Product home page Git Product logo

pythonsift's Introduction

PythonSIFT

This is an implementation of SIFT (David G. Lowe's scale-invariant feature transform) done entirely in Python with the help of NumPy. This implementation is based on OpenCV's implementation and returns OpenCV KeyPoint objects and descriptors, and so can be used as a drop-in replacement for OpenCV SIFT. This repository is intended to help computer vision enthusiasts learn about the details behind SIFT.

Update 2/11/2020

PythonSIFT has been reimplemented (and greatly improved!) in Python 3. You can find the original Python 2 version in the legacy branch. However, I strongly recommend you use master (the new Python 3 implementation). It's much better.

Dependencies

Python 3

NumPy

OpenCV-Python

Last tested successfully using Python 3.8.5, Numpy 1.19.4 and OpenCV-Python 4.3.0.

Usage

import cv2
import pysift

image = cv2.imread('your_image.png', 0)
keypoints, descriptors = pysift.computeKeypointsAndDescriptors(image)

It's as simple as that. Just like OpenCV.

The returned keypoints are a list of OpenCV KeyPoint objects, and the corresponding descriptors are a list of 128 element NumPy vectors. They can be used just like the objects returned by OpenCV-Python's SIFT detectAndCompute member function. Note that this code is not optimized for speed, but rather designed for clarity and ease of understanding, so it will take a few minutes to run on most images.

Tutorial

You can find a step-by-step, detailed explanation of the code in this repo in my two-part tutorial:

Implementing SIFT in Python: A Complete Guide (Part 1)

Implementing SIFT in Python: A Complete Guide (Part 2)

I'll walk you through each function, printing and plotting things along the way to develop a solid understanding of SIFT and its implementation details.

Template Matching Demo

I've adapted OpenCV's SIFT template matching demo to use PythonSIFT instead. The OpenCV images used in the demo are included in this repo for your convenience.

python template_matching_demo.py

Questions, Concerns, Bugs

Anyone is welcome to report and/or fix any bugs. I will resolve any opened issues as soon as possible.

Any questions about the implementation, no matter how simple, are welcome. I will patiently explain my code to you.

Original Paper

"Distinctive Image Features from Scale-Invariant Keypoints", David G. Lowe

Definitely worth a read!

Legal Notice

SIFT was patented, but it has expired. This repo is primarily meant for educational purposes, but feel free to use my code any way you want, commercial or otherwise. All I ask is that you cite or share this repo.

You can find the original (now expired) patent here (Inventor: David G. Lowe. Assignee: University of British Columbia.).

pythonsift's People

Contributors

rmislam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.