Disclaimer: Anyone and organizations are welcome to repost the articles in this blog, but the original links and author information must be marked.
Link: http://blog.csdn.net/li_007/archive/2010/03/16/5384937.aspx
Pioneering little turtle -------> csdn
During this period of time, the camera calibration and image malformed Correction Problems are almost the same. Let's take a break and share some results with you!
I. Calibration
There are too many online materials and a lot of methods to tell the truth about camera calibration. I personally think that if you want to study this, You can first understand the basic principles and then look at the opencv Example calibration. If you want to learn more, we suggest you download some papers.
Of course I recommend a Web site: http://www.ti-times.com/dfiles.asp? FL = download (Shenzhen sci-tech era) I also found it in the process of searching for information. I think it summarizes a lot of useful information for us.
Here, I will explain a little. The calibration of opencv is based on Zhang zhengyou's calibration method. During the calibration process, we should avoid the angle skew difference between the two calibration plates being too small, this will produce a lot of errors (of course, we can combine some methods in the paper to improve the algorithm ).
Previous: http://hi.csdn.net/space-9784-do-album-picid-497526-goto-down.html (csdn blog upload picture function is harmonious)
Ii. Malformed correction
In fact, we have completed malformed correction in the calibration example of opencv. However, in my project, due to some restrictions, if no correction is made, 2.8 of the lenses will be filled with the entire touch area, but after correction, because it is mainly radial distortion, opencv is the same size before and after correction, which will inevitably cause some corrected images to be cropped. No way, I had to write the most basic Correction Algorithm by myself. Now I will post some basic algorithm principles.
Picture: http://hi.csdn.net/space-9784-do-album-picid-497527-goto-down.html
The specific code is as follows: (TMD, code insertion is also harmonious, and csdn is poor, ready to transfer the blog)
// # Pragma parallel OMP
For (INT I = 0; I <realwidth; I ++)
{
// # Pragma parallel OMP
For (Int J = 0; j <realheight; j ++)
{
// Point U and V in the pixel Coordinate System of the image in the physical Coordinate System
Double u = I-65;
Double V = J-25;
// Calculate the point in the physical Coordinate System of the Image Based on the relationship between the point in the physical Coordinate System of the image and the point in the pixel Coordinate System of the image.
//
// U = x/dx + U0 FX = 1/dx
// V = y/dy + V0 FY = 1/dy
Double X = (u-U0)/FX;
Double Y = (V-V0)/fy;
Double r2 = POW (x, 2) + POW (Y, 2 );
Double r4 = POW (R2, 2 );
Double Fr = 1 + K1 * r2 + K2 * R4 + K3 * R2 * R4;
Double UD = (u-U0) * FR + U0;
Double Vd = (V-V0) * FR + V0;
Int U0 = int (UD );
Int V0 = int (VD );
Int U1 = int (1 + ud );
Int V1 = int (1 + VD );
If (UD> 0 & UD <640 & VD> 0 & VD <480)
{
Fcimageplus-> image. pdata [I + J * realwidth] = pixelinterpolation (tmpimage [0]. image. pdata,
UD, Vd, U0, V0, u1, V1 );
}
}
}
Result texture:
Http://hi.csdn.net/space-9784-do-album-picid-497528-goto-down.html
Http://hi.csdn.net/space-9784-do-album-picid-497525-goto-down.html