The calibration internal reference of fisheye camera 1080P is converted to 720P internal reference && fisheye camera calibration method

A fisheye camera is a wide-angle camera that can provide images with a large field of view, and is usually used in cars to improve driving safety. Some vehicles require a fisheye camera, mainly for the following reasons:

  1. Improve driving safety: Fisheye cameras can provide a larger field of view to help drivers observe the situation around the vehicle, including side and rear blind spots, as well as the position of pedestrians and other vehicles. This can reduce the driver's blind spot and improve driving safety.

  2. Assisted driving: Fisheye cameras can be used in automatic driving systems to provide a wider field of view and help vehicles identify and track surrounding vehicles, pedestrians and other objects, thereby making more accurate decisions on driving routes and speeds.

  3. Reversing assistance: The fisheye camera can provide a larger field of vision when reversing, helping the driver observe the situation around the vehicle and reduce accidents caused by blind spots when reversing.

  4. Ease of parking: Fisheye cameras can help drivers park more conveniently in tight parking spaces, while also reducing the risk of collisions when parking.

In short, the application of fisheye cameras in automobiles can improve driving safety and driving convenience, so it is widely used in some vehicles.

question

        Q: Are there any ready-made algorithms that can generate corresponding camera internal parameters for different resolutions? Is the calibrated data more accurate and reliable than the algorithm (the accuracy is not enough or the conversion reliability is not guaranteed in some scenarios)

        A: If it’s the same fisheye camera, it’s okay to push streams with different resolutions; if it’s a different fisheye camera, it may need to be recalibrated. ChatGpt replied:

// 代码如下:
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/calib3d.hpp>

using namespace std;
using namespace cv;

void convertCalibration(const Mat& K_1080, Mat& K_720) {
    int width_1080 = 1920; // 1080P的宽度
    int height_1080 = 1080; // 1080P的高度
    int width_720 = 1280; // 720P的宽度
    int height_720 = 720; // 720P的高度

    double fx = K_1080.at<double>(0, 0); // 水平焦距
    double fy = K_1080.at<double>(1, 1); // 垂直焦距
    double cx = K_1080.at<double>(0, 2); // 光心X坐标
    double cy = K_1080.at<double>(1, 2); // 光心Y坐标

    // 计算缩放系数
    double scale_width = (double)width_720 / (double)width_1080;
    double scale_height = (double)height_720 / (double)height_1080;

    // 计算新的内参矩阵
    K_720 = Mat::zeros(3, 3, CV_64F);
    K_720.at<double>(0, 0) = fx * scale_width;
    K_720.at<double>(1, 1) = fy * scale_height;
    K_720.at<double>(0, 2) = cx * scale_width;
    K_720.at<double>(1, 2) = cy * scale_height;
}

int main() {
    // 定义原始相机内参矩阵K_1080
    Mat K_1080 = (Mat_<double>(3, 3) << 1000.0, 0.0, 960.0, 0.0, 1000.0, 540.0, 0.0, 0.0, 1.0);

    // 定义新的相机内参矩阵K_720
    Mat K_720;

    // 转换内参
    convertCalibration(K_1080, K_720);

    // 输出转换结果
    cout << "原始内参矩阵K_1080:\n" << K_1080 << endl;
    cout << "新的内参矩阵K_720:\n" << K_720 << endl;

    return 0;
}

对于将1080P的内参转换为720P的内参,畸变系数矩阵不需要改变。因为畸变系数矩阵与图像分辨率无关,只与相机光学系统有关。所以,即使改变了图像的分辨率,畸变系数矩阵也不需要做任何改变。

因此,在上面提供的C++代码中,只需要将内参矩阵从1080P转换为720P即可,畸变系数矩阵不需要做任何更改。

1080 resolution effect picture below 

Effect picture after calculating the internal reference matrix of 720 resolution

 Feel good!

Calibration theory and method [ Fisheye camera calibration method - know ]

Guess you like

Origin blog.csdn.net/John_ToStr/article/details/130384608