0

我正在学习 OpenCV 2.4.2 中的 FaceRecognizer 功能并编写了一些代码进行测试。但是,我在此代码上遇到错误:

int num_components = 10;
double threshold = 10.0;
Ptr<FaceRecognizer> model = createEigenFaceRecognizer(num_components, threshold);

带有此错误消息:

First-chance exception at 0x75719617 in Cs.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x001af2e4..

我尝试了几种方法,但无法真正弄清楚导致分配错误的问题是什么。大家对这个错误有什么想法吗?

4

2 回答 2

1

我认为问题可能出在其他地方,在带有 OpenCV 2.4.2 的 mac 上,如果我这样做,我就没有这样的问题:

#include <opencv2/core/core.hpp>
#include <opencv2/contrib/contrib.hpp>

int main(){
  using namespace cv;
  Ptr<FaceRecognizer> model = createEigenFaceRecognizer(10, 10.0);
  return 0;
}

你确定你没有包含类似#include <cv.h>or的东西#include <highgui.h>吗?

于 2012-11-02T10:26:16.160 回答
0

请提供更多详细信息,否则将很难重现该错误。如果您自己编译,您的问题应该包含您的 OpenCV 版本或 SVN 版本、您的操作系统、它是否是 32/64 位以及您正在使用的数据。如果您不使用文档随附的示例,则应附上相关的代码片段(如果可能)。

于 2012-07-15T07:11:34.040 回答