How to write Keypoints into document of txt
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?
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;
Asked: 2012-07-13 09:18:22 -0600
Seen: 1,922 times
Last updated: Jul 13 '12