[Matlab] Camera Calibration (Computer Vision Toolbox)

Image processing and computer vision is a major application area of ​​Matlab, this part includes 4 toolboxes - image processing, computer vision, radar, medical image. Since visual things are easy to present, start with the computer vision toolbox.

The official document introduces the computer vision toolbox as follows: Design and test computer vision, 3D vision and video processing systems, provide algorithms, functions and applications that can be used for feature detection, object recognition, semantic segmentation and camera calibration, etc. In addition, There are vision and point cloud SLAM, stereo vision, point cloud processing and motion estimation, etc. However, there is currently a separate radar toolbox for radar point cloud related processing, which will be introduced later.

insert image description here

camera calibration

Camera calibration is used to estimate the parameters of an image or a camera's lens and image sensor. Through calibration, lens distortion, depth estimation, object measurement and 3D scene reconstruction can be handled.

insert image description here

Camera parameters include camera intrinsic parameters, camera extrinsic parameters and distortion coefficients. Through camera calibration, you can:

  1. Plot the camera's relative position (coordinate system transformation) and calibration mode.
  2. Computes the reprojection error.
  3. Computes parameter estimation errors.

The camera can be automatically calibrated through the MATLAB application Camera Calibrator, which is suitable for pinhole cameras and fisheye cameras.

cameraCalibratorOpen the camera calibration program through the APP or enter directly on the command line :

insert image description here

Before calibrating, print or buy a sheet of checkerboard paper, which can be generated from this website . After printing out on A4 paper, measure the actual length of a grid to be 20mm.

insert image description here

Entering the camera calibration program, you can take a checkerboard photo in advance, or you can take it online, and put the checkerboard paper in the distance and near, and stop for a short time in several positions up, down, left, and right.

insert image description here

After setting the time interval and number of shots, you can automatically take photos:

insert image description here

You will then be prompted for the length of the side of the checkerboard:

insert image description here

Then close the collector and click Calibrate to start calibration:

insert image description here
After the calibration is completed, the effect is as follows:

insert image description here

Click Export Camera Parameters, you can see the camera parameters in the matlab workspace:

insert image description here
insert image description here

Command line input cameraParams.IntrinsicMatrixcan view the internal parameters of the camera:

insert image description here

Corresponding parameters in the workspace:

insert image description here

In the same way, you can view other parameters:

insert image description here

After calibration, the accuracy of the single camera calibration can be evaluated and improved,
1. Check the reprojection error
The reprojection error is the distance (in pixels) between the detected point and the corresponding reprojected point, in bar displayed in graph form. In general, an average reprojection error of less than one pixel is acceptable, and a bar graph can be selected to select images and remove images with large errors.

insert image description here

2. Examining extrinsic parameter visualization
The 3-D extrinsic parameter map provides a camera-centered checkerboard view and a tessellated camera-centered view. A camera-centric view is useful if the camera is stationary when the image is captured. A view centered on the checkerboard is useful if the checkerboard is stationary. You can click and drag the graph to rotate it. Click on the board (or camera) to select it. The data highlighted in the visualization corresponds to the selected image in the list. Check the relative positions of the checkerboard and the camera to see if they are what you expect. For example, a checkerboard that appears behind the camera indicates a calibration error.

insert image description here

3. Check the undistorted image
To see the effect of removing lens distortion, click Show Undistorted on the view, if the calibration is accurate, the distorted lines in the image preview will become straight lines.

insert image description here

To improve the calibration results, remove high-error images, add more images, or modify the calibration procedure settings until satisfactory results are obtained.

The improved results can be exported to the workspace again.

Measure planar objects with a calibrated camera

。。。

that's all.

Guess you like

Origin blog.csdn.net/qq_40344790/article/details/127241652