himanshukandwal / javacv

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

Loading cvMat from XML File #113

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

I'm trying to execute code that work very will in C++ :

        try {
            CvMat test  = opencv_core.cvCreateMat(1,3,opencv_core.CV_32FC1);
            test.put(0, 0, 1);
            test.put(0, 1, 8);
            test.put(0, 2, 5);
            opencv_core.cvSave("test.xml",test);
            opencv_core.cvSave("test.xml",test);
            CvMat testLoad = (CvMat)opencv_core.cvLoad("test.xml");
} catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

But i have all the time this exception launched :

java.lang.ClassCastException: com.googlecode.javacpp.Pointer cannot be cast to 
com.googlecode.javacv.cpp.opencv_core$CvMat

How can i fix that?
thanks,

Original issue reported on code.google.com by Kharroub...@gmail.com on 3 Oct 2011 at 3:12

GoogleCodeExporter commented 8 years ago
As explained in the README.txt file, we need to cast Pointer objects this way:
    CvMat testLoad = new CvMat(opencv_core.cvLoad("test.xml"));
Please post other questions you may have on the mailing list, thank you

Original comment by samuel.a...@gmail.com on 6 Oct 2011 at 12:39