我的项目范围是通过比较样本图像特征集来识别纸币。在那里,我已经完成了样本图像的特征提取部分。此外,我需要将示例图像特征存储在文本文件或 XML 文件中以及它们的分类中。请帮助我在 OpenCv 上使用 SVM 分类器进行图像分类部分
这是我完成的特征提取代码。
int main( intargc, char** argv ) { /加载图像为灰度/
//declaring Mat object.This will holds an image(like iplimage in old opencv versions).
Mat gray_scale_img;
//imread is used to load an image. in here i have load the image as a grayscale image.
gray_scale_img=imread("100.jpg",CV_LOAD_IMAGE_GRAYSCALE);
/*surf detector settings*/
//setting the threshold value.high value will result low number of keypoints.
int hessian=100;
//initializing the surf keypoint detector
SurfFeatureDetectordetector(hessian);
/*detect surf key points*/
//creating vector to store detected keypoints
std::vector<KeyPoint>keypoints;
//detect keypoints
detector.detect(gray_scale_img,keypoints);
/*extract descriptor vectors/feature vectors from each and every keypoints */
SurfDescriptorExtractor extractor;
//this mat object will goinf to hold the extracted descriptors.
Mat descriptors;
//extracting descriptors/features
extractor.compute(gray_scale_img,keypoints,descriptors);
}