Changes between Version 46 and Version 47 of Tutorial/GeometricCalibration


Ignore:
Timestamp:
Jan 29, 2015, 11:37:23 AM (9 years ago)
Author:
vaillant1p
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Tutorial/GeometricCalibration

    v46 v47  
    77We shall use the diameter of the half cylinder visible on the upper let of the image to set the calibration. Its physical diameter  is 2cm. The corresponding diameter in pixels can be obtained with the ruler displayed by the menu bar '''[Tools/ruler]''' of uvmat.
    88
    9 First zoom on the cylinder to optimize the precison. Select '''zoom on''', press the left mouse button and adjust the field with the directional key board arrows. Then unselect '''zoom on''' to allow for other mouse actions (otherwise zoom has priority). It is also useful to increase the contrast at the cylinder edge by setting '''MaxA''' to 100 in the frame '''[Scalar]''' (right side of uvmat).
     9First zoom on the cylinder to optimize the precison. Select '''zoom on''', press the left mouse button and adjust the field with the directional key board arrows. Then unselect '''zoom on''' to allow for other mouse actions (otherwise zoom has priority). It is also useful to increase the contrast at the cylinder edge by setting '''MaxA''' to 100 in the frame '''[Scalar]''' (right side of '''uvmat''').
    1010
    1111Then select the menu bar '''[Tools/ruler]''', press the left hand mouse button on the cylinder edge, draw a diameter keeping the mouse pressed, release it on the opposite edge. The length in pixels, 140, is displayed, so the scaling factor is 140/2=70 pixels/cm.
     
    2222The origin of the phys coordinates is now arbitrary. It is more convenient to have it for instance at the centre of the cylinder, now at (x,y)=(1.69, 4.05).
    2323
    24 To get the precise position of the cylindre, it is useful to introduce a projection circle, using in '''uvmat''' the menu bar command Projection '''[Projection object/ellipse]'''. In '''set_object''', select '''[!ProjMode]'''='none', so that the line is just used as a marker, without projection operation. Set XMax=1, YMax=1, the radius of the circle, and the coordinates (1.69, 4.05) of the centre in the table '''Coord'''. Then press '''[REFRESH]'''. To optimise the visualisation, zoom in and increase the image contrast to MaxA=100.
     24To get the precise position of the cylindre, it is useful to introduce a projection circle, using in '''uvmat''' the menu bar command '''[Projection object/ellipse]'''. In '''set_object''', select '''[!ProjMode]'''='none', so that the line is just used as a marker, without projection operation. Set XMax=1, YMax=1, the radius of the circle, and the coordinates (1.69, 4.05) of the centre in the table '''Coord'''. Then press '''[REFRESH]'''. To optimise the visualisation, zoom in and increase the image contrast to MaxA=100.
    2525
    26 To shift the coordinates, activate in '''geometry_calib''' the menu bar command '''[!Tools/Translate points]''', and fills  (x=-1.69, y=-4.05) in the edit box which pops up. The phys coordinates of the calibration points are then shifted, and a new calibration put the cylindre centre at the origin (0,0).
    27 
    28 put in the same folder.
     26To shift the coordinates, activate in '''geometry_calib''' the menu bar command '''[!Tools/Translate points]''', and fills  (x=-1.69, y=-4.05) in the edit box which pops up. The phys coordinates of the calibration points are then shifted, select '''[APPLY]''' in''' 'geometry_calib' ''': a new calibration put the cylindre centre at the origin (0,0). These new calibration data are saved in an .xml file in the same folder as the image.
    2927
    3028== '''Repeating the calibration''' ==
    3129To repeat the calibration for several image series obtained with the same camera at the same position, different methods can be used.
    3230
    33 - Copy the xml to the appropriate location, with the same name (but extension .xml) and path as the flle containing the image series. This is however not appropriate in general as the xml file contains other information, in particular about image timing.
     31- Copy the .xml file to the appropriate location, with the same name (but extension .xml) and path as the file containing the image series. This is however not appropriate in general as the xml file contains other information, in particular about image timing.
    3432
    3533- Open with '''uvmat''' one of the image of the series to calibrate, select '''[Tools/geometric calibration]''', and in the GUI '''geometry_calib''', the menu bar '''[!Import/All]''', then press''' [APPLY]'''. For further repetitions, the GUI '''geometry_calib''' can be left opened while new image series are opened, and '''[APPLY]''' repeated each time without importing the calibration data again. [[BR]]
     
    5048Introduce those in the two first columns of the table '''[!ListCoord]'''. This can be conveniently done by copy-paste Matlab vector x=[0 58.8 58.8 0] in the upper line of the x column, and y=[0 0 55.1 55.1] in the y column (use carriage return to validate the input).
    5149
    52 To perform the calibration, press '''[APPLY]''', first with the default option 'rescale' in '''calib_type'''. The image is now displayed in phys coordinates. We observe that the rectangular frame is slightly rotated. Furthermore the displayed precision, about 3 pixels, is not excellent.
     50To perform the calibration, press '''[APPLY]''', first with the default option 'rescale' in '''[calib_type]'''. The image is now displayed in phys coordinates. We observe that the rectangular frame is slightly rotated. Furthermore the displayed precision, about 3 pixels, is not excellent.
    5351
    54 To improve the precision we then apply the option 'linear' in '''calib_type''', which seeks a general linear transform, including rotation. The precision is indeed improved to about 1 pixel. The previous xml file has been saved with a ~, ('Dalsa1.xml~') so it can be reverted in case of error.
     52To improve the precision we then apply the option 'linear' in '''[calib_type]''', which seeks a general linear transform, including rotation. The precision is indeed improved to about 1 pixel. The previous xml file has been saved with a ~, ('Dalsa1.xml~') so it can be reverted in case of error.
    5553
    5654== 3D calibration with a target grid ==
    57 Most precise and general calibration relies on the use of a target grid. As an example, open in uvmat the image ima_6 in 'UVMAT_DEMO07_GeometryCalibration/Angles/Dalsa1' (accessible on http://servforge.legi.grenoble-inp.fr/pub/soft-uvmat/). Open the menu bar '''[Tools/geometric calibration] '''and pick four corner points ABCD with the mouse define the periphery of the phys grid selected for calibration. The first point A will define the phys axis origin while AB defines the x axis and AD the y axis. AB and DC should be parallel on the phys grid (see fig). Then select''' [!Tools/Detect grid] '''on the upper menu bar of''' geometry_calib''': you get a new GUI '''detect_grid''' in which you define (in phys units) the grid mesh and the positions of the  first and last points on each axis. A z position can be defiend as well, do not fill it in this example. The option white markers is selected (by default) indicating that the grid is white (the opposite option would be needed for a grid made of black crosses on a white background). After validation by '''[OK]''', the detected grid appears on uvmat.
     55Most precise and general calibration relies on the use of a target grid. As an example, open in uvmat the image img_10 in 'UVMAT_DEMO07_GeometryCalibration/multiple_planes/Dalsa1' (accessible on http://servforge.legi.grenoble-inp.fr/pub/soft-uvmat/). Open the menu bar '''[Tools/geometric calibration] '''and pick four corner points ABCD with the mouse define the periphery of the phys grid selected for calibration. The first point A will define the phys axis origin while AB defines the x axis and AD the y axis. AB and DC should be parallel on the phys grid (see fig). Then select''' [!Tools/Detect grid] '''on the upper menu bar of''' geometry_calib''': you get a new GUI '''detect_grid''' in which you define (in phys units) the grid mesh and the positions of the  first and last points on each axis. Enter the value 0 for the '''[first]''' ''x'' and ''y'', the distance between two points on the grid is 10 cm so enter 10 for '''[mesh]''' ''x'' and ''y''. According to the number of meshes you selected with your 4 points ABCD enter the correct value of '''[last]''' ''x'' and ''y''. A ''z'' position can be defiend as well, do not fill it in this example. The option white markers is selected (by default) indicating that the grid is white (the opposite option would be needed for a grid made of black crosses on a white background). After validation by '''[OK]''', the detected grid appears on '''uvmat'''.
    5856
    5957[[Image(Tutorial3 - Detect Grid)]]
     
    6159If a  point is not correct, select the option '''[!CheckEnableMouse]''' in '''geometry_calib'''. Then you can adjust the point marker by selecting it with the (left button) mouse and moving it while keeping the mouse pressed (when adjustement is finished, select the option  '''[!CheckEnableMouse]''' to avoid spurious point creation with the mouse).
    6260
    63 If the grid image is of poor quality, it is alternatively possble to mark all the points by the mouse, using the '''[!Tools/Create]''' grid instead of '''[!Tools/Detect grid]''' in geometry_calib (not convenient in general).
     61If the grid image is of poor quality, it is alternatively possible to mark all the points by the mouse, using the '''[!Tools/Create]''' grid instead of '''[!Tools/Detect grid]''' in geometry_calib (not convenient in general).
    6462
    6563Once the grid has been marked, the calibration can be performed by the press button '''[APPLY]'''. We observe that the simple option 'rescale' is not appropriate in this case: a perspective effect is clearly visible, together with a non-linear deformation (grid lines are curved on the image). Therefore select the option '3D_quadr' which applies a 3D projection and quadratic correction. The grid image now appears of good quality in phys coordinates.
    6664
    67 This 3D calibration relies on the [https://servforge.legi.grenoble-inp.fr/projects/soft-uvmat/search?q=attachment%3A3D_view.pdf pinhole camera model] (see [https://servforge.legi.grenoble-inp.fr/projects/soft-uvmat/search?q=wiki%3AUvmatHelp%23GeometryCalib UvmatHelp#GeometryCalib] section 8.1). It involves ''intrinsic parameters'' which characterize the optical system (camera and objective lens) and ''extrinsic parameters'' which describe the translation and rotation of the camera with respect to the physical coordinates. detailler sur le GUI. The intrinsic parameters are shown in the frame '''[Intrinsic Parameters] '''in the GUI '''geometry_calib'''. These are the focal lenghts (in pixel size on the sensor) '''[fx]''' and '''[fy]''',  the quadratic radial distortion coefficient '''[kc]''' and the coordinates '''[Cx]''' and '''[Cy]''' of the optical centre for this distortion (expressed in pixels on the image). The extrinsic parameters are shown in the frame  '''[Extrinsic Parameters]. '''It indicates in particular the translation T_z which represents the distance from the camera to the origin of the phys coordinates. Note that the calibration grid has been assumed by default to be at z=0, but this can be changed by selecting '''[!Tools/Translate points]''' in '''geometry_calib''' and entering a translation in ''z'' for the grid point coordinates.
     65This 3D calibration relies on the [https://servforge.legi.grenoble-inp.fr/projects/soft-uvmat/search?q=attachment%3A3D_view.pdf pinhole camera model] (see [https://servforge.legi.grenoble-inp.fr/projects/soft-uvmat/search?q=wiki%3AUvmatHelp%23GeometryCalib UvmatHelp#GeometryCalib] section 8.1). It involves intrinsic parameters which characterize the optical system (camera and objective lens) and extrinsic parameters which describe the translation and rotation of the camera with respect to the physical coordinates. The intrinsic parameters are shown in the frame '''[Intrinsic Parameters] '''in the GUI '''geometry_calib'''. These are the focal lenghts (in pixel size on the sensor) '''[fx]''' and '''[fy]''',  the quadratic radial distortion coefficient '''[kc]''' and the coordinates '''[Cx]''' and '''[Cy]''' of the optical centre for this distortion (expressed in pixels on the image). The extrinsic parameters are shown in the frame  '''[Extrinsic Parameters]. '''It indicates in particular the translation T_z which represents the distance from the camera to the origin of the phys coordinates. Note that the calibration grid has been assumed by default to be at z=0, but this can be changed by selecting '''[!Tools/Translate points]''' in '''geometry_calib''' and entering a translation in ''z'' for the grid point coordinates.
    6866
    69 A last''' '''item needed to define calibration in a 3D context is the determination of the plane of the object in the phys coordinates. It is assumed by default to be the plane z=0, but this can be changed by the menu bar option '''[!Tools/Set slice] '''of uvmat. It is then possible to change the assumed z position, keeping the same calibration. Observe the corresponding change in the grid scale, since the same grid is then assumed to be at a different distance.
     67A last''' '''item needed to define calibration in a 3D context is the determination of the plane of the object in the phys coordinates. It is assumed by default to be the plane z=0, but this can be changed by the menu bar option '''[!Tools/Set slice] '''of '''uvmat'''. It is then possible to change the assumed ''z'' position, keeping the same calibration. Observe the corresponding change in the grid scale, since the same grid is then assumed to be at a different distance.
    7068
    7169== 3D calibration improved by multiple planes: ==
    72 The calibration of previous section provides 3D information thanks to the inclination of the calibration grid, but the precision is not optimum, and the process would not converge for a grid perpendicular to the line of view. A more precise procedure consists in first determining the intrinsic parameters by mutiple views of the same grid with different inclinations, as shown in the example **.
     70The calibration of the previous section provides 3D information, such as the intrinsic parameters, thanks to the inclination of the calibration grid, but the precision is not optimum, and the process would not converge for a grid perpendicular to the line of view. A more precise procedure consists in first of determining the intrinsic parameters by mutiple views of the same grid with different inclinations.
    7371
    74 Open su the grid image is correctly set, click on the '''[APPEND LIST]''' button in '''[Point Lists]'''. This will save the grid as 'img~.xml'. This document is saved in the same folder as the image. To open this document select '''[Import.../Calibration points]'''.
     72Once the grid image is correctly set, click on the '''[APPEND LIST]''' button in '''[Point Lists]''' in''' 'geometry_calib''''. This will save the grid as 'img~.xml' file. This document is saved in the same folder as the image. To open it select '''[Import.../Calibration points]'''.
    7573
    76 Durind the calibration, some intrinsic parameters are determined
     74Now that the calibration is made for the first image we need to do it for the other ones, you can open the different grids 'img.ref~.xml' to skip the calibration. Once a document is open, the grid is shown in '''uvmat''', to save it in the '''[Point Lists]''' click on '''[APPEND LIST]''', it will appear below the first saved document.
    7775
    78 Now that the calibration is made for the first image we need to do it for the other ones (you can also open the different grids 'img.ref~.xml' to skip the calibration). Once a document is open, the grid is shown in '''uvmat''', to save it in the '''[Point Lists]''' click on '''[APPEND LIST]''', it will appear below the first saved document.
     76'''Note:''' if the serie is missing some images (ie the increment from one image to another is not steady), '''uvmat''' will not allow you to use the arrow '''[->]'''  to move from an image to another if the increment is set. To avoid this  delete the number in '''[increment]''', you will then be able to go from an  image to another.
    7977
    8078When all the grids are selected in '''[Point Lists]''', select '''[APPLY]'''. The calibration on every image is now made and the values of the intrinsic parameters are reevaluated according to the different data determined by every calibration. Note that the more images used for the calibration, the more precise the intrinsic parameters will be.
    8179
    82 For the next calibration, to avoid any change on the intrinsic parameters, select the option '''3D_extrinsic'''. It applies a 3D projection and quadratic correction according to the intrinsic parameters.
    83 
    84 '''Note:''' if the serie is missing some images (ie the increment from one image to another is not steady), '''uvmat''' will not allow you to use the arrow '''[->]'''  to move from an image to another if the increment is set. To avoid this  delete the number in '''[increment]''', you will then be able to go from an  image to another.
     80For the next calibration, to avoid any change on the intrinsic parameters, select the option '''3D_extrinsic''' in '''[calib_type]''' in''' 'geometry_calib''''. It applies a 3D projection and quadratic correction according to the already determined intrinsic parameters.
    8581
    8682== '''Merging the images of several cameras:''' ==
    87 Open with '''uvmat''' the image 10 in 'UVMAT_DEMO07_GeometryCalibration/Dalsa1'. Create a projection plane using the menu bar tool '''[Projection objects/plane]''', select '''[!ProjMod]''' =interp_lin, '''[Min x]''','''[Min y]''' = -100, '''[Max x]''','''[Max y]''' = 100 and click on '''[REFRESH]'''.
     83Open with '''uvmat''' the image 10 in 'UVMAT_DEMO07_GeometryCalibration/multiple_planes/Dalsa1'. Create a projection plane using the menu bar tool '''[Projection object/plane]''', select '''[!ProjMod]''' =interp_lin, '''[Min x]''','''[Min y]''' = -100, '''[Max x]''','''[Max y]''' = 100 and click on '''[REFRESH]'''. The image will appear in a new''' 'view_field' '''frame.
    8884
    8985Now that the projection plane is set, in '''series''' ('''[Run/field series]''') open the two other images 10 from Dalsa2 and Dalsa3 by selecting in the menu bar tool '''[!Open/Browse append...]'''. You can now see the three files in the '''[Input Files]''' table.