SURF + BOWImgDescriptorExtractor + BFMatcher给出类型错误

时间:2016-06-28 05:58:53

标签: python opencv surf

我正在使用opencv-2.4.13和python 2.7。我正在尝试为我的SVM分类器创建训练集。在使用BOWImgDescriptorExtractor时,我收到类型错误。这是代码..

extract = cv2.DescriptorExtractor_create("SURF")
surf = cv2.SURF(400)
matcher = cv2.BFMatcher(cv2.NORM_L2)

BOW = cv2.BOWKMeansTrainer(100)

for ImageName in FileList:
    img = cv2.imread(ImageName,0)
    kp, des = surf.detectAndCompute(img1,None)
    BOW.add(des)
 dictionary = BOW.cluster()

bow_extract = cv2.BOWImgDescriptorExtractor( extract, matcher ) 
bow_extract.setVocabulary( dictionary )

ImageName = FileList[0]
img = cv2.imread(ImageName,0)
kp = surf.detect(img1)
inp = bow_extract.compute(img1,kp)

我收到此错误

Traceback (most recent call last):
  File "Pre_process.py", line 48, in <module>
    inp = bow_extract.compute(img1, surf.detect(img1))
cv2.error:/opencv-2.4.13/modules/core/src/stat.cpp:2481: error: (-215) type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U) in function batchDistance

0 个答案:

没有答案