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.
Article directory
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.
Camera parameters include camera intrinsic parameters, camera extrinsic parameters and distortion coefficients. Through camera calibration, you can:
- Plot the camera's relative position (coordinate system transformation) and calibration mode.
- Computes the reprojection error.
- 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.
cameraCalibrator
Open the camera calibration program through the APP or enter directly on the command line :
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.
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.
After setting the time interval and number of shots, you can automatically take photos:
You will then be prompted for the length of the side of the checkerboard:
Then close the collector and click Calibrate to start calibration:
After the calibration is completed, the effect is as follows:
Click Export Camera Parameters, you can see the camera parameters in the matlab workspace:
Command line input cameraParams.IntrinsicMatrix
can view the internal parameters of the camera:
Corresponding parameters in the workspace:
In the same way, you can view other parameters:
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.
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.
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.
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.