Ask Your Question
3

java.lang.IllegalArgumentException: Incomatible Mat from MatOfDMatch

asked 2013-03-24 17:01:01 -0500

collers gravatar image

I'm struggling with some C++ code I'm trying to convert to Java/Scala. The original was:

std::vector<std::vector<cv::DMatch> > matches;
cv::Ptr<cv::DescriptorMatcher> descriptorMatcher;
descriptorMatcher = new cv::BruteForceMatcher<cv::HammingSse>();
descriptorMatcher->radiusMatch(descriptors2,descriptors,matches,100.0);

The Java/Scala looks like this:

val matches = new java.util.ArrayList[MatOfDMatch]
val matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMING)
matcher.radiusMatch(descriptors2, descriptors1, matches, 100F)

When this is run I'm getting the error:

Exception in thread "main" java.lang.IllegalArgumentException: Incomatible Mat
    at org.opencv.core.MatOfDMatch.<init>(MatOfDMatch.java:31)
    at org.opencv.utils.Converters.Mat_to_vector_vector_DMatch(Converters.java:690)
    at org.opencv.features2d.DescriptorMatcher.radiusMatch(DescriptorMatcher.java:561)

Looks like the code is using checkVector to validate that the inner Mat's returned by the underlying C++ code are a vector and they obviously aren't. But the C++ works so why not the Java? Any help/advice much appreciated.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-04-04 08:32:29 -0500

Andrey Pavlenko gravatar image

The code passing results from native level to Java contains an error: when some vector<DMatch> is empty an exception is raised. The coming 2.4.5 will include the fix.

edit flag offensive delete link more
0

answered 2013-05-23 00:17:24 -0500

keltik gravatar image

Although Mr. Pavlenko was clear and has answered the question, I want to add something, namely using this code:

FeatureDetector fd = FeatureDetector.create(FeatureDetector.FAST);
...
fd.detect(myImageList,myImageKeyPointList);

If myImageKeyPointList is empty also an exception is raised (i guess that is the same reason as Mr. Pavlenko mentioned in his post):

Exception in thread "main" java.lang.IllegalArgumentException: Incomatible Mat
    at org.opencv.core.MatOfKeyPoint.<init>(MatOfKeyPoint.java:31)
    at org.opencv.utils.Converters.Mat_to_vector_vector_KeyPoint(Converters.java:591)
    at org.opencv.features2d.FeatureDetector.detect(FeatureDetector.java:229)
    ...

Besides i am using openCV 2.4.5 and java.

edit flag offensive delete link more

Comments

Andrey Pavlenko gravatar imageAndrey Pavlenko ( 2013-06-08 04:12:49 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-03-24 17:01:01 -0500

Seen: 810 times

Last updated: May 23 '13