I also asked about this in the OpenCV forum, trying my luck elsewhere. I am using OpenCV 3.0 in Visual Studio Professional 2013.
So, I'm trying to calibrate the camera using the tutorial code in calib3d and this tutorial. I keep repeating the same error again and again (std :: length_error in the memory location), and I traced it where I try to add the angle vector specified by findChessboardCorners to the image_points vector in the last line of my code.
image_points.push_back(corners);
In the debug window, the size of the angles is indicated as: angles {size = 2305843009213050645}, which is obviously too large (in the calibration image I use only 35 angles).
The stripped-down tutorial code is below, although again I highlighted a problem to find ChessboardCorners giving a seemingly meaningless angular vector. The strange part is that there is no problem drawing corners on the calibration image I use - it seems that the corners were calibrated perfectly. So what's the problem? I really don't know why findChessboardCorners would give me such a large angle vector that I cannot even add it to the list of vectors.
using namespace cv; using namespace std; int main(int argc, char** argv){ int numBoards = 1; int numCornersHor=7; int numCornersVer=5; int numSquares = numCornersHor * numCornersVer; Size board_sz = Size(numCornersHor, numCornersVer); vector<vector<Point3f>> object_points; vector<vector<Point2f>> image_points; vector<Point2f> corners; int successes = 0; Mat large_image; Mat image; Mat gray_image; large_image = imread(argv[1], IMREAD_COLOR); resize(large_image, image, Size(), .5, .5); vector<Point3f> obj; for (int j = 0; j<numSquares; j++) obj.push_back(Point3f((j / numCornersHor)*29, (j%numCornersHor)*29, 0.0f)); if (image.empty()) return(0); else if (image.channels()>1) cvtColor(image, gray_image, CV_BGR2GRAY); else gray_image = image; bool found = findChessboardCorners(image, board_sz, corners, CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FAST_CHECK | CV_CALIB_CB_NORMALIZE_IMAGE); 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); int key = waitKey(1); if (key == 27) return 0; image_points.push_back(corners); }