Как использовать поезд OpenCV CvNormalBayesClassifier?

ЦЕЛЬ:

Я хочу использовать 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

0

Решение

Задача ещё не решена.

Другие решения


По вопросам рекламы ammmcru@yandex.ru
Adblock
detector