title: OpenCV run-time error while calibrating camera in line calibratecamera
body: <p>I wrote a calibration code as bellow:</p>
  
  <pre><code>int numBoards = 20;
  int numCornersHor=6;
  int numCornersVer=9;
  int numSquares = numCornersHor * numCornersVer;
  cv::Size board_sz = cv::Size(numCornersHor, numCornersVer);
  
  std::vector&lt;std::vector&lt;cv::Point3f&gt; &gt; object_points;
  std::vector&lt;std::vector&lt;cv::Point2f&gt; &gt; image_points;
  std::vector&lt;cv::Point2f&gt; corners;
  std::vector&lt;cv::Point3f&gt; obj;
      for(int j=0;j&lt;numSquares;j++)
          obj.push_back(cv::Point3f(j/numCornersHor, j%numCornersHor, 0.0f));
  
  int successes=0;
  </code></pre>
  
  <p>After initialization of useful variables, I get frames from webcam and store it in buffer.</p>
  
  <pre><code>    while(successes&lt;numBoards)
      {        
          unsigned char* buffer=eyeCamera-&gt;getFrame();
          cv::Mat rawImg=cv::Mat(cv::Size(widthCam,heightCam),CV_8UC4, buffer,cv::Mat::AUTO_STEP);
          cv::Mat grayImg;
          cv::cvtColor(rawImg,grayImg,CV_BGR2GRAY);
  
          bool found = findChessboardCorners(rawImg, board_sz, corners,
                                             CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS);
          if(found)
          {
              cv::cornerSubPix(grayImg, corners, cv::Size(11, 11), cv::Size(-1, -1),
                               cv::TermCriteria(CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 30, 1.1));
              cv::drawChessboardCorners(grayImg, board_sz, corners, found);
          }
  
          cv::imshow("win2", grayImg);
  </code></pre>
  
  <p>Everything is ok so far.I show grayImg and chessboard corners are painted.</p>
  
  <pre><code>        int key = cv::waitKey(1);
          if(key==27)
              return;
  
          if(key==' ' &amp;&amp; found!=0)
          {
            image_points.push_back(corners);
            object_points.push_back(obj);
  
            successes++;
  
            if(successes&gt;=numBoards)
                break;
          }
  
      }
  
      cv::Mat intrinsic = cv::Mat(3, 3, CV_64F);
      cv::Mat distCoeffs= cv::Mat(8, 1, CV_64F);
      std::vector&lt;cv::Mat&gt; rvecs;
      std::vector&lt;cv::Mat&gt; tvecs;
      intrinsic.at&lt;double&gt;(0,0) = 1.0;
  
      int widthCam=640; 
      int heightCam=480;
  </code></pre>
  
  <p>object_points and image_points are filled with 54 elements ~ 9 * 6</p>
  
  <pre><code>    cv::calibrateCamera(object_points, image_points, cv::Size(widthCam,heightCam), intrinsic, distCoeffs, rvecs, tvecs);
  </code></pre>
  
  <p>I'm using Qt creator. I always get run-time error while calling the last line: calibrateCamera()</p>
  
  <p>Edit: I tried the same code with <code>cvCalibrateCamera2</code> and again i got the same error. I provide opencv Exeption:</p>
  
  <pre><code>OpenCV error: Bad argument (the output array of translation vectors must be 3-channel
  1xn or nx1 array or 1-channel nx3 array, where n is the bumber of views) in
  cvCalibrateCamera2, file F:\OpenCV\opencv\modules\calib3d\src\calibration.cpp,line 1506
  terminate called after throwing an instance of 'cv::Exeption'
  </code></pre>
  
  <p>I am using 10 snapshot and my defined rvec and tvec are as follows:</p>
  
  <pre><code>CvMat* rvec  = cvCreateMat(10,3,CV_32FC1);
  CvMat* tvec  = cvCreateMat(10,3,CV_32FC1);
  </code></pre>
  
  <p>Can anyone help me solve this error? </p>
  
  <p>Thanks.</p>