C++ 在目标检测的图像处理中,如何在模式识别算法中提取特定特征?
我想从近距离检测物体(飞机门)。该算法应该非常健壮,因此可以在任何平面(有许多不同的绘画、徽标)和任何天气条件(太阳、雨、白天和夜晚)下实现 我在OpenCV中搜索并实现了一些特征提取算法,如SURF、SIFT和ORB,但结果不是很好 这里的代码使用ORB特征检测器C++ 在目标检测的图像处理中,如何在模式识别算法中提取特定特征?,c++,opencv,image-processing,feature-extraction,pattern-recognition,C++,Opencv,Image Processing,Feature Extraction,Pattern Recognition,我想从近距离检测物体(飞机门)。该算法应该非常健壮,因此可以在任何平面(有许多不同的绘画、徽标)和任何天气条件(太阳、雨、白天和夜晚)下实现 我在OpenCV中搜索并实现了一些特征提取算法,如SURF、SIFT和ORB,但结果不是很好 这里的代码使用ORB特征检测器 #include "opencv2/opencv_modules.hpp" #include <stdio.h> #ifndef HAVE_OPENCV_NONFREE int main(int, char**) {
#include "opencv2/opencv_modules.hpp"
#include <stdio.h>
#ifndef HAVE_OPENCV_NONFREE
int main(int, char**)
{
printf("The sample requires nonfree module that is not available in your OpenCV distribution.\n");
return -1;
}
#else
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdlib.h>
using namespace cv;
using namespace std;
static void help()
{
printf("\nThis program demonstrates using features2d detector, descriptor extractor and simple matcher\n"
"Using the SURF desriptor:\n"
"\n"
"Usage:\n matcher_simple <image1> <image2>\n");
}
Mat src;Mat src_gray;
int thresh = 5;
int max_thresh = 600;
RNG rng(12345);
void thresh_callback(int, void* );
int main(int argc, char** argv)
{
Mat img1;
Mat img2;
img1= imread("a350_1.jpg", CV_LOAD_IMAGE_GRAYSCALE);
resize(img1, img1, Size(700,500), 0, 0, INTER_CUBIC);
img2= imread("a350_1.jpg", CV_LOAD_IMAGE_GRAYSCALE);
resize(img2, img2, Size(680,480), 0, 0, INTER_CUBIC);
Mat image;
if(! img1.data || ! img1.data)
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
// detecting keypoints
OrbFeatureDetector detector(1500);
vector<KeyPoint> keypoints1, keypoints2;
detector.detect(img1, keypoints1);
detector.detect(img2, keypoints2);
// computing descriptors
OrbDescriptorExtractor extractor;
Mat descriptors1, descriptors2;
extractor.compute(img1, keypoints1, descriptors1);
extractor.compute(img2, keypoints2, descriptors2);
// matching descriptors
BFMatcher matcher(NORM_HAMMING);
vector<DMatch> matches;
matcher.match(descriptors1, descriptors2, matches);
// drawing the results
namedWindow("matches", CV_WINDOW_AUTOSIZE);
Mat img_matches;
drawMatches(img1, keypoints1, img2, keypoints2, matches, img_matches);
imshow("matches", img_matches);
waitKey(0);
return 0;
}
#endif
#包括“opencv2/opencv_modules.hpp”
#包括
#如果没有自由
int main(int,char**)
{
printf(“该示例需要OpenCV发行版中不可用的非自由模块。\n”);
返回-1;
}
#否则
#包括“opencv2/core/core.hpp”
#包括“opencv2/features2d/features2d.hpp”
#包括“opencv2/highgui/highgui.hpp”
#包括“opencv2/nonfree/nonfree.hpp”
#包括“opencv2/imgproc/imgproc.hpp”
#包括
#包括
使用名称空间cv;
使用名称空间std;
静态void帮助()
{
printf(“\n此程序演示如何使用features2d检测器、描述符提取器和简单匹配器\n”
“使用冲浪描述器:\n”
“\n”
“用法:\n matcher\u simple\n”);
}
Mat-src;Mat src_gray;
int thresh=5;
int max_thresh=600;
RNG RNG(12345);
无效阈值回调(int,void*);
int main(int argc,字符**argv)
{
Mat-img1;
Mat-img2;
img1=imread(“a350\u 1.jpg”,CV\u加载\u图像\u灰度);
调整大小(img1,img1,大小(700500),0,0,中间立方);
img2=imread(“a350\u 1.jpg”,CV\u加载\u图像\u灰度);
调整大小(img2,img2,大小(680480),0,0,中间立方);
Mat图像;
如果(!img1.data | |!img1.data)
{
cout如果您可以创建多种类型对象(门)的数据集,您可以使用SIFT输出等特征来训练SVM(在opencv中,您可以找到几个示例).是的,在这里使用ORB特征检测器添加代码。是的,我可以创建数据集,但我喜欢使用窗和门之间的距离等特征。如何检测该特征并将其纳入SVM?