Opencv 双目标定之后,校正图像出现错误,求大神指导

在使用OpenCV进行双目标定后,校正图像出现了错误。已确认角点顺序正确,但标定后的图像不正常。问题可能出现在标定代码的某个环节,例如图像大小不一致、角点检测、参数设置等。目前尚未找到解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

左右图像标定结果如下

角点顺序左右图都没错。

可是标定之后,校正的图像如下错误

 

 

 

标定代码如下

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

评论 17
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值