小编oct*_*fbr的帖子

使用FLANN匹配从OpenCV SIFT列表中识别图像

应用程序的要点是从已经设置的图像列表中识别图像.图像列表已将SIFT描述符提取并保存在文件中.这里没什么有趣的:

std::vector<cv::KeyPoint> detectedKeypoints;
cv::Mat objectDescriptors;

// Extract data
cv::SIFT sift;
sift.detect(image, detectedKeypoints);
sift.compute(image, detectedKeypoints, objectDescriptors);

// Save the file
cv::FileStorage fs(file, cv::FileStorage::WRITE);
fs << "descriptors" << objectDescriptors;
fs << "keypoints" << detectedKeypoints;
fs.release();
Run Code Online (Sandbox Code Playgroud)

然后设备拍照.SIFT描述符以相同的方式提取.现在的想法是将描述符与文件中的描述符进行比较.我正在使用OpenCV的FLANN匹配器.我试图通过图像来量化相似性.经过整个清单后,我应该有最好的匹配.

const cv::Ptr<cv::flann::IndexParams>& indexParams = new cv::flann::KDTreeIndexParams(1);
const cv::Ptr<cv::flann::SearchParams>& searchParams = new cv::flann::SearchParams(64);

// Match using Flann
cv::Mat indexMat;
cv::FlannBasedMatcher matcher(indexParams, searchParams);
std::vector< cv::DMatch > matches;
matcher.match(objectDescriptors, readDescriptors, matches);
Run Code Online (Sandbox Code Playgroud)

匹配后我明白我得到了特征向量之间最近找到的距离列表.我找到了最小距离,并且使用它我可以计算"好的匹配",甚至可以获得相应点的列表:

// Count the number of mathes where the distance is less than 2 * min_dist
int goodCount …
Run Code Online (Sandbox Code Playgroud)

c++ opencv image-recognition sift flann

6
推荐指数
1
解决办法
6894
查看次数

标签 统计

c++ ×1

flann ×1

image-recognition ×1

opencv ×1

sift ×1