Ask Your Question
0

fail to load keypoints from .yml file

asked 2013-09-18 14:44:18 -0600

mike gravatar image

updated 2013-09-19 05:36:22 -0600

berak gravatar image

Hi,

I want to find keypoints in different images and save them on my hard disk. The saving part works very well. To save the keypoints I use the following:

    Mat it;
    it = imread( "pic1.jpg", IMREAD_GRAYSCALE);
    vector<KeyPoint> keypoints;
    detector.detect( (it), keypoints );
    FileStorage fs("keypoint1.yml", FileStorage::WRITE);
    write( fs , "keypoint", keypoints );
    fs.release();

When I try to read the file I fail with this :

            vector<KeyPoint> keypoint1s;
            FileStorage fs2("keypoint1.yml", FileStorage::READ);
            FileNode kptFileNode = fs2["keypoint1"];
            read( kptFileNode, keypoint1s );
            fs2.release();

If I do it like that, "keypoint1s" remains empty. Would be great if somebody knows how to fix this!

Thanks!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-09-19 05:34:53 -0600

berak gravatar image

you write:

write( fs , "keypoint", keypoints );

you read:

FileNode kptFileNode = fs2["keypoint1"];

see the mismatch ? you have to use the same "key" for both, ie "keypoint", not "keypoint1"

btw, the whole could be rewritten like:

FileStorage fs("keypoint1.yml", FileStorage::WRITE);
fs << "keypoint" << keypoints;
fs.release();

vector<KeyPoint> keypoint1s;
FileStorage fs2("keypoint1.yml", FileStorage::READ);
fs2["keypoint"] >> keypoint1s;
fs2.release();
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-09-18 14:44:18 -0600

Seen: 906 times

Last updated: Sep 19 '13