我发现两幅图像之间有相似之处。我的代码是
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)
我面临的错误是 -
错误回溯(最近一次调用最后一次) in() ----> 1匹配= flann.knnMatch(des1,des2,k = 2)错误:/feedstock_root/build_artefacts/work/opencv-3.1.0/modules/python/src2/cv2.cpp:163: 错误:( - 215)数据通常应为NULL!在函数中分配'
我该如何解决这个问题?请建议
谢谢!
答案 0 :(得分:0)
在您的代码中,请检查您的路径,因为您的扩展程序无关紧要 “/home/atul/Documents/Data/objectdetection/imboxes1/images000.jpeg/car0.jpg” 请将images000.jpeg更改为简单文件夹images000 / car0.jpg
同时检查查询图像的大小应小于原始图像的大小