各位大佬,我正在用Sobel、SIFT feature extraction、Color histogram去做图像分类检索。想输入一张图片去检索相类似的图像,出现了以下错误,请问该怎么解决呢?万分感谢
# Define a function to find similar images
def find_similar_images(image_path, k=5):
# Load input image and compute descriptors
img = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
img = cv2.resize(img, (img_size, img_size))
keypoints, descriptors = sift.detectAndCompute(img, None)
# If no keypoints are found, return an empty list
if descriptors is None:
return []文章来源:https://www.toymoban.com/news/detail-419221.html
# Convert descriptors to np.float32 data type
descriptors = descriptors.astype(np.float32)
# Compute distances between input image descriptors and dataset descriptors
matcher = cv2.FlannBasedMatcher()
matches = matcher.knnMatch(descriptors, data, k=2)
distances = [m[0].distance for m in matches]
文章来源地址https://www.toymoban.com/news/detail-419221.html
到了这里,关于error: OpenCV(4.7.0) :-1: error: (-5:Bad argument) in function ‘knnMatch‘> Overload resolution fail的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!