Javacv: save keypoints and descriptor

Created on 27 Jun 2017  路  3Comments  路  Source: bytedeco/javacv

Hello

After a keypoints detection, I would like to save the keypoints (KeyPointVector) and descriptors (Mat)
currently using version 1.3.1
I tried to do like that (sorry if I am very wrong) - getImageDescriptors() returns my descriptor org.bytedeco.javacpp.opencv_core$Mat[width=61,height=591,depth=8,channels=1]

        FileStorage fs = new FileStorage("./kp.xml",FileStorage.WRITE);
        fs.writeObj("data", getImageDescriptors());     
        fs.close();

But I get OpenCV Error: Bad argument (Unknown object) in cvWrite, file C:\projects\bytedeco\javacpp-presets\opencv\cppbuild\windows-x86_64\opencv-3.1.0\modules\core\src\persistence.cpp, line 5000

I have no issue if I use fs.writeObj("data", new Mat());

Am I complely wrong ? or is there a better way to deserialize / serialize that ?

Thanks a LOT !

question

Most helpful comment

Actually I don't know. :-s

Anyway, one good night of sleeps and things get easy and working :

        FileStorage fs = new FileStorage("./kp.xml",FileStorage.WRITE);
        org.bytedeco.javacpp.opencv_core.write(fs, "desc", getImageDescriptors());
        org.bytedeco.javacpp.opencv_core.write(fs, "kp", getImageKeypoints());
        fs.release();

And I am getting

 <?xml version="1.0"?>
 <opencv_storage>
 <desc type_id="opencv-matrix">
   <rows>591</rows>
   <cols>61</cols>
   <dt>u</dt>
   <data>
     160 23 0 0 128 1 8 70 223 255 128 139 199 129 255 119 0 0 0 0 0 15 0

Sorry for the questions, but did not find any javacv example, and was really stuck after a while ...
Thanks

All 3 comments

Does the same thing work in C++?

Actually I don't know. :-s

Anyway, one good night of sleeps and things get easy and working :

        FileStorage fs = new FileStorage("./kp.xml",FileStorage.WRITE);
        org.bytedeco.javacpp.opencv_core.write(fs, "desc", getImageDescriptors());
        org.bytedeco.javacpp.opencv_core.write(fs, "kp", getImageKeypoints());
        fs.release();

And I am getting

 <?xml version="1.0"?>
 <opencv_storage>
 <desc type_id="opencv-matrix">
   <rows>591</rows>
   <cols>61</cols>
   <dt>u</dt>
   <data>
     160 23 0 0 128 1 8 70 223 255 128 139 199 129 255 119 0 0 0 0 0 15 0

Sorry for the questions, but did not find any javacv example, and was really stuck after a while ...
Thanks

Awesome. Please consider contributing a small sample for that! Thanks
https://github.com/bytedeco/javacv/tree/master/samples

Was this page helpful?
0 / 5 - 0 ratings

Related issues

The-Crocop picture The-Crocop  路  5Comments

y4nnick picture y4nnick  路  3Comments

Bahramudin picture Bahramudin  路  3Comments

RaGreen picture RaGreen  路  4Comments

cansik picture cansik  路  4Comments