如何在opencv中将SIFT功能用于单词袋? [英] how to use SIFT features for bag of words in opencv?
本文介绍了如何在opencv中将SIFT功能用于单词袋?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在阅读了图像的筛选特征后,我已经阅读了很多有关实现单词袋的文章,但是我仍然对下一步的工作感到困惑.我具体要做什么?
I have read a lot of articles about implementing bag of words after taking sift features of an image, but I'm still confused what to do next. What do i specifically do?
非常感谢您的指导.
这是我到目前为止的代码.
This is the code that i have so far.
cv::Mat mat_img = cropped.clone();
Mat grayForML;
cvtColor(mat_img, grayForML, CV_BGR2GRAY);
IplImage grayImageForML = grayForML.operator IplImage();
//create another copy of iplGray
IplImage *input = cvCloneImage(&grayImageForML);
Mat matInput = cvarrToMat(input);
// Mat matInput = copy_gray.clone();
cv::SiftFeatureDetector detector;
std::vector<cv::KeyPoint> keyPoints;
detector.detect(input, keyPoints);
//add results to image and save.
cv::Mat output;
cv::drawKeypoints(input, keyPoints, output); //SIFT OUTPUT RESULT
//resize and display
cv::Mat output_reduced;
cv::resize(output, output_reduced, cv::Size2i(output.cols / 2, output.rows / 2));
imshow("SIFT result", output_reduced);
推荐答案
训练一揽子单词系统的过程如下:
Training a bag of words system goes as follows:
- 为训练集的每个图像计算特征
- 群集这些功能
- 用每个群集中具有特征的图像标记每个群集
此时培训已经完成,您可以按照以下步骤进行测试:
At this point the training is done and you can start with the testing as follows:
- 计算测试图像的特征
- 对于每个功能,找到最近的群集
- 为属于该群集的每个训练图像添加一个勾号
- 重复测试图像的所有功能
- 滴答声最高的图像是最佳匹配,而滴答声次高的图像是次佳匹配,依此类推
您会注意到,使用SIFT没有限制.您可以尝试使用其他特征提取器和描述符.
As you can notice, there is no restriction to using SIFT. You can try different feature extractors and descriptors.
这篇关于如何在opencv中将SIFT功能用于单词袋?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文