左右图像标定结果如下
角点顺序左右图都没错。
可是标定之后,校正的图像如下错误
标定代码如下
void main()
{
Size boardSize;
boardSize.width = 11;
boardSize.height = 8;
vector<string> imagelist;
bool ok = readStringList("D:/Code/vision/Binocular_Demo/Binocular_Calibration/Image/stereo_calib.xml", imagelist);
StereoCalib(imagelist, boardSize, true, true, true);
}
bool Binocular_Calibration::StereoCalib(const vector<string>& imagelist, Size boardSize, bool displayCorners = false, bool useCalibrated = true, bool showRectified = true)
{
if (imagelist.size() % 2 != 0)
{
cout << "Error: the image list contains odd (non-even) number of elements\n";
return false;
}
const int maxScale = 2;
const float squareSize = 1.f; // Set this to your actual square size
// ARRAY AND VECTOR STORAGE:
vector<vector<Point2f> > imagePoints[2];
vector<vector<Point3f> > objectPoints;
Size imageSize;
int i, j, k, nimages = (int)imagelist.size() / 2;
imagePoints[0].resize(nimages);
imagePoints[1].resize(nimages);
vector<string> goodImageList;
for (i = j = 0; i < nimages; i++)
{
for (k = 0; k < 2; k++)
{
const string& filename = imagelist[i * 2 + k];
Mat img = imread(filename, 0);
if (img.empty())
break;
if (imageSize == Size())
imageSize = img.size();
else if (img.size() != imageSize)
{
cout << "The image " << filename << " has the size different from the first image size. Skipping the pair\n";
break;
}
bool fou