Reputation: 45
I am finding similarity between two images. My code is
img1 = cv2.imread(os.path.join("/home/atul/Documents/Data/objectdetection/imboxes1/images000.jpeg/car0.jpg"))
img2 = cv2.imread(os.path.join("/home/atul/Documents/Data/objectdetection/frames1/images000.jpeg"))
sift = cv2.xfeatures2d.SIFT_create()
kp1, des1 = sift.detectAndCompute(img1,None)
kp2, des2 = sift.detectAndCompute(img2,None)
FLANN_INDEX_KDTREE = 0
index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
search_params = dict(checks = 50)
flann = cv2.FlannBasedMatcher(index_params, search_params)
matches = flann.knnMatch(des1,des2,k=2)
The error i am facing is-
error Traceback (most recent call last) in () ----> 1 matches = flann.knnMatch(des1,des2,k=2) error: /feedstock_root/build_artefacts/work/opencv-3.1.0/modules/python/src2/cv2.cpp:163: error: (-215) The data should normally be NULL! in function allocate'
How can i resolve this? Please suggest
Thanks!
Upvotes: 1
Views: 241
Reputation: 56
In your code please check your path as your extension is irrelevant "/home/atul/Documents/Data/objectdetection/imboxes1/images000.jpeg/car0.jpg" please change the images000.jpeg to simple folder images000/car0.jpg
Also check the size of query image should be smaller than that of original image
Upvotes: 0