我在代码中尝试使用NormalBayesClassifier
来应用词袋模型。预训练矩阵已经准备好并传递给了trainme
矩阵。我的使用方式如下:
NormalBayesClassifier classifier;classifier.train(trainme, labels);
但我遇到了以下错误:
error C2065: 'NormalBayesClassifier' : undeclared identifier
我已经添加了所有正确的库文件,并且其他OpenCV函数都能正常工作,包括features2d函数。
以下是我的库文件列表:
#include <stdafx.h>#include <stdlib.h>#include <cv.hpp>#include <cxcore.hpp>#include <highgui.h>#include <iostream>#include "opencv2/nonfree/features2d.hpp"#include "opencv2/calib3d/calib3d.hpp"#include "opencv2/imgproc/imgproc.hpp"#include "opencv2/nonfree/nonfree.hpp"#include <fstream>#include <windows.h>using namespace cv;using namespace std;
这些应该已经涵盖了NormalBayesClassifier
函数,为什么我还会遇到这个错误呢?
回答:
根据文档,普通贝叶斯分类器的类名实际上是CvNormalBayesClassifier
。
对应的头文件是:
#include "opencv2/ml/ml.hpp"