Koo Yong Jian
Koo Yong Jian

Reputation: 1

OpenCV 2.4.2 FaceRecognizer std::bad_alloc exception

I am learning about the FaceRecognizer feature in OpenCV 2.4.2 and wrote some code to test. However i get an error on this code:

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

with this error message:

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

I tried several ways but cant really figure out what are the problems cause bad allocation happens. Everyone got any ideas about this error?

Upvotes: 0

Views: 431

Answers (2)

Barney Szabolcs
Barney Szabolcs

Reputation: 12514

I think the problem could be somewhere else, on mac with OpenCV 2.4.2 I have no such problem if I do this:

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

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

Are you sure you did not include anything like #include <cv.h> or #include <highgui.h>?

Upvotes: 1

bytefish
bytefish

Reputation: 3797

Please give more details or it is going to be hard to reproduce the error. Your question should contain your OpenCV version or SVN revision if you compiled it yourself, your Operating System, wether it is 32/64bit and the data you are using. If you are not using the samples coming with the documentation you should attach relevant snippets of your code (if possible).

Upvotes: 0

Related Questions