将vector <keypoint>转换为Mat,但是前两个元素丢失了

时间:2018-09-19 17:28:58

标签: opencv mat keypoint

我正在C ++中使用OpenCV 3.4.1,正在处理一些图像数据。为了执行处理,我将OpenCV返回的KeyPoints转换为Mats,然后转换为数组。我有一个将KeyPoints转换为Mat的函数,但是在此过程中,有时会丢失前两行数据。这并非一直都发生,这尤其令人困惑。有时,数据被完美复制。我在下面附加了我的函数,以及在无法正确转换时的输出示例。请注意,输出值与1280x960 .pgm图像有关。

void convKeyPoints2Mat(vector<KeyPoint> kp, Mat& newMat) {  

// Variable Declarations
vector<Point2f> points;
vector<KeyPoint>::iterator it;

// Convert vector<KeyPoint> type to type Point2f
for( it= kp.begin(); it!= kp.end();++it)
{
    points.push_back(it->pt);
}

// Convert type Point2f to type Mat
newMat = Mat(points);

return;
}

关键点输出:

[{Keypoint output 1

垫子输出:

Mat output

感谢您的帮助!

0 个答案:

没有答案
相关问题