OpenCV Error: Assertion failed (queryDescriptors.type() == trainDescCollection[0].type()) in knnMatc

確認兩個:spa

一、圖像是灰度的code

// Read in the imageip

Mat img = imread(entryPath.string(), 1);string

cvtColor(img, img, CV_BGR2GRAY);it

二、描述子要是CV_8UC1形式的(在以前用描述子造成詞袋時,描述子格式有轉換爲CV_32F過)。io

cv::Mat dictionary = bowTrainer.cluster();opencv

cv::Mat uDictionary;class

dictionary.convertTo(uDictionary, CV_8UC1);im

bowDE.setVocabulary(uDictionary);word

仍然有疑惑詳見:https://answers.opencv.org/question/17460/how-to-use-bag-of-words-example-with-brief-descriptors/

相關文章
相關標籤/搜索