对不起,我的英语太差了。
我已经包含了头文件:
#include "cv.h"
#include "opencv/cv.hpp"
#include "opencv2/face.hpp"
using namespace std;
using namespace cv;
using namespace cv::face;
我声明变量如下:
vector<UMat> images;
vector<int> labels;
Ptr<BasicFaceRecognizer> modelPCA = createEigenFaceRecognizer();
将照片读到UMat:
for(...) {
UMat t_image = imread(t_imagePath.toStdString(), 0).getUMat(ACCESS_FAST);
images.push_back(t_image);
labels.push_back(label);
}
但是当我在训练时:
modelPCA->train(images, labels);
发布错误:
OpenCV Error: Bad argument (The data is expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >).) in asRowMatrix, file C:\opencv\opencv_contrib-3.2.0\modules\face\src\face_basic.hpp, line 43
terminate called after throwing an instance of 'cv::Exception'
what(): C:\opencv\opencv_contrib-3.2.0\modules\face\src\face_basic.hpp:43: error: (-5) The data is expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >). in function asRowMatrix
我该如何解决?
答案 0 :(得分:0)
也许opencv还不支持
if(src.kind() != _InputArray::STD_VECTOR_MAT && src.kind() != _InputArray::STD_VECTOR_VECTOR) {
String error_message = "The data is expected as InputArray::STD_VECTOR_MAT (a std::vector<Mat>) or _InputArray::STD_VECTOR_VECTOR (a std::vector< std::vector<...> >).";
CV_Error(Error::StsBadArg, error_message);
}