在OpenCV代码中使用NormalBayesClassifier时出现未声明的标识符

我在代码中尝试使用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"

Related Posts

L1-L2正则化的不同系数

我想对网络的权重同时应用L1和L2正则化。然而,我找不…

使用scikit-learn的无监督方法将列表分类成不同组别,有没有办法?

我有一系列实例,每个实例都有一份列表,代表它所遵循的不…

f1_score metric in lightgbm

我想使用自定义指标f1_score来训练一个lgb模型…

通过相关系数矩阵进行特征选择

我在测试不同的算法时,如逻辑回归、高斯朴素贝叶斯、随机…

可以将机器学习库用于流式输入和输出吗?

已关闭。此问题需要更加聚焦。目前不接受回答。 想要改进…

在TensorFlow中,queue.dequeue_up_to()方法的用途是什么?

我对这个方法感到非常困惑,特别是当我发现这个令人费解的…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注