Ask Your Question

Revision history [back]

I have the same problem, the code runs but except for very trivial cases (one set of points, checkerboard middle of the screen) it always fails the assertion. The test case included in OCV doesn't include the input data (left.xml and object.xml files) so it is hard to figure out what is wrong in my input data.

I have the same problem, the code runs but except for very trivial cases (one set of points, checkerboard middle of the screen) it always fails the assertion. The test case included in OCV doesn't include the input data (left.xml and object.xml files) so it is hard to figure out what is wrong in my input data.

Edit: I think i have nailed it. The problem is the 3D object point set, instead of having the origin (0,0) in the corner of the checkerboard like in the OpenCV examples i have put an offset to put the origin in the middle of the checkerboard by subtracting the halved checkerboard width and height. Below my code to construct the 3d object points:

std::vector<cv::Point3d> Create3DChessboardCorners(cv::Size boardSize, float squareSize)
{
  // This function creates the 3D points of your chessboard in its own coordinate system
float width = (boardSize.width-1)*squareSize;
float height = (boardSize.height-1)*squareSize;


  std::vector<cv::Point3d> corners;

  for( int i = 0; i < boardSize.height; i++ )
  {
    for( int j = 0; j < boardSize.width; j++ )
    {
      corners.push_back(cv::Point3d(float(j*squareSize)-width, float(i*squareSize)-height, 0));
    }
  }

  return corners;
}

Now it seeim to be working, I have tested it by calculating the pose (rotation and translation) of the pattern by cv::solvePnP and projecting back to 2d by cv::fisheye::projectPoints