title: Camera calibration with OpenCV - findChessboardCorners returns false
body: <p>I try to calibrate my camera. I run some example but all of them don't find corners of chess board. Finally, I use <a href="https://stackoverflow.com/questions/14841683/camera-calibration-opencv?rq=1">this question</a>'s code, but it can't find corners.There is a image below. I use it to find corners. </p>
  
  <p>I find a command on web for this problem.It says that <em>board_sz has to hold the number of inner corners, not the</em> <em>number of squares</em>. board_sz is a 2-dimensional object.I don't understand that how can I use it to hold the number of inner corner except h*w.</p>
  
  <p>I give w  = 9,h = 7</p>
  
  <p><strong>Edit 1 ** 
  **Code :</strong></p>
  
  <pre><code>#include &lt;cv.h&gt;
  #include &lt;highgui.h&gt;
  #include &lt;vector&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  
  using namespace cv;
  using namespace std;
  
  int main()
  {
  int numBoards = 0;
  int numCornersHor;
  int numCornersVer;
  
  printf("Enter number of corners along width: ");
  scanf("%d", &amp;numCornersHor);
  
  printf("Enter number of corners along height: ");
  scanf("%d", &amp;numCornersVer);
  
  printf("Enter number of boards: ");
  scanf("%d", &amp;numBoards);
  
  int numSquares = numCornersHor * numCornersVer;
  Size board_sz = Size(numCornersHor, numCornersVer);
  VideoCapture capture = VideoCapture(0);
  
  vector&lt;vector&lt;Point3d&gt;&gt; object_points;
  vector&lt;vector&lt;Point2d&gt;&gt; image_points;
  
  vector&lt;Point2d&gt; corners;
  int successes=0;
  
  Mat image;
  Mat gray_image;
  capture &gt;&gt; image;
  
  vector&lt;Point3d&gt; obj;
  for(int j=0;j&lt;numSquares;j++)
      obj.push_back(Point3d(j/numCornersHor, j%numCornersHor, 0.0f));
  
  while(successes&lt;numBoards)
  {
      cvtColor(image, gray_image, CV_BGR2GRAY);
  
      bool found = findChessboardCorners(image, board_sz, corners, CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS);
  
      if(found)
      {
          cornerSubPix(gray_image, corners, Size(11, 11), Size(-1, -1), TermCriteria(CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 30, 0.1));
          drawChessboardCorners(gray_image, board_sz, corners, found);
      }
  
      imshow("win1", image);
      imshow("win2", gray_image);
  
      capture &gt;&gt; image;
  
      int key = waitKey(1);
  
      if(key==27)
          return 0;
  
      if(key==' ' &amp;&amp; found!=0)
      {
          image_points.push_back(corners);
          object_points.push_back(obj);
          printf("Snap stored!\n");
  
          successes++;
  
          if(successes&gt;=numBoards)
              break;
      }
  }
  
  Mat intrinsic = Mat(3, 3, CV_32FC1);
  Mat distCoeffs;
  vector&lt;Mat&gt; rvecs;
  vector&lt;Mat&gt; tvecs;
  
  intrinsic.ptr&lt;float&gt;(0)[0] = 1;
  intrinsic.ptr&lt;float&gt;(1)[1] = 1;
  
  calibrateCamera(object_points, image_points, image.size(), intrinsic, distCoeffs, rvecs, tvecs);
  
  Mat imageUndistorted;
  while(1)
  {
      capture &gt;&gt; image;
      undistort(image, imageUndistorted, intrinsic, distCoeffs);
  
      imshow("win1", image);
      imshow("win2", imageUndistorted);
  
      waitKey(1);
  }
  
  capture.release();
  
  return 0;
  }
  </code></pre>
  
  <p>Image : </p>
  
  <p><img src="https://i.stack.imgur.com/uRPSl.png" alt="enter image description here"> </p>