convert keypoints to mat or save them to text file opencv

前端 未结 2 1351
执念已碎
执念已碎 2021-01-01 02:23

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

2条回答
  •  -上瘾入骨i
    2021-01-01 03:16

    Convert to cv::Mat is as follows.

    std::vector keypoints;
    std::vector points;
    std::vector::iterator it;
    
    for( it= keypoints.begin(); it!= keypoints.end();it++)
    {
        points.push_back(it->pt);
    }
    
    cv::Mat pointmatrix(points);
    

    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);
    

提交回复
热议问题