目标:
我想使用CvNormalBayesClassifier来确定图像中的文本是否是手写的。
已经尝试的内容:
我检测到我的图像JPG(输入)的关键点。
SiftFeatureDetector detector;
vector<KeyPoint> keypoints;
detector.detect(input, keypoints);
我计算描述符。
Mat descript;
SiftDescriptorExtractor deExtrac;
deExtrac.compute(input, keypoints, descript);
我在理解如何使用函数
时遇到问题bool CvNormalBayesClassifier::train(const Mat& trainData, const Mat& responses, const Mat& varIdx=Mat(), const Mat& sampleIdx=Mat(), bool update=false );
我试过了:
Mat trainingClassifications(100, 1, CV_32FC1);
CvNormalBayesClassifier *bayes = new CvNormalBayesClassifier;
bayes->train(descript, trainingClassifications);
bayes->save("bayes.model");
问题:
我收到以下错误:
OpenCV Error: Sizes of input arguments do not match (Response array must contain as many elements as the total number of samples) in cvPreprocessCategoricalResponses,
file /Users/.../opencv/modules/ml/src/inner_functions.cpp, line 671
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/.../opencv/modules/ml/src/inner_functions.cpp:671:
error: (-209) Response array must contain as many elements as the total number of samples in function cvPreprocessCategoricalResponses