In [1]:
import sys, os
import numpy as np
import cv2
cv2.startWindowThread()
Out[1]:
In [15]:
img = cv2.imread('j:/dev/opencv_graph/TemcaGraphPy/SampleImages/test1.tif',0)
img8 = np.uint8(img)
print img.shape, img.dtype
In [30]:
#surf
# Create SURF object. You can specify params here or later.
# Set Hessian Threshold to 400
surf = cv2.xfeatures2d.SURF_create()
surf.setUpright(True)
surf.setHessianThreshold(8000)
kp, des = surf.detectAndCompute(img8,None)
len(kp)
Out[30]:
In [32]:
print surf.descriptorSize()
In [31]:
img2 = cv2.drawKeypoints(img,kp,None,(255,0,0),4)
cv2.imshow('surf', img2)
cv2.waitKey(0)
Out[31]:
In [20]:
#sift
sift = cv2.xfeatures2d.SIFT_create()
kp = sift.detect(img8,None)
len(kp)
#imgOut = img8
imgO2 = cv2.drawKeypoints(img8,kp, None, color=(0,255,0), flags=0)
cv2.imwrite('sift_keypoints.jpg',imgO2)
cv2.imshow('imgOut', imgO2)
cv2.waitKey(0)
Out[20]:
In [32]:
cv2.imshow('8bpp', img)
cv2.waitKey(0)
Out[32]:
In [37]:
cv2.imshow('imgOut', imgOut)
cv2.waitKey(0)
Out[37]:
In [17]:
imgOut.shape
Out[17]:
In [18]:
imgOut.dtype
Out[18]:
In [ ]:
cv2.xfeatures2d.