Storing feature information (keypoints, descriptors)

asked 2013-08-14 11:11:41 -0500

mada gravatar image


I have run into a problem while trying to store image features in a file. I am using GPU version of SURF algorithm. I have calculated keypoints and descriptors and they are both stored in a gpu::GpuMat structure. More precisely, I have a vector like this:

struct featureInfo
    gpu::GpuMat keypoints;
    gpu::GpuMat descriptors;
    std::string frameName;
} frameData;

std::vector<featureInfo> data;

It contains keypoints/descriptors and other info for hundreds of frames. What would be the easiest (or fastest) way to store it to a file?

I guess gpu::GpuMat files need to be downloaded to CPU before being stored? And, if that is the case, is there a way to upload descriptors back to GPU without having to calculate them again?


edit retag flag offensive close merge delete


You will have to download them from the GPU to CPU before you save them. As for uploading them, you deserialize your key point and descriptor from your file and, key points into Keypoint vector and your descriptors into a Mat.

const char * filePath =; cv::FileStorage fs2(filePath, cv::FileStorage::READ);

std::vector<cv::KeyPoint > keypoints_1;
cv::Mat descriptors_1;

cv::FileNode kptFileNode = fs2["keypoints_1"];
read( kptFileNode, keypoints_1 );
cv::FileNode descFileNode = fs2["descriptors_1"];
read( descFileNode, descriptors_1 );

JasonHonduras gravatar imageJasonHonduras ( 2015-10-31 17:18:26 -0500 )edit