加载保存的SURF关键点 [英] Loading saved SURF keypoints

查看:188
本文介绍了加载保存的SURF关键点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在检测图像中的SURF特征,然后将其写入yml文件.然后,我想再次从yml文件中加载功能以尝试检测对象,但此刻我在加载要在图像上绘制关键点时遇到了麻烦.

I am detecting SURF features in an image and then writing them to a yml file. I then want to load the features from the yml file again to try and detect an object but at the moment I'm having trouble loading the keypoints to draw them on an image.

我正在这样写关键点:

cv::FileStorage fs("keypointsVW.yml", cv::FileStorage::WRITE);
write(fs, "keypoints_1", keypoints_1);
fs.release();

我正在尝试像这样阅读它们:

I am trying to read them like so:

cv::FileStorage fs2("keypointsVW.yml", cv::FileStorage::READ);
read(fs2, "keypoints_1", keypoints_1);
fs2.release();

但这会产生很多错误.

检测并绘制代码:

    cv::Mat img_1 = cv::imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
    int minHessian = 400;
    cv::SurfFeatureDetector detector(minHessian);
    std::vector<cv::KeyPoint> keypoints_1;
    detector.detect(img_1, keypoints_1);
    cv::Mat img_keypoints_1;
    //......write code
    //.......read code
    drawKeypoints(img_1, keypoints_1, img_keypoints_1);
    imshow("keypoints_1", img_keypoints_1);

推荐答案

找到了解决方案,如果有人遇到相同的问题,我将在此处发布.

Found the solution, I'll post it here in case anyone else has the same problem.

std::vector<cv::KeyPoint> testPoints;
cv::FileStorage fs2("keypointsVW.yml", cv::FileStorage::READ);
cv::FileNode kptFileNode = fs2["keypointsVW"];
read(kptFileNode, testPoints);
fs2.release();

这篇关于加载保存的SURF关键点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆