这是我在这里发表的第一篇文章,所以我希望能够正确地提出我的问题: - )
我想做"大象检测"通过分类颜色样本(我的灵感来自this paper)。这是我的解决方案"直到训练分类器:
所以,问题出现在最后一步:过了一会儿(几个小时),我收到以下错误信息:
我的训练样本是[3列x 1,385,235行] CV_32FC1 Mat对象。我不相信这个数据结构太大了,不是吗?我有16 GB的RAM,而且我使用的是OpenCV 2.4.9和Codeblocks。
但是,这是源代码:
//Loading Background & Foreground Training Images
Mat train_00_background = imread("training_set/train_00_background.png");
cvtColor(train_00_background, train_00_background, CV_BGR2BGRA);
oclMat t_00_bg;
t_00_bg.upload(train_00_background);
(...)
Mat train_00_foreground = imread("training_set/train_00_foreground.png");
cvtColor(train_00_foreground, train_00_foreground, CV_BGR2BGRA);
oclMat t_00_fg;
t_00_fg.upload(train_00_foreground);
(...)
//COLOR SEGMENTATION by MEAN SHIFT CLUSTERING
meanShiftSegmentation(t_00_bg, train_00_background_clustered, 5, 5, 50, TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));
(...)
//CV_8UC3 -> CV_32FC3
train_00_background_clustered.convertTo(train_00_background_clustered, CV_32FC3);
(...)
//Normalization
train_00_background_clustered *= 1./255;
(...)
//RGB -> Luv
cvtColor(train_00_background_clustered, train_00_background_clustered, CV_BGR2Luv);
(...)
//COLOR LIST EXTRACTION FROM BACKGROUND AND FOREGROUND
//colorListBg_00 is a 3 x NumberOfColors CV_32FC1 Mat
extractColorList(train_00_background_clustered, colorListBg_00);
// Memory release
train_00_background_clustered.release();
(...)
//Color List concatenation
//background
colorListBg_00.copyTo(colorList);
colorList.push_back(colorListBg_01);
(...)
Size s = colorList.size();
int s1 = s.height;
//foreground
colorList.push_back(colorListFg_00);
(...)
s = colorList.size();
int s2 = s.height - s1;
// ASSIGNING THE LABELS
Mat labelsBg(s1, 1, CV_32FC1, -1.0);
Mat labelsFg(s2, 1, CV_32FC1, 1.0);
Mat labels;
labelsBg.copyTo(labels);
labels.push_back(labelsFg);
// SVM TRAINING
CvSVMParams params;
params.svm_type = CvSVM::C_SVC;
params.kernel_type = CvSVM::RBF;
params.term_crit = cvTermCriteria( CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 1000, FLT_EPSILON );
CvSVM SVM;
SVM.train_auto(colorList, labels, Mat(), Mat(), params, 2);
感谢您关注此问题。