将关键点转换为mat或将它们保存到文本文件opencv [英] convert keypoints to mat or save them to text file opencv
本文介绍了将关键点转换为mat或将它们保存到文本文件opencv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经提取了(opencv开源)中的SIFT功能,它们被提取为关键点。现在,我想将它们转换为矩阵(用他们的x,y坐标)或保存在一个文本文件...
I have extracted SIFT features in (opencv open source) and they are extracted as keypoints. Now, I would like to convert them to Matrix (With their x,y coordinates) or save them in a text file...
在这里,代码提取关键点,现在我想知道如何将它们转换为MAT或保存在txt,xml或yaml ...
Here, you can see a sample code for extracting the keypoints and now I would like to know how convert them to MAT or save them in txt, xml or yaml...
cv::SiftFeatureDetector detector;
std::vector<cv::KeyPoint> keypoints;
detector.detect(input, keypoints);
推荐答案
转换为cv :: Mat如下。 / p>
Convert to cv::Mat is as follows.
std::vector<cv::KeyPoint> keypoints;
std::vector<cv::Point2f> points;
std::vector<cv::KeyPoint>::iterator it;
for( it= keypoints.begin(); it!= keypoints.end();it++)
{
points.push_back(it->pt);
}
cv::Mat pointmatrix(points);
写入filestorage是
Write to filestorage is
cv::FileStorage fs("test.yml", cv::FileStorage::WRITE);
cv::FileStorage fs2("test2.xml", cv::FileStorage::WRITE);
detector.write(fs);
detector.write(fs2);
这篇关于将关键点转换为mat或将它们保存到文本文件opencv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文