Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

to get th coordinates of sift keypoints

import cv2 import numpy as np

img = cv2.imread('info-tabs3.jpg') gray= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

sift = cv2.xfeatures2d.SIFT_create() kp = sift.detect(gray,None) pts = np.float([kp[idx].pt for idx in len(kp)]).reshape(-1, 1, 2) print 'The list of detected keypoints is:' pts.pt

img=cv2.drawKeypoints(gray,kp,img)

cv2.imwrite('sift_keypoints.jpg',img) cv2.imshow('window',img) cv2.waitKey(10000) cv2.destroyAllWindows()

this is my code to detect and display keypoints (im using opencv 3.1.0 and python 2.7 ) the erreor displayed is : File "sift.py", line 10 print 'The list of detected keypoints is:' pts.pt ^ SyntaxError: invalid syntax as you can see im getting a syntax error, any corrections in the code then please do tell .

click to hide/show revision 2
None

updated 2018-06-17 03:48:52 -0600

berak gravatar image

to get th coordinates of sift keypoints

this is my code to detect and display keypoints (im using opencv 3.1.0 and python 2.7 )

import cv2
import numpy as np

np

img = cv2.imread('info-tabs3.jpg') gray= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

sift = cv2.xfeatures2d.SIFT_create() kp = sift.detect(gray,None) pts = np.float([kp[idx].pt for idx in len(kp)]).reshape(-1, 1, 2) print 'The list of detected keypoints is:' pts.pt

pts.pt img=cv2.drawKeypoints(gray,kp,img) cv2.imwrite('sift_keypoints.jpg',img) cv2.imshow('window',img) cv2.waitKey(10000) cv2.destroyAllWindows()

img=cv2.drawKeypoints(gray,kp,img)

cv2.imwrite('sift_keypoints.jpg',img) cv2.imshow('window',img) cv2.waitKey(10000) cv2.destroyAllWindows()

this is my code to detect and display keypoints (im using opencv 3.1.0 and python 2.7 ) the erreor displayed is : :

File "sift.py", line 10
    print 'The list of detected keypoints is:' pts.pt
     ^
SyntaxError: invalid syntax

as you can see im getting a syntax error, any corrections in the code then please do tell .