Ask Your Question
0

How to write Keypoints into document of txt

asked 2012-07-13 09:18:22 -0600

Guobiao gravatar image

I detect Keypoints by detector,such as MSER or Surf.I need to write these Keypoints into document(Txt format).But, What should I do?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2012-07-13 09:32:13 -0600

XCoder gravatar image

updated 2012-07-13 10:01:17 -0600

I would recommend using YML rather than txt, because with YML it will be much easier to access data afterwards.

To write in yml file your keypoints and descriptors use this:

 fileString = "keypoints.yml";
 cv::FileStorage fs(fileString, cv::FileStorage::WRITE);

 write(fs,"keyPointsSURF", keypointsSURF);              
 write(fs,"descriptorsSURF", descriptorsSURF);  
fs.release()

It's very simnple to access the data:

    fs.open("keypoints.yml", FileStorage::READ);
        if(fs.isOpened())
        {
            read(fs["descriptorsSURF"], descriptorsSURF); 
            read(fs["keyPointsSURF"], keypointsSURF);   
    }   
fs.release();

The "read" command can be swapped with this too, I personally prefer the "read" method:

fs["descriptorsSURF"] >> descriptorsSURF;
fs["keyPointsSURF"] >> keypointsSURF;
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2012-07-13 09:18:22 -0600

Seen: 1,963 times

Last updated: Jul 13 '12