Ask Your Question
0

unknown dot on using FileStorage to write Mat

asked 2013-09-06 10:53:47 -0500

krammer gravatar image

updated 2013-09-06 11:42:53 -0500

berak gravatar image

I am using the following code to store Mat(SURF features) to a file

  cv::Mat descriptors;
  featureExtractor->compute(image, keypoints, descriptors);
  FileStorage fs("features.yml", FileStorage::WRITE);
  fs<<"oriimage"<<descriptors;

for reading the file, I use

FileStorage fs;
fs.open("features.yml", FileStorage::READ);
Mat m;
fs["oriimage"] >> m;

The Mat is stored and read as: {3., 6., 0., 0., 0., 0., 3., 2., 0., 0., 34.} //Note the .(dot) at the end of each number

while before storing if I do cout << descriptors, it prints the same numbers without the dots.

What is wrong with my code ?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-09-06 11:32:31 -0500

berak gravatar image

updated 2013-09-06 11:35:12 -0500

don't worry, that's ugly but not a real problem. there's nothing wrong with your code.

cout and FileStorage are just using different iomanipulation flags to show the numbers .

SURF (and SIFT) descriptors are indeed float type, so the FileStorage adds all those dots.

#include <iomanip>
int main()
{
    float f = 1.0;
    std::cout << std::showpoint << std::setprecision(1) << f << " " << std::noshowpoint << f << std::endl;
    return 1;
}

1. 1

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-09-06 10:53:47 -0500

Seen: 146 times

Last updated: Sep 06 '13