Monocular Camera Calibration Based on MATLAB

1 Introduction

Recently, I came into contact with the camera calibration experiment. It feels quite interesting and the operation is not difficult. Therefore, I would like to take this article to record and share how to use the MATLAB toolbox for monocular camera calibration.

2. Preparations

Here we are monocular camera calibration based on MATLAB, so we need to use the MATLAB environment. Here I use the MATLAB R2017a version. This experiment also needs to use the toolbox-calib in the figure below.
Baidu network disk download link: Toolbox
Extraction code: vinc
insert image description here
I use MATLAB2017 version here, other versions should also be compatible with this toolbox, so you can download and operate by yourself.

3. Calibration process

1. Calibration preparation stage

1. After downloading the toolbox, you can decompress it to any fixed location. I decompress it here and put it in the matlab folder.
insert image description here
2. After opening matlab, click to set path
insert image description here
3. Add toolkit file
Click to add folder, find the TOOLBOX_calib folder at this time, then add the file into it, and finally save and close.
insert image description here
4. Import calibration pictures
Here I will store the pictures to be calibrated in the JQimage_R file of the D disk, and then open matlab, and point the file directory to the picture collection directory to be calibrated. As shown below:
insert image description here

2. Calibration operation steps

1. After the above operations are completed, enter calib on the command line at this time, and the calibration interface will pop up. There are two options in this interface, and I chose the first one (the difference is not big, the difference is the meaning in the brackets).
insert image description here
2. After clicking the above options, the window shown in Figure 1 below will appear, and then click the option pointed by the arrow below, and the information pointed to by the arrow in Figure 2 will appear. This line of information is required to enter the name of the picture, and the calibration imported from above As you can see from the picture, the name of the picture here is Image. After entering, press Enter, and the information of the other party will appear. This is the format of the input picture. The format here is tif.
insert image description hereinsert image description here
3. Next, select the read picture option box as shown in Figure 1 below, and then the preview picture box as shown in Figure 2 will pop up after reading the picture.
insert image description here
insert image description here
4. Then we directly click the third option box to extract the corner points. After clicking, the command prompt line will appear to process the picture. The brackets are all by default, so we will default here, just press Enter. After pressing Enter, the corner window selection will appear. The default corner window in my version is 5X5, and you can use the default operation first. I am operating with the default corner window size here. When there is an error later, error correction is performed. So here you can just press enter.
insert image description here
5. After the above operations, a picture box will pop up, and the mouse will turn into a black cross at this time. Try to operate this interface in full screen to improve the accuracy of corner point calibration. This is the corner point extraction of the first picture, and the sub-outer corner points are extracted in a clockwise or counterclockwise order. After the extraction is complete, press Enter to continue to extract the next picture, and so on to complete the extraction of all pictures.
insert image description here
I have 20 pictures here. After the extraction is completed, the command prompt line is displayed as follows:
insert image description here
6. After the extraction is completed, perform calibration, and click the option box in the following figure to start calibration (after clicking, don’t worry about it, it will automatically perform calibration and get data). After the automatic calibration is completed, the relevant data and errors in Figure 2 will appear.
insert image description here
insert image description here
7. From the data in Figure 2 in the above operation 6, we can know the size of the error, and then we need to analyze the error! Click on the options below.
insert image description here
Then the data analysis diagram as shown in the following figure will appear:

insert image description here

At this time, we can see that the distribution error of pink and green is very large, and they are not concentrated. At this time, use the cross to click a pink or a green plus sign (no matter who you click, you must follow these errors in turn) picture, to extract and calibrate again), and then the corresponding picture number and the specific error amount will appear on the command line. Here I clicked on the pink one.
insert image description here
8. At this point, click the following option to save the previously obtained data. It is better to continue the following operation only after saving.
insert image description here

3. Error analysis and adjustment

1. Immediately after the above operation, we click the re-extraction option box to re-extract the pink No. 18 picture.
insert image description here
Before the corner window was 5x5 by default, here it is set to 6x6. Enter the picture number after pressing Enter, and then enter a random value in the next line.

insert image description here
2. After re-extracting and calibrating, click Analyze, and you can find that the distribution of pink has changed slightly, but the change is not large, indicating that there is still a certain error. Then here I have repeatedly calibrated pink, but as shown in the picture below, it is still very divergent, and then we will first correct and recalibrate other pictures. Remember to save the previous data after each calibration~
insert image description here
3. At this time, repeat the extraction and calibration of another picture, and then try to reduce the error err. Here I am the result of repeated extraction and calibration of the green No. 15 picture. It can be clearly seen that the green mark has converged a lot.
insert image description here
4. In this way, I re-extracted and calibrated the scattered pictures above one by one. Later, I re-extracted and calibrated the pink color several times, as shown in the figure below: 5. At this time, you will find that using different data
insert image description here
insert image description here
repeatedly Re-calibration, always pink is divergent and cannot be gathered. At this time, we can delete the picture with a large error.
insert image description here
Enter the picture number to be deleted here.
insert image description here
After deletion, the analyzed data is as follows:
insert image description here
At this time, the error is also reduced a lot:
insert image description here
6. Click the following option box at this time, and the external parameters will be displayed in 3D form.
insert image description here
3D display of external parameters:
insert image description here
7. Click the following option boxes to view relevant data:
insert image description here

4. Conclusion

This article is a record of my own experiments. The experimental results may have a large error, because manual calibration may not be very detailed, but the overall camera single-target calibration operation process is as follows.
If there are deficiencies, please correct me!

The above operating environment is MATLAB R2017a~

Guess you like

Origin blog.csdn.net/m0_56817529/article/details/127819167