我正在阅读使用Opencv训练KNN的教程。代码是为opencv3编写的,但我需要在opencv2中使用它。最初的培训是:
cv2.ml.KNearest_create().train(npaFlattenedImages, cv2.ml.ROW_SAMPLE, npaClassifications)
我试着用这个:
^{pr2}$但错误是:
Unsupported index array data type (it should be 8uC1, 8sC1 or 32sC1) in function cvPreprocessIndexArray
在这里,似乎使full code适用于OpenCV 2.4.13的更改:
int tflag
,文档说:“只支持CV_ROW_SAMPLE
数据布局”。npaClassifications
作为下一个参数sampleIdx
引起的。在修复后的其他错误:
^{} 只返回2个值:
→ contours, hierarchy
(无论如何,您不需要第三个值,imgContours
)。KNearest.findNearest()
是^{现在的结果是:
Ulrich Stern already did me a favor to provide a raw diff。在
相关问题 更多 >
编程相关推荐