OpenCv- error in training faces. Assertion failed (0 <= i && i < (int)v.size())

asked 2013-12-20 00:26:52 -0500

vivek0402 gravatar image

updated 2013-12-20 01:33:32 -0500

I I am working on Face Recognition by using java library of OpenCv. but on training the algotithm I am getting following debugging error-

OpenCV Error: Assertion failed (0 <= i && i < (int)v.size()) in unknown function, file ......\src\opencv\modules\core\src\matrix.cpp, line 992

Exception in thread "main" java.lang.RuntimeException: ......\src\opencv\modules\core\src\matrix.cpp:992: error: (-215) 0 <= i && i < (int)v.size()

I am using OpenCv 2.4.6, JavaCv.6, netbeans7.3.1, windows8 64 bit. I am using following libraries- OpenCv-2.4.6, Javacpp.jar javacv.jar, opencv-2.4.6.0-windows-x86_64.jar, javacv-windows-x86_64.jar. Here is my code-

static{ System.loadLibrary("opencv_java246"); }
public static void main(String[] args) {
    // TODO code application logic here
  FaceRecognizer fr= opencv_contrib.createEigenFaceRecognizer();
  MatVector imgs=new MatVector(7);
  int []id=new int[7];
  for(int i=1;i<=7;i++)
  {
      String url="C:/Users/vivek/Documents/NetBeansProjects/Recognizer2/a"+i+".jpg";
      CvArr img=opencv_highgui.cvLoadImage(url);
      imgs.put(img);
      id[i-1]=i;
  }
  CvArr test=opencv_highgui.cvLoadImageM("C:/Users/vivek/Documents/NetBeansProjects/Recognizer2/a7.jpg");
  fr.train(imgs,id);
  System.out.println(fr.predict(test));

I am stuck here please describe briefly what's the problem.

edit retag flag offensive close merge delete