I'm implementing a simple bag-of-words matching system, where I have
10,100 "clusters" and I am trying to match a single feature vector to the closest cluster. This works for a smaller number of clusters, but I need it to work for this larger set.
Essentially, I put all
10,100 clusters into a vector of
cv::Mat objects, each of which is
1 x 16. Then, I add these to the BFMatcher as follows:
cv::BFMatcher matcher(cv::NORM_HAMMING); bf_matcher.add(clusters_for_matching);
Finally, given a new
1 x 16 feature vector to match, I do the following:
std::vector<cv::DMatch> matches; bf_matcher.match(feature_vector, matches);
The error I get is the following:
OpenCV Error: Assertion failed ((int64)imgCount*IMGIDX_ONE < INT_MAX) in unknown function, file ......\src\opencv\modules\features2d\src\matchers.cpp, line 360
My question is simple, what is going on and how can I make this work? It's pretty clear that for some reason it considers
10,100 to be too many training instances, but that is extremely small in comparison to some other applications.
answered 2013-02-09 09:09:50 -0500Guanta
Hmm, very weired, I am doing nearly the same without a problem. So let's look at matchers.cpp: imgCount would be the numbers of clusters, i.e. 10100 in your case. According to matchers.cpp IMGIDX_ONE = (1 << 18) = 2^18 = 262144. So 10100*262144 = 2 647 654 400. If INT_MAX is 2^31 - 1 = 2 147 483 647 the assertion fails. However, depending on your system and the compiler you use, see http://stackoverflow.com/questions/9257065/int-max-in-32-bit-vs-64-bit-environment, INT_MAX can vary. I'm not very sure about the meaning of this assertion, but maybe this assertion could be changed to UINT_MAX then you wouldn't have a problem, i.e. changing INT_MAX to UINT_MAX in matchers.cpp and recompiling opencv may solve your problem for now.
Asked: 2013-02-07 13:22:17 -0500
Seen: 376 times
Last updated: Feb 09 '13