Hi guys,I am a frensh man in opencv developers,I read the book “Mastering OpenCV with Practical Computer Vision Projects”,in the three character,I find a problem,the book use ORB as detector,Freak as descriptorextractor,and the BFMatcher as matcher,when i call the knnMatch function,the program pop a bug。here is my code:
cv::Mat patternImg = cv::imread("starry_night_small.jpg", 0);//starry_night
cv::Mat testImg = cv::imread("starry_night_test.jpg", 0);
std::vector<cv::KeyPoint> queryKeypoints;
std::vector<cv::KeyPoint> trainKeypoints;
std::vector<std::vector<cv::DMatch>> matches;
cv::Mat queryDescriptor;
cv::Mat trainDescriptor;
cv::ORB detector(1000);
cv::FREAK extractor(false,false);
cv::BFMatcher matcher(cv::NORM_HAMMING, true);
detector.detect(patternImg, trainKeypoints);
detector.detect(testImg, queryKeypoints);
extractor.compute(patternImg, trainKeypoints, trainDescriptor);
extractor.compute(testImg, queryKeypoints, queryDescriptor);
matcher.knnMatch(queryDescriptor, trainDescriptor, matches, 1);
cv::imshow("pattern", patternImg);
cout << "matches size-->" << matches.size() << endl;
cv::waitKey(0);
but when i run the program,which break and tell me a error:
OpenCV Error: Assertion failed (K == 1 && update == 0 && mask.empty()) in cv::ba tchDistance, file ......\sources\modules\core\src\stat.cpp, line 2500 ##