我儘量讓描述符的字典中以OpenCV的。 當我使用BOWKmeansTrainer的方法.cluster(),我的應用程序將引發未處理的異常爲什麼我得到未處理的異常時,試圖計算集羣
OpenCV Error: Assertion failed (data.dims <= 2 && type == CV_32F && K > 0) in un known function, file ......\src\opencv\modules\core\src\matrix.cpp, line 2485 Unknown exception
我不明白爲什麼會發生。我試圖改變參數,但它沒有幫助。
你能不能給我一些想法如何,我可以解決這個問題?
INT主(INT ARGC,CHAR *的argv []){
const int countClusters = 2;
vector<string> fileList;
GetFilesInFolder(folder_one, fileList);
vector<bool> trainMask(fileList.size());
InitRandomBoolVector(trainMask, 0.1);
Ptr<FeatureDetector> keypointsDetector = FeatureDetector::create("HARRIS");
Ptr<DescriptorExtractor> descriptorsExtractor = DescriptorExtractor::create("BRIEF");
Mat descriptors;
Mat voc;
TermCriteria tc(TermCriteria::COUNT + TermCriteria::EPS, 10, 0.001);
BOWKMeansTrainer bowTrainer(vocSize,tc);
for(int i = 0;i < filesList.size();i++)
{
if(is_voc.at(i))
{
vector<KeyPoint> keypoints;
Mat image = imread(filesList.at(i));
keypointsDetector->detect(image,keypoints);
descriptorsExtractor->compute(image,keypoints,descriptors);
bowTrainer.add(descriptors);
}
}
try
{
voc = bowTrainer.cluster();
}
catch(std::exception ex)
{
printf(ex.what());
}
return 0;
}
異常消息告訴你的問題是什麼。慢慢仔細閱讀。 – karlphillip
我幫助他:'尺寸<= 2'和'類型== CV_32F'和'K> 0'。所以要麼選擇其他類型,要麼獲得更多維度。 –
我有一個很難理解的例外。特別是,我不明白「<= 2」的含義。有沒有人建議仔細閱讀例外,誰也能解釋這些尺寸是什麼? –