按照网上的代码用svm训练分类器
结果报错
[ INFO:0] global C:\build\master_winpack-build-win64-vc14\opencv\modules\core\src\ocl.cpp (891) cv::ocl::haveOpenCL Initialize OpenCL runtime…
[ INFO:0] global C:\build\master_winpack-build-win64-vc14\opencv\modules\videoio\src\videoio_registry.cpp (187) cv::`anonymous-namespace’::VideoBackendRegistry::VideoBackendRegistry VIDEOIO: Enabled backends(7, sorted by priority): FFMPEG(1000); GSTREAMER(990); INTEL_MFX(980); MSMF(970); DSHOW(960); CV_IMAGES(950); CV_MJPEG(940)
[ INFO:0] global C:\build\master_winpack-build-win64-vc14\opencv\modules\videoio\src\backend_plugin.cpp (353) cv::impl::getPluginCandidates Found 2 plugin(s) for FFMPEG
[ INFO:0] global C:\build\master_winpack-build-win64-vc14\opencv\modules\videoio\src\backend_plugin.cpp (172) cv::impl::DynamicLib::libraryLoad load E:\opencv\build\x64\vc14\bin\opencv_videoio_ffmpeg420_64.dll => OK
[ INFO:0] global C:\build\master_winpack-build-win64-vc14\opencv\modules\videoio\src\backend_plugin.cpp (233) cv::impl::PluginBackend::PluginBackend Video I/O: loaded plugin ‘FFmpeg OpenCV Video I/O plugin’
不明白这是什么意思,希望有大佬告诉我一下
代码
#include <iostream>
#include <fstream>
#include <stdlib.h> //srand()和rand()函数
#include <time.h> //time()函数
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/ml/ml.hpp>
#define INRIANegativeImageList "D:\\INRIAPerson\\Train\\neg.lst" //原始负样本图片文件列表
#define cropNegNum 1220
//负样本图片个数
using namespace std;
using namespace cv;
int CropImageCount = 0; //裁剪出来的负样本图片个数
int main()
{
Mat src;
string ImgName;
char saveName[256];//裁剪出来的负样本图片文件名
ifstream fin(INRIANegativeImageList);//打开原始负样本图片文件列表
int num = 0;
//一行一行读取文件列表
while (getline(fin, ImgName))
{
cout << "处理:" << ImgName << endl;
ImgName = "D:\\INRIAPerson\\" + ImgName;
src = imread(ImgName, 1);//读取彩色图片
//src =cvLoadImage(imagename,1);//c的接口,
cout<<"宽:"<<src.cols<<",高:"<<src.rows<<endl;
//图片大小应该能能至少包含一个64*128的窗口
if (src.cols >= 64 && src.rows >= 128)
{
srand((unsigned int)time(NULL));//设置随机数种子
//从每张图片中随机裁剪10个64*128大小的不包含人的负样本
for (int i = 0; i < 10; i++)
{
int x = (rand() % (src.cols - 64)); //左上角x坐标
int y = (rand() % (src.rows - 128)); //左上角y坐标
//cout<<x<<","<<y<<endl;
Mat imgROI = src(Rect(x, y, 64, 128));
//Rect rect(400,400,300,300);
// Mat image_cut = Mat(img, rect);
sprintf(saveName, "D:\\INRIAPerson\\newneg\\noperson%06d.jpg", ++CropImageCount);//生成裁剪出的负样本图片的文件名
imwrite(saveName, imgROI);//保存文件
// //保存裁剪得到的图片名称到txt文件,换行分隔
//if (i < (cropNegNum - 1)) {
// fout << "neg" << i << "Cropped" << num++ << ".png" << endl;
//}
//else if (i == (cropNegNum - 1) && j < 4) {
// fout << "neg" << i << "Cropped" << num++ << ".png" << endl;
//}
//else {
// fout << "neg" << i << "Cropped" << num++ << ".png";
//}
}
}
}
cout << "总共裁剪出" << CropImageCount << "张图片" << endl;
cin.get();
return 0;
}
#include "opencv2/core/core.hpp"
#include "opencv2/objdetect.hpp"
#include "opencv2/core/cuda.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/video/video.hpp"
#include "opencv2/ml.hpp"
#include "opencv2/opencv.hpp"
#include <opencv2/ml/ml.hpp>
#include <opencv2/highgui/highgui_c.h>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/imgcodecs.hpp>
#include <stdlib.h>
#include <time.h>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <vector>
#include <fstream>
#include <cstdlib>
using namespace std;
using namespace cv;
using namespace cv::ml;
//函数声明
void get_svm_detector(const Ptr< SVM > & svm, vector< float > & hog_detector);
void convert_to_ml(const std::vector< Mat > & train_samples, Mat& trainData);
void load_images(const String & dirname, vector< Mat > & img_lst, bool showImages);
void sample_neg(const vector< Mat > & full_neg_lst, vector< Mat > & neg_lst, const Size & size);
void computeHOGs(const Size wsize, const vector