Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to calibrate the camera in Python

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article shows you how to calibrate the camera in Python, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Distortion can be resolved with the following:

Similarly, another tangential distortion is because the imaging light does not reach the mirror plane completely parallel. So some areas look closer than expected. It can be solved in the following ways:

Due to radial distortion, the straight line appears as a curve, which becomes more obvious as the line is farther away from the center of the image. For example, in the picture shown below, the two edges of the chessboard marked in red, you can see that the chessboard is not a straight line, nor does it match the red line. All the straight lines are convex.

We need to find five parameters, called distortion parameters:

In addition, we need to find more information, such as the internal and external parameters of the camera, which are camera-specific parameters. Including focal length (fx,fy). Optical Center (cx,cy). Also known as the camera matrix. It only depends on the camera itself. Once calculated, it can be saved for later use. It should be a matrix of 3x3:

Basic settings of Python

To find the pattern of the chessboard, we use the function cv2.findChessboardCorners (). We also need to pass the type of pattern we are looking for, such as 8x8 grid, 5x5 grid, etc., in this example, we use 7x6 grid (generally speaking, the chessboard is the inner corner of 8x8's square 7x7), which returns corners. These corners are placed in order from left to right and from top to bottom.

This function may not be able to find the desired pattern in all the images, so the choice of a number is to write the code, start the camera, then check each frame, find the desired pattern, when the pattern is obtained, find the corner, and store it in the list. Provide some intervals at the same time, and then we can adjust the orientation of our chessboard as we read the following frames. Keep going through this process until you get all the good patterns you need. Even in this case, we don't know how much is good, so we read in all the images and get the good ones.

The external parameters correspond to the rotation and translation vectors to reflect a three-dimensional point into a two-dimensional system.

For stereoscopic applications, these distortions need to be corrected first. To find all these parameters, all we have to do is provide some sample images (such as chessboards) with well-defined patterns. We find specific points (the four corners of the chessboard), we know their real-world coordinates, we know their coordinates in the image. Through these data, the background can solve some mathematical problems to get the distortion parameters.

The above is how to calibrate the camera in Python. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report