cheddadi / javacv

Automatically exported from code.google.com/p/javacv
GNU General Public License v2.0
0 stars 0 forks source link

Documentation: OpenCV Error Bad Argument Type in cvarrToMat #441

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. A sample file with three image descriptor files is attached.

An xml descriptor file is loaded from disk using cvLoad. The same descriptor is 
load into two different cvMat object and then compared. (create a 
FlannBasedMatcher object, a DMatch object then call dmatch.match on the two 
matrix objects with the flann)

What is the expected output? What do you see instead?

I expect the two matrix values to match. I see an error

OpenCV Error: Bad argument (Unknown array type) in cvarrToMat, file 
/Users/saudet/projects/javacv-cppjars/opencv-2.4.8/modules/core/src/matrix.cpp, 
line 698
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: 
/Users/saudet/projects/javacv-cppjars/opencv-2.4.8/modules/core/src/matrix.cpp:6
98: error: (-5) Unknown array type in function cvarrToMat

What version of the product are you using? On what operating system?
         Environment: Mac OS x 10.9, Java 7 u 51, OpenCV 2.4.8, JavaCV 0.7

Please provide any additional information below.

I am certain that this code worked on version 0.5 of JavaCV with OpenCV 2.4.2

I note that the final object in the test file is null. I also tried
      opencv_core.CvMat mask = new opencv_core.CvMat();
      mask.zero();
      matcherM1I1.match(matrix1, matrix2,matchesM1I1,mask);
which resulted in the same error message.

Sorry about the yml file. I didn't realize until upload that it was larger 
(1.2M uncompressed)

Thanks

Paul

Original issue reported on code.google.com by pstus...@gmail.com on 7 Mar 2014 at 1:57

Attachments:

GoogleCodeExporter commented 8 years ago
Please mark this as either closed or documentation.

This might be a documentation issue rather than a code issue. Further 
investigation identified that this code worked with the 0.3 version and 
independent install of 2.4.2. Reading the javacv_0.7 source code suggested a 
change that I tried and it worked. Modifying the knnMatch statement to use a 
null CvMat solves the error message problem.

Change line 74 of MatrixTest.java
from
 matcherM1I1.knnMatch(matrix1,matrix2,vMatchesM1I1,1,new opencv_core.CvMat(),true);
to
 matcherM1I1.knnMatch(matrix1,matrix2,vMatchesM1I1,1,null,true);

Resolves the issue.

Thanks 

Original comment by pstus...@gmail.com on 10 Mar 2014 at 9:44

GoogleCodeExporter commented 8 years ago
Ah, I see, thanks for the update! The problem is that "new CvMat()" doesn't 
actually initialize anything because it's a C struct. However, "new 
CvMat(null)" does that we need because this means no memory gets allocated at 
all, which forces the called function to allocate and initialize everything for 
us.

In any case, I'm working on wrappers that are closer to the original C++ API:
    http://code.google.com/p/javacpp/wiki/Presets
This should resolve these kinds of issues...

Original comment by samuel.a...@gmail.com on 16 Mar 2014 at 1:01

GoogleCodeExporter commented 8 years ago
The latest release of JavaCV 0.8 now maps the C++ API of OpenCV more closely, 
so using a Mat object directly should fix this issue. There are a lot of other 
changes with this release, so please make sure to read the news release here:
    http://bytedeco.org/release/2014/04/28/first-release.html

Incidentally, the project is now hosted on GitHub:
    https://github.com/bytedeco/javacv

Thanks for reporting!

Original comment by samuel.a...@gmail.com on 29 Apr 2014 at 1:42