When loading KeyPoint from XML, the class_id is lost [closed]

asked 2015-09-08 22:46:44 -0500

Metalzero2 gravatar image

Hello all,

When I use point extractor (specifically I use AKAZE but it is similar to SIFT) I use the FileStorage to save it in a .XML file. After I extract the points, I manually give each point a class_id. Later on I save it in a xml file. After it is saved, I look at the xml file and everything is saved correctly. Then I try to load it and everything loads correctly except the class_id. I manually checked everything and only the class_id is wrong. Not only it is wrong but far exceeds the limits of a int (which the class_id is). For example

  • I saved class_id = 1 and when I load it I get class_id = 1065353216
  • I saved class_id = 2 and when I load it I get class_id = 1073741824
  • I saved class_id = 3 and when I load it I get class_id = 1077936128

Here is the code of how I load it

vector<KeyPoint> temp_kpts;
FileStorage fs("Myfile.xml", FileStorage::READ);
fs["KeyPoints_1"] >> temp_kpts;
cout<<"KeyPoitn ID is --> "<< temp_kpts[0].class_id <<endl;
cout<<"KeyPoitn ID is --> "<< temp_kpts[1].class_id <<endl;
cout<<"KeyPoitn ID is --> "<< temp_kpts[2].class_id <<endl;

Does anybody know what is going on?

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-11 13:00:45.897818


There is abug in opencv. you can read this post (first answer and comments)

LBerger gravatar imageLBerger ( 2015-09-09 00:57:36 -0500 )edit

@LBerger Is there some bug report ?

Metalzero2 gravatar imageMetalzero2 ( 2015-09-09 06:38:01 -0500 )edit

@Metalzero2 I cannot retrieve it. @berak Is it same Bug?

LBerger gravatar imageLBerger ( 2015-09-09 07:05:09 -0500 )edit

Do you have these line in the xml file

<opencv_storage> <cascade> <stagetype>BOOST</stagetype> <featuretype>SIFT</featuretype> ....... and a few other line after this ??

If you don't then you don't have the correct format of this XML file. So if you need to have an idea about these lines open any xml file of those present in opencv directory where you extracted it, and read the syntax, you may find some interesting.

tes gravatar imagetes ( 2016-03-31 14:34:03 -0500 )edit

@tes using this :

akaze->detectAndCompute(im, noArray(), temp_kpts, desc1);
FileStorage fs("Myfile.xml", FileStorage::WRITE);
fs << "AKAZE"<<temp_kpts;

I have got :


<?xml version="1.0"?>
  4.1441625976562500e+002 2.8969802856445313e+001


LBerger gravatar imageLBerger ( 2016-03-31 14:50:56 -0500 )edit

<opencv_storage> <cascade type_id="opencv-cascade-classifier"><stagetype>BOOST</stagetype> <featuretype>SIFT</featuretype> <height>24</height> <width>24</width> <stageparams> <maxweakcount>211</maxweakcount></stageparams> <featureparams> <maxcatcount>0</maxcatcount></featureparams> <stagenum>25</stagenum> <stages>

This is how it should look like. To be honest I have not used AKAZE yet, but try what I wrote, it may help you

tes gravatar imagetes ( 2016-03-31 14:56:57 -0500 )edit