在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

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

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