带词袋的 ORB FeatureDetector
ORB FeatureDetector with Bag Of Words
BOWImgDescriptorExtractor
必须接收 32F,所以 SURF
或 SIFT
必须用于 DescriptorExtractor
,但对于 FeatureDetector
肯定可以任何你想要的,对吗?
我只是需要在这里澄清一下,我只见过有人说 "You can't use ORB
with Bow
" 但是在检测特征时,为什么使用哪个很重要?
我认为这无关紧要。您可以使用任意方法进行特征点检测(即 ORB、FAST、SIFT、SURF 等)。
问题可能出在下一步,从特征点描述,原因在their answer here关大说:
The link you posted, gives one possibilty to solve the issue of binary descriptors by simple conversion to float (CV_32F) and relies on the fact that OpenCV's k-means algorithm can only deal with CV_32F and uses L2-distance for comparison. Thus, the binary descriptors may however also cluster in a wrong way (since actually you want to have a Hamming distance measure)!
这就是为什么建议使用 SIFT/SURF 描述符的原因。但除此之外,您可以将不同类型的特征点检测器与不同类型的描述符混合使用。
粗略地说,与您的标题问题相关的 pseudo-code 是:
# Construct vocabulary
bow_trainer = cv2.BOWKMeansTrainer(50)
bow_trainer.add(np.float32(descriptors))
vocab = bow_trainer.cluster().astype(descriptor.dtype)
# Create an object for computing global image BoW descriptors
bow_descr = cv2.BOWImgDescriptorExtractor(ORBdetector, CV2.BFMatcher(CV.NORM_HAMMING))
bow_descr.setVocabulary(vocab)
# Load an image, find keypoints, compute global image descriptor
img = cv2.imread("PathtoImage", ...)
keypoints = detector.detect(img,None)
description = bow_descr.compute(img, kps)
# Visualization
plt.figure( ...)
# Distance calculation (assuming you have two histograms, stored each in the "description" variable)
dist = 1 - cv2.compareHist(pic1.description, pic2.description, cv2.HISTCMP_CORREL)
BOWImgDescriptorExtractor
必须接收 32F,所以 SURF
或 SIFT
必须用于 DescriptorExtractor
,但对于 FeatureDetector
肯定可以任何你想要的,对吗?
我只是需要在这里澄清一下,我只见过有人说 "You can't use ORB
with Bow
" 但是在检测特征时,为什么使用哪个很重要?
我认为这无关紧要。您可以使用任意方法进行特征点检测(即 ORB、FAST、SIFT、SURF 等)。
问题可能出在下一步,从特征点描述,原因在their answer here关大说:
The link you posted, gives one possibilty to solve the issue of binary descriptors by simple conversion to float (CV_32F) and relies on the fact that OpenCV's k-means algorithm can only deal with CV_32F and uses L2-distance for comparison. Thus, the binary descriptors may however also cluster in a wrong way (since actually you want to have a Hamming distance measure)!
这就是为什么建议使用 SIFT/SURF 描述符的原因。但除此之外,您可以将不同类型的特征点检测器与不同类型的描述符混合使用。
粗略地说,与您的标题问题相关的 pseudo-code 是:
# Construct vocabulary
bow_trainer = cv2.BOWKMeansTrainer(50)
bow_trainer.add(np.float32(descriptors))
vocab = bow_trainer.cluster().astype(descriptor.dtype)
# Create an object for computing global image BoW descriptors
bow_descr = cv2.BOWImgDescriptorExtractor(ORBdetector, CV2.BFMatcher(CV.NORM_HAMMING))
bow_descr.setVocabulary(vocab)
# Load an image, find keypoints, compute global image descriptor
img = cv2.imread("PathtoImage", ...)
keypoints = detector.detect(img,None)
description = bow_descr.compute(img, kps)
# Visualization
plt.figure( ...)
# Distance calculation (assuming you have two histograms, stored each in the "description" variable)
dist = 1 - cv2.compareHist(pic1.description, pic2.description, cv2.HISTCMP_CORREL)