title: Error when debug: Debug Assertion Failed: Vector subscript out of range
body: <p>I have work on code for recognition hand gesture using Hu Moment extraction feature, but when i start to debug, a notification appears that Debug Assertion Failed! Vector subscript out of range. someone told me that I you have a bug in my code, but I still can't figured it out. Please help me. Here's the crashed code</p>
  
  <pre><code>//function hand image declare and preprocessing image
  //function contour detection
  //function bounding box
  int main()
  {
  
  VideoCapture cap(0); //capture the video from web cam
  
  if (!cap.isOpened())  // if not success, exit program
  {
      cout &lt;&lt; "Cannot open the web cam" &lt;&lt; endl;
  
  }
  vector&lt;vector&lt;Point&gt; &gt; MyContours = getTestCases();
  string array[] = {"V","W","Y"};
  while (1)
  {
      Mat imgOriginal;
  
      bool bSuccess = cap.read(imgOriginal); // read a new frame from video
      if (!bSuccess) //if not success, break loop
      {
          cout &lt;&lt; "Cannot read a frame from video stream" &lt;&lt; endl;
          break;
      }
      Mat send;
      imgOriginal.copyTo(send);
      vector&lt;Point&gt; present_hand_state = detectHand(send);
  
      double area = contourArea(present_hand_state, false);
      cout &lt;&lt; area &lt;&lt; endl;
      int a = matchTheState(present_hand_state, MyContours);
  
      if (a != 100 &amp; area &gt; 500)
          imshow("ImgOriginal", imgOriginal);
  
      waitKey(23);
  }
  }
  
  int matchTheState(vector&lt;Point&gt; present_hand_state, vector&lt;vector&lt;Point &gt; &gt; MyContours)
  {
  vector&lt;double&gt; array(MyContours.size());
  int answer = 0;
  for (int i = 0; i &lt; MyContours.size(); i++)
  {
      double match_value = cv::matchShapes(MyContours[i], present_hand_state, CV_CONTOURS_MATCH_I2, 0);
      array[i] = match_value;
      if (array[answer] &gt; array[i])
          answer = i;
  }
  if (array[answer] &lt; 0.9)
      return answer;
  else
      return 100;
  }
  </code></pre>
  
  <p>while the contents of the <code>vector&lt;vector&lt;point&gt;&gt; MyContours</code> is an image declaration that is used as a comparison value.</p>
  
  <pre><code>vector&lt;Mat&gt; testCases;
  vector&lt;vector&lt;Point&gt; &gt; MyContours;
  Mat test = imread("D:\KULIAH\TA\database\F1\frame_v_thres.jpg", CV_LOAD_IMAGE_GRAYSCALE);
  testCases.push_back(test);//1
  test = imread("D:\KULIAH\TA\database\F1\frame_w_thres.jpg", CV_LOAD_IMAGE_GRAYSCALE);
  testCases.push_back(test);//2
  test = imread("D:\KULIAH\TA\database\F1\frame_y_thres", CV_LOAD_IMAGE_GRAYSCALE);
  testCases.push_back(test);//3
  </code></pre>