0

When I run the facerec_eigenfaces demo program from OpenCV 3.1 I receive an unhandled exception:

OpenCV Error: Assertion failed (0 <= i && i < (int)v.size()) in cv::_InputArray::getMat_

This follows a call to _InputArray::getMat(int). I reduced the facerec_eigenfaces program to the following which gives the same error. (I also tried other binary pgm files with the same result.) Can anyone suggest what may be wrong?

#include "opencv2/core.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include <vector>

int main(int argc, char *argv[])
{
  auto m = cv::imread("../att_faces/s1/1.pgm", 0);
  std::vector<cv::Mat> imgs;
  imgs.push_back(m);
  cv::InputArrayOfArrays ia(imgs);
  ia.getMat(0); // assertion here 
  return 0;
}
user2023370
  • 10,488
  • 6
  • 50
  • 83
  • The assert is in matrix.cpp and reads there as `CV_Assert(0 <= i && i < (int)v.size());` The `v` is assigned from the `ia` variable's `getObj` method: `const std::vector& v = *(const std::vector*)ia.getObj();` and if I print out its contentious size, `v.size()`, it's `1`, which is greater than the `0` index passed to `getMat` - as it should be. (I don't know why it's `1`, but that's another question.) Help? – user2023370 Mar 20 '16 at 23:12
  • It seems the issue doesn't exist if I instead link to the debug OpenCV library: `opencv_world310d.lib`. – user2023370 Mar 21 '16 at 21:38

0 Answers0