ORB FeatureDetector与袋词

时间:2015-03-03 14:07:12

标签: opencv image-recognition orb

BOWImgDescriptorExtractor必须收到32F,因此SURFSIFT必须用于DescriptorExtractor,但对于FeatureDetector肯定可以是任何你祝,对吧?

我只需要在这里做一些澄清,我只是见过人们说"你不能ORBBow" 但是在检测到这些功能时,为什么使用哪个功能呢?

2 个答案:

答案 0 :(得分:2)

我不会想到这件事。您可以使用任意方法进行特征点检测(即ORB,FAST,SIFT,SURF等)。

问题可能来自下一步,从特征点描述,出于Guanta在their answer here中所述的原因:

  

您发布的链接,通过简单转换为float(CV_32F)来解决二进制描述符问题的可能性,并依赖于OpenCV的k-means算法只能处理CV_32F并使用L2-的事实比较距离。因此,二进制描述符也可能以错误的方式聚集(因为实际上你想要一个汉明距离度量)!

这就是为什么建议使用SIFT / SURF描述符的原因。但除此之外,您可以将不同类型的特征点检测器与不同类型的描述符混合使用。

答案 1 :(得分:1)

大致来说,与标题问题相关的伪代码为:

# 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)
相关问题