__init__.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*-
00003 
00004 import math
00005 
00006 import cv2
00007 import siftfastpy
00008 
00009 
00010 def get_sift_keypoints(img):
00011     """Get sift keypoints from image
00012     Parameters
00013     ----------
00014     img: array-like
00015         Img from which we get sift keypoints
00016 
00017     Returns
00018     -------
00019     frames: numpy.ndarray
00020         each row has [col, row, orientation, scale] in this order
00021 
00022     desc: numpy.ndarray
00023         descriptors of each frame
00024     """
00025     siftimg = siftfastpy.Image(img.shape[1], img.shape[0])
00026     siftimg.SetData(img)
00027     frames, desc = siftfastpy.GetKeypoints(siftimg)
00028     return frames, desc
00029 
00030 
00031 def draw_sift_frames(img, frames):
00032     """
00033     Parameters
00034     ----------
00035     img: array-like
00036         Gray-scale image
00037     frames: numpy.ndarray
00038         each row has [col, row, orientation, scale] in this order
00039     """
00040     if len(img.shape) > 2:
00041         raise ValueError('input image should be gray-scale')
00042 
00043     keypoints = []
00044     for frame in frames:
00045         col, row, ori, scale = frame
00046         angle = ori / math.pi * 180
00047         kp = cv2.KeyPoint(x=col, y=row, _size=scale, _angle=angle)
00048         keypoints.append(kp)
00049     dst = cv2.drawKeypoints(img, keypoints,
00050                             flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
00051     return dst


imagesift
Author(s): Rosen Diankov (rdiankov@cs.cmu.edu), Kei Okada
autogenerated on Wed Sep 16 2015 04:36:33