loading
 
automatic image calibration parameters
pat from United States  [12 posts]
1 year
I want to do automatic calibration in one script, and then load these calibration parameters and warp images when I run another script. How do I do that?

Can I save the calibration parameters in a file?


Steven Gentner from United States  [1370 posts] 1 year
Pat,

If you download the latest version there is now an export button in that module to export the needed warping parameters to a text file (its actually just the variables that the module creates too). Using the same module in another configuration you can then load in that configuration file using the Import filename text box which will monitor that file and reload if it ever changes. This allows for the robofile to be updated across many machines without needing to recalibrate each time because those parameters which are specific to each camera can now be stored externally to the robofile.

v2.80.30 has this update.

STeven.
pat from United States  [12 posts] 1 year
thanks Steven for the new feature. Follow up questions:

can you provide the equation that does the calibration? i.e. how the exported calibration variables can be used to transform the warped image to the unwarped image?

also can I export the pixel location of the corners in the checkerboard pattern?
Steven Gentner from United States  [1370 posts] 1 year
Pat,

We've made an update to create a AUTO_CALIBRATION_CORNERS array that will hold the corner points that can be exported by other modules (like Write_Variables). Note that this array is ONLY created on calibration ... if you calibrate and just read in the calibration values it will not generate this array as it skips the corner finding process unless the calibrate button is pressed.

In terms of the equation, its not just a simple equation but an entire process. You do see the values of the equations in the parameters box (both intrinsic and extrinsic). The parameters can can be reduced to a single matrix but if you are looking to use the results in another system it is probably easier to use that system to create its own transformation using the corner points. We typically avoid using matrix calculations as one normally would as we find better optimizations are possible using direct methods but that's probably just us. What I can mention is that the order of usage (which is very relevant is)

Z rotation
Y rotation
X rotation
scale
perspective
translation
lens warping (intrinsic)

but again that's just the order we found to work best for us. Other applications will do this differently.

STeven.
pat from United States  [12 posts] 1 year
thanks Steven,

having the corner coordinates help me a lot, is that the original (warped) corners or the corrected (unwarped) corners, or both?

as for the equation, I am only interested in intrinsic lens correction. So I would imagine I only need the equation involving some of the K parameters and U0 and V0. Is the equation used to transform warped to unwarped, or unwarped to warped?
Steven Gentner from United States  [1370 posts] 1 year
Pat,

Its the unwarped corner points as found in the original image. The idea is that with those corner points and an understanding of the detected grid you can simply assign each point to a point in a corrected grid and find the formula that warps correctly. For example, if you know that the detected points form a 4x5 grid, the first point would be warped to point 0,0 and the second to 100,0 and the third to 200,0 and the 6th to 0, 100. This assumes that each square is 100 pixels big ... which is why that is a parameter in the interface.

We added AUTO_CALIBRATION_CORNERS_WIDTH and AUTO_CALIBRATION_CORNERS_HEIGHT to provide the needed width and height of the detected grid. From those you create your own destination points that fit into your needs.

The intrinsic warping formula is easier. See at the bottom of

http://www.roborealm.com/help/Radial.php

about what that formula looks like. In this case it looks like

x = X-u0
y = Y-v0
r = sqrt(x^2+y^2);
z = K0 + (K1*r) + (K2*r*r);
s = -KS/z;
X = x*s;
Y = y*s;

as this can be found from most documentation about intrinsic calibration. Note that the radial module goes to power 4 where as the auto_calibrate module only goes to a power of 2 ... which should be ok in most cases.

Note that this is the formula from the unwarped to the warped image. The really tricky part is to figure out how to fill the holes in the destination image!

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index