You are here: Start » Program Examples » Calibration with Editor on Remapped Images

Calibration with Editor on Remapped Images

Aim

The goal is to compute the world coordinates of the dots based on given images of the calibration grid.

Input

A few images of the calibration grid and the dots.

Output

The coordinates of the found dots.

Hints

First of all, as there are both lens and perspective distortion, they need to be removed by using the RectifyImage filter. Next, to correctly locate the dots it is best to use the ExtractBlobs_Intensity. Eventually, to find the center points of circles, try fitting a corresponding shape to them and use an appropriate property output.

Solution (AVS)

  1. In the Project Explorer section create a Global Parameter named RectificationMap of RectificationMap type. In the Initial Value section click on the 3 dots button to open the editor.

  2. In the first step of calibration remove lens distortion:

    • Load an with the calibration grid.
    • Choose the Chessboard type.
    • Count the chessboard squares horizontally and vertically and enter the numbers in the parameters section.
    • Use Locate button to find calibration points.
    • Calibration will be most precise within the green area. In order to achieve best performance on entire picture the calibration grid should cover it completely. You can use a number of pictures to achieve this. Just load them into the editor on the right.
    • Use Compute Calibration Model to calculate Camera calibration model and activate the next step.
  3. In the second step of the calibration, we will determine the transformation between Real-world points and image points:

    • Load an image with the calibration grid.
    • Choose Calibration grid.
    • Choose the Chessboard type and fulfil the Width and the Height information like in a previous step. Set the Square size as 7,5.
    • Use Locate button to find calibration points.
    • Select black cursor icon.
    • Click on point A. In the table with points insert World X [mm]: 0 and World Y [mm]: 0.
    • Click on point B. In the table with points insert World X [mm]: 0 and World Y [mm]: 120.
    • Click on point C. In the table with points insert World X [mm]: 172,5 and World Y [mm]: 120.
    • Click on point D. In the table with points insert World X [mm]: 172,5 and World Y [mm]: 0.
    • Click the Compute World Transform button.
    • Click the Next > button.
  4. Last step of the calibration is used to set parameters of the image after rectification:

    • Load an image with the calibration grid.
    • Click the Generate Rectification Map button.
    • Click the OK button.
  5. In the ACQUIRE section of the application add the EnumerateImages filter and set the inDirectory to the location of the dots' images.

  6. In the PROCESS section add the RectifyImage filter. Connet the inRectificationMap input to the RectificationMap parameter and the inImage input to the EnumerateImages outImage output.

  7. Create a new Step macrofilter named FindDiscs. Drag the RectifyImage outImage output to the new macrofilter to create the input.

  8. Go to the FindDiscs macrofilter. Add the ExtractBlobs_Intensity filter. Connect its inImage input to the macrofilter's input.

  9. Add 2 ClassifyRegions filters:

  10. Add the RegionBoundingCircle_OrNil filter and connect its input to the last ClassifyRegions outAccepted output.

  11. Add the FitCircleToEdges filter:

  12. Add a formula. Drag the outAlignedFittingField Axis.Radius out put form the previous filter to create the input and name it Radius.

    outDiameter = inRadius * 2

  13. Drag the formula output to the Macrofilter Outputs section.

  14. Go back to the Main macrofilter. Add the CreateCoordinateSystemFromPoint filter. Set the inPoint input as {50;50}.

  15. Add the AlignPoint filter. Connect its inAlignment input to the CreateCoordinateSystemFromPoint output and the inPoint input to the ImageWasherCenter output of the FindDiscs macrofilter.

  16. Create a new Step macrofilter named PixToMilimeters. Drag to it:

  17. Inside the PixToMilimeters macrofilter:

    • Label the WorldScale input.
    • Exapnd the AlignedPoint input to get X and Y values separately.
    • Add 3 PixelsToMillimetres filters:
      • Connect the inScale input with the WorldScale for each new filter.
      • For the first one, connect the inPixels to the Diameter macrofilter's input.
      • For the second one, connect the inPixels to the X macrofilter's input.
      • For the third one, connect the inPixels to the Y macrofilter's input.
    • Connect each PixelsToMillimetres outputs to the macrofilter's output and name them: Diameter_mm, PositionX_mm and PositionY_mm.
  18. Go back to the Main macrofilter. Create a new Step macrofilter named GenerateGraphics. Drag to it:

  19. Inside the GenerateGraphics create 2 Step macrofilters and name them VisualizeCordinateSystem and CreateLabels. Drag the Alignment macrofilter input to the VisualizeCordinateSystem step and all the rest of the inputs to the CreateLabels.

  20. Inside the VisualizeCordinateSystem macrofilter create a new Step macrofilter. Name it GeneratingAxis. Create 3 inputs of it:

  21. Inside the GeneratingAxis macrofilter:

    • Add the MakeSegment filter. Connect the inPoint2 input to the macrofilter's Point2 input.
    • Add the AlignSegment filter. Connect the inSegment input to the previous filter's output. Connect the inAlignment input to the macrofilter's Alignment input. Expand the outputs to get the outAlignedSegment Point2 value. Drag the outAlignedSegment output to the Macrofilter Outputs section.
    • Add the MakeStringLabel filter. Connect the inText input to the macrofilter's Axis input. Connect the inPosition input to the Point2 output of the previous filter. Drag the outLabel output to the Macrofilter Outputs section to create a new output.

Macrofilter Main.

Macrofilter CreateLabels.

Macrofilter FindDiscs.

Macrofilter GenerateGraphics.

Macrofilter GeneratingAxis.

Macrofilter PixToMilimeters.

Macrofilter VisualizeCordinateSystem.