title: OpenCV Camera Calibration, Assertion Failed <ni > 0 && ni==ni1>
body: <p>I am trying to perform camera calibration using <code>openCV</code>. On the same example data from <code>openCV</code> samples this works great, but my source generates an error: </p>
  
  <pre><code>Assertion failed &lt;ni &gt; 0 &amp;&amp; ni==ni1&gt;... collectCallibrationData..    calibration.cpp line 3193"
  objectPoints and imagePoints are the same size. Changing other inputs dont   affect error code. 
  </code></pre>
  
  <p>Can anyone help me deal with it? The code follows:</p>
  
  <pre><code>void main()//enter code here
  {
  //initial operations, declatarions etc
  int *Asize; float *APoints; 
  float AAPoints[]= {/* My Array */};
  int AAsize[] = {4,54,2}; //My array size
  Asize = AAsize; APoints = AAPoints; // will be called as dll that is why this wierd attribution
  int page = *(Asize); int row = *(Asize+1); int col = *(Asize +2);
  Point3f pointBuf;
  vector&lt;vector&lt;Point3f&gt;&gt; imagePoints;
  vector&lt;Point3f&gt; vectBuf;
  Size boardSize; 
  boardSize.height = 6; boardSize.width = 9;
  Mat cameraMatrix, distCoeffs;
  float squareSize=50;
  
  
  //change 1d array to vector&lt;vector&lt;point3f&gt;&gt;
  for (int i = 0; i&lt;page; i++)
  {
      for (int j = 0; j&lt;row; j++)
      {
          pointBuf.x = *(APoints + (i*(row*col))+j*2);
          pointBuf.y = *(APoints + (i*(row*col))+j*2+1);
          pointBuf.z = 0;
          vectBuf.push_back(pointBuf);
      }
      imagePoints.push_back(vectBuf);
      vectBuf.clear();
  }
  
  // create objectPoint vector&lt;vector&lt;Points3f&gt;&gt;
  vector&lt;vector&lt;Point3f&gt;&gt; objectPoints;
   vectBuf.clear();
    for( int i = 0; i &lt; boardSize.height; ++i )
     {
      for( int j = 0; j &lt; boardSize.width; ++j )
           vectBuf.push_back(Point3f(float( j*squareSize ), float( i*squareSize ), 0));
    }
  objectPoints.resize(imagePoints.size(),vectBuf);
  
  //initialize starting variables for calibration
  cameraMatrix = Mat::eye(3, 3, CV_64F);
  distCoeffs = Mat::zeros(1, 1, CV_64F);
  cameraMatrix.at&lt;double&gt;(0,0) = 1.0;
  vector&lt;Mat&gt; rvecs, tvecs;
  Size imageSize; imageSize.width = 2040; imageSize.height = 2040; 
  
  
  double rms = calibrateCamera(objectPoints, imagePoints, imageSize, cameraMatrix, distCoeffs, rvecs, tvecs);
  }
  </code></pre>