Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opencv 是张';s算法对错误敏感吗?_Opencv_Camera Calibration - Fatal编程技术网

Opencv 是张';s算法对错误敏感吗?

Opencv 是张';s算法对错误敏感吗?,opencv,camera-calibration,Opencv,Camera Calibration,我用单反相机一次拍两张棋盘的照片。每个对应角点的偏移小于1。但是每张照片的相机矩阵非常不同。 输出: 源代码: static const Size patterSize(8, 6); vector<Vec2f> corners1 = { { 4362.5f, 473.445f },{ 4398.2f, 870.585f },{ 4432.4f, 1264.15f },{ 4467.0f, 1652.41f },{ 4500.4f, 2036.37f },{ 4533.1f, 241

我用单反相机一次拍两张棋盘的照片。每个对应角点的偏移小于1。但是每张照片的相机矩阵非常不同。
输出:

源代码:

static const Size patterSize(8, 6);

vector<Vec2f> corners1 = { { 4362.5f, 473.445f },{ 4398.2f, 870.585f },{ 4432.4f, 1264.15f },{ 4467.0f, 1652.41f },{ 4500.4f, 2036.37f },{ 4533.1f, 2416.87f },{ 4565.3f, 2792.2f },{ 4596.8f, 3164.32f },{ 4001.4f, 534.995f },{ 4039.3f, 934.814f },{ 4076.0f, 1331.22f },{ 4112.5f, 1723.f },{ 4148.2f, 2110.53f },{ 4183.1f, 2493.87f },{ 4217.6f, 2872.27f },{ 4251.4f, 3246.14f },{ 3633.6f, 596.604f },{ 3673.4f, 1000.05f },{ 3712.5f, 1399.71f },{ 3751.f, 1794.36f },{ 3791.5f, 2192.78f },{ 3826.6f, 2571.79f },{ 3863.f, 2953.15f },{ 3899.f, 3330.55f },{ 3258.5f, 659.839f },{ 3300.f, 1067.13f },{ 3342.3f, 1469.84f },{ 3386.4f, 1868.42f },{ 3425.0f, 2267.45f },{ 3463.8f, 2651.51f },{ 3502.9f, 3034.91f },{ 3542.0f, 3415.47f },{ 2877.1f, 724.695f },{ 2921.5f, 1135.48f },{ 2965.7f, 1541.77f },{ 3009.2f, 1943.08f },{ 3052.1f, 2340.24f },{ 3094.4f, 2732.48f },{ 3136.5f, 3119.85f },{ 3177.9f, 3502.21f },{ 2488.0f, 791.248f },{ 2535.4f, 1204.72f },{ 2582.f, 1614.45f },{ 2628.3f, 2019.17f },{ 2673.7f, 2419.54f },{ 2718.5f, 2814.48f },{ 2763.3f, 3204.62f },{ 2807.5f, 3589.85f } };
vector<Vec2f> corners2 = { { 4362.7f, 473.381f },{ 4398.f, 870.536f },{ 4432.4f, 1263.96f },{ 4467.2f, 1652.29f },{ 4500.6f, 2036.31f },{ 4533.3f, 2416.81f },{ 4565.4f, 2792.2f },{ 4597.0f, 3164.33f },{ 4001.5f, 534.915f },{ 4039.f, 934.763f },{ 4076.2f, 1331.17f },{ 4112.6f, 1722.9f },{ 4148.3f, 2110.53f },{ 4183.f, 2493.79f },{ 4217.7f, 2872.22f },{ 4251.6f, 3246.17f },{ 3633.f, 596.545f },{ 3673.f, 999.967f },{ 3712.6f, 1399.65f },{ 3751.0f, 1794.31f },{ 3791.f, 2193.16f },{ 3826.7f, 2571.76f },{ 3863.4f, 2953.13f },{ 3900.0f, 3330.48f },{ 3258.6f, 659.74f },{ 3300.8f, 1066.98f },{ 3342.4f, 1469.8f },{ 3386.5f, 1868.34f },{ 3425.2f, 2267.81f },{ 3463.9f, 2651.4f },{ 3502.9f, 3034.95f },{ 3542.1f, 3415.42f },{ 2877.3f, 724.687f },{ 2921.6f, 1135.42f },{ 2965.8f, 1541.69f },{ 3009.3f, 1943.02f },{ 3052.1f, 2340.18f },{ 3094.4f, 2732.46f },{ 3136.5f, 3119.82f },{ 3178.0f, 3502.2f },{ 2488.1f, 791.197f },{ 2535.4f, 1204.66f },{ 2582.1f, 1614.38f },{ 2628.4f, 2019.2f },{ 2673.7f, 2419.53f },{ 2718.6f, 2814.43f },{ 2763.3f, 3204.61f },{ 2807.6f, 3589.8f } };

vector<vector<Vec3f>> objectPoints;
objectPoints.push_back(vector<Vec3f>());
for (int row = 0; row < patterSize.height; row++) {
    for (int col = 0; col < patterSize.width; col++) {
        //int num = (row*patterSize.width + col) * 3;
        objectPoints.at(0).push_back(Vec3f(col, row, 0));
    }
}

vector<vector<Vec2f>> imagePoints1;
imagePoints1.push_back(vector<Vec2f>());
for (int row = 0; row < patterSize.height; row++) {
    for (int col = 0; col < patterSize.width; col++) {
        int num = (row*patterSize.width + col);
        imagePoints1.at(0).push_back(corners1.at(num));
    }
}

vector<vector<Vec2f>> imagePoints2;
imagePoints2.push_back(vector<Vec2f>());
for (int row = 0; row < patterSize.height; row++) {
    for (int col = 0; col < patterSize.width; col++) {
        int num = (row*patterSize.width + col);
        imagePoints2.at(0).push_back(corners2.at(num));
    }
}

Mat cameraMatrix = Mat::eye(3, 3, CV_64F);
Mat distCoeffs = Mat::zeros(5, 1, CV_64F);
vector<Mat> rvecs, tvecs;

calibrateCamera(objectPoints, imagePoints1, Size(6000, 4000), cameraMatrix, distCoeffs, rvecs, tvecs);
cout << cameraMatrix << endl;
calibrateCamera(objectPoints, imagePoints2, Size(6000, 4000), cameraMatrix, distCoeffs, rvecs, tvecs);
cout << cameraMatrix << endl;
静态常量大小模式化(8,6);
{4398.2f,870.58555F},{{4432.4f,1264.154.15f},{{4432.4f,1264.4f,1264.154.15f},{{4467.0f,1662.5f,4762.5f,473.5.5f,473.4562.55F,473.473.473.55555F,473.455 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5.5f,473.5f,473.473.473.473.5555F},,,{{{{{{{,,{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{1.5f,1723.f},{4148.2f,2110.53f},{4183.1f,2493.87f},{4217.6f,2872.27f},{3673.4f,1000.05f},{{3673.4f,1000.05f},{3712.5f,1399.719.7F},{3712.5f,399.4f,3246.4f,32461.4f,3246.4f,3246.1446.146.14 f},{3633.6.6.6.6f,596.6.6 6.6 6 6 6 6 6.6 6 6 6 6 6 6.6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6.7 7.7 f},{{{{3673.4.4.4.4.4.4f,1000.4,1000.4,1000.0 0 0,1000.05f,1000.05f},1000.05f},,{,,,{{{{00 0 0 0 0 0 0 0 0 0 0.3.3.3.3.3 3386.4f,1868.42f},{3425.0f,2267.45f},{3463.8f,2651.51f},{3502.9f,3034.91f},35.42.0 0 0 0 f,3415.47 0 0 0 0 0 f,3415.47 f},{2877.1f,724.695.5 5 f,1135.485.0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0{,{2821.21.21.5 5 5 5 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0{2628.3f,2019.17f},{2673.7f,2419.54f},{2718.5f,2814.48f},{2763.3f,3204.62f},{2807.5f,3589.85f};
{4398.f,870.536.6 6 6 6 6 6 6 f},{{4432.4f,1263.963.96f},{{4432.4f,1263.963.963.96f},{4467.2f,1652.2f,1652.295.29f},{{{{{4362.762.77.7.7f,4762.7 7 7 7.7 7 7 7 7.7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7,477,473.7 7 7 7 7 7 7 7 7,475.7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7,1652.5 5 5 5 5 5 5 5 5 5 5 5 5.29f},,,,,,{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{f,1722.9f},{4148.3f,2110.53f},{4183.f,2493.79f},{4217.7f,2872.22f},{3673.f,999.967f},{{3773.f,999.967.7 7 7 7 7 7 f},{3712.6f,1399.6f,1399.65f},{{3712.6f,4251.6f,324.6 6 6 6 6.6 f,3246.6.6 6 6.6 f,3246.6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0,1794.7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 7 7 7 7 7 7 7 7 7 7 7 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0{3386.5f,1868.34f},{3425.2f,2267.81f},{3463.9f,2651.4f},{3502.9f,3034.95f},2877.3f,724.687.7f},{2921.6f,1135.42f},{2921.6f,1135.42f},{2942.1f,3542.1f,3542.1f,3442.1f,3442.1f{3542.1f,3542.1f,3542.1f,3442.1f,3415.1f,3442.1f,3415.1f,3415.1f,3415.1f,3415.1f,3415.1515.1515.1515.1515.42.1f},,,{,,{{{2815.1515.1515.1f,3415.1f,3415.1f,3415.1f,3415.1f,3415.1515.1515.1515.1f,3415.1515.1515.1515.157.15F},{2628.4f,2019.2f},{2673.7f,2419.53f},{2718.6f,2814.43f},{2763.3f,3204.61f},{2807.6f,3589.8f};
矢量目标点;
objectPoints.push_back(vector());
对于(int row=0;row好吧,你的问题是什么?输出矩阵变化太大,尽管输入的差异很小。我想知道我的源代码是否正确。@Holzkohlengrill但相应点的偏移量小于1像素,相对于相机大小约为0.03%。@Anderaso,你的问题是什么?输出矩阵变化太大,虽然输入的差异很小。我想知道我的源代码是否正确。@Holzkohlengrill但对应点的偏移量小于1像素,相对于相机的大小约为0.03%。@anderas
static const Size patterSize(8, 6);

vector<Vec2f> corners1 = { { 4362.5f, 473.445f },{ 4398.2f, 870.585f },{ 4432.4f, 1264.15f },{ 4467.0f, 1652.41f },{ 4500.4f, 2036.37f },{ 4533.1f, 2416.87f },{ 4565.3f, 2792.2f },{ 4596.8f, 3164.32f },{ 4001.4f, 534.995f },{ 4039.3f, 934.814f },{ 4076.0f, 1331.22f },{ 4112.5f, 1723.f },{ 4148.2f, 2110.53f },{ 4183.1f, 2493.87f },{ 4217.6f, 2872.27f },{ 4251.4f, 3246.14f },{ 3633.6f, 596.604f },{ 3673.4f, 1000.05f },{ 3712.5f, 1399.71f },{ 3751.f, 1794.36f },{ 3791.5f, 2192.78f },{ 3826.6f, 2571.79f },{ 3863.f, 2953.15f },{ 3899.f, 3330.55f },{ 3258.5f, 659.839f },{ 3300.f, 1067.13f },{ 3342.3f, 1469.84f },{ 3386.4f, 1868.42f },{ 3425.0f, 2267.45f },{ 3463.8f, 2651.51f },{ 3502.9f, 3034.91f },{ 3542.0f, 3415.47f },{ 2877.1f, 724.695f },{ 2921.5f, 1135.48f },{ 2965.7f, 1541.77f },{ 3009.2f, 1943.08f },{ 3052.1f, 2340.24f },{ 3094.4f, 2732.48f },{ 3136.5f, 3119.85f },{ 3177.9f, 3502.21f },{ 2488.0f, 791.248f },{ 2535.4f, 1204.72f },{ 2582.f, 1614.45f },{ 2628.3f, 2019.17f },{ 2673.7f, 2419.54f },{ 2718.5f, 2814.48f },{ 2763.3f, 3204.62f },{ 2807.5f, 3589.85f } };
vector<Vec2f> corners2 = { { 4362.7f, 473.381f },{ 4398.f, 870.536f },{ 4432.4f, 1263.96f },{ 4467.2f, 1652.29f },{ 4500.6f, 2036.31f },{ 4533.3f, 2416.81f },{ 4565.4f, 2792.2f },{ 4597.0f, 3164.33f },{ 4001.5f, 534.915f },{ 4039.f, 934.763f },{ 4076.2f, 1331.17f },{ 4112.6f, 1722.9f },{ 4148.3f, 2110.53f },{ 4183.f, 2493.79f },{ 4217.7f, 2872.22f },{ 4251.6f, 3246.17f },{ 3633.f, 596.545f },{ 3673.f, 999.967f },{ 3712.6f, 1399.65f },{ 3751.0f, 1794.31f },{ 3791.f, 2193.16f },{ 3826.7f, 2571.76f },{ 3863.4f, 2953.13f },{ 3900.0f, 3330.48f },{ 3258.6f, 659.74f },{ 3300.8f, 1066.98f },{ 3342.4f, 1469.8f },{ 3386.5f, 1868.34f },{ 3425.2f, 2267.81f },{ 3463.9f, 2651.4f },{ 3502.9f, 3034.95f },{ 3542.1f, 3415.42f },{ 2877.3f, 724.687f },{ 2921.6f, 1135.42f },{ 2965.8f, 1541.69f },{ 3009.3f, 1943.02f },{ 3052.1f, 2340.18f },{ 3094.4f, 2732.46f },{ 3136.5f, 3119.82f },{ 3178.0f, 3502.2f },{ 2488.1f, 791.197f },{ 2535.4f, 1204.66f },{ 2582.1f, 1614.38f },{ 2628.4f, 2019.2f },{ 2673.7f, 2419.53f },{ 2718.6f, 2814.43f },{ 2763.3f, 3204.61f },{ 2807.6f, 3589.8f } };

vector<vector<Vec3f>> objectPoints;
objectPoints.push_back(vector<Vec3f>());
for (int row = 0; row < patterSize.height; row++) {
    for (int col = 0; col < patterSize.width; col++) {
        //int num = (row*patterSize.width + col) * 3;
        objectPoints.at(0).push_back(Vec3f(col, row, 0));
    }
}

vector<vector<Vec2f>> imagePoints1;
imagePoints1.push_back(vector<Vec2f>());
for (int row = 0; row < patterSize.height; row++) {
    for (int col = 0; col < patterSize.width; col++) {
        int num = (row*patterSize.width + col);
        imagePoints1.at(0).push_back(corners1.at(num));
    }
}

vector<vector<Vec2f>> imagePoints2;
imagePoints2.push_back(vector<Vec2f>());
for (int row = 0; row < patterSize.height; row++) {
    for (int col = 0; col < patterSize.width; col++) {
        int num = (row*patterSize.width + col);
        imagePoints2.at(0).push_back(corners2.at(num));
    }
}

Mat cameraMatrix = Mat::eye(3, 3, CV_64F);
Mat distCoeffs = Mat::zeros(5, 1, CV_64F);
vector<Mat> rvecs, tvecs;

calibrateCamera(objectPoints, imagePoints1, Size(6000, 4000), cameraMatrix, distCoeffs, rvecs, tvecs);
cout << cameraMatrix << endl;
calibrateCamera(objectPoints, imagePoints2, Size(6000, 4000), cameraMatrix, distCoeffs, rvecs, tvecs);
cout << cameraMatrix << endl;