c++ - NormalBayesClassifier 在 opencv 代码中给出未声明的标识符

标签 c++ opencv machine-learning

我正在尝试在我的代码中使用 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 函数,那我为什么会收到这个错误?

最佳答案

根据documentation ,正态贝叶斯分类器的类实际上称为 CvNormalBayesClassifier

对应的头文件为:

#include "opencv2/ml/ml.hpp"

关于c++ - NormalBayesClassifier 在 opencv 代码中给出未声明的标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13778780/

相关文章:

c++ - C++中的递归回溯

c++ - 模板化的多态回调是个好主意吗?

c++ - std::tr1::function 及其接受的模板值

opencv - 是否可以在 OpenCV 的 cvKmeans2 中查看当前迭代次数?

machine-learning - TF-IDF vs XGBoost vs CNN

c++ - 如何将 Haskell LLVM passes 与 C++ LLVM passes 集成(如果有的话)?

c++ - opencv 2.3.* imread 不工作

python - 如何在 Python 中使用 OpenCV 的 connectedComponentsWithStats?

python - Scikit Learn 中预测的扩展特征

python - "TclError: no display name and no $DISPLAY environment variable"nltk错误