You are here: Start » Program Examples » Calibration With Editor on Original Image
Calibration With Editor on Original Image
Aim:
The aim is to find discs on the input image and check their diameter.
Input:
A few images of black discs and the calibration grid.
Output:
Located objects with their diameters in millimeters.
Hints:
The fastest and simplest way to detect the black discs is the Blob Analysis technique. To fit the circle to the found objects, use the FitCircleToEdges and FitCircleToPoints. You don't have to transform the whole image to get results in millimeters, only the points of the object.
Solution (FIS):
-
Add the EnumerateImages filter to the Acquire section. Set the inDirectory as the path to the discs' image folder.
-
Create a new Step macrofilter, name it FindDiscs. Drag the outImage output from the previous filter to the new step to create the inImage input.
-
Inside the new macrofilter, add the ExtractBlobs_Intensity. Connect the inImage input with the macrofilter inImage input.
-
Set the MinArea parameter inside the inSplittingParams to 20000 in order to remove noise.
-
Drag the outBlobs output to the Macrofilter Outputs section to create the outWashersBlobs output.
-
Use the RegionMassCenter to get the center of the discs. Connect its input with the outBlobs output of the previous filter.
-
Add the MakeCircle filter:
- Connect the inCenter with the outMassCenter output of the previous filter.
- Connect the inRadius input to 134.
- Drag the outCircle output to the Macrofilter Outputs section to create the outCircleCenter output.
-
Go back to the Main macrofilter.
-
Add the FitCircleToEdges filter:
- Connect the inImage input with the the EnumerateImages output.
- Connect the inFittingField.Axis to the FindDiscs outCircleCenter* output.
- Click on Show/Hide Ports at the bottom of the filter and check the Point option in the outEdges submenu.
-
Create a new Step macrofilter, name it CalculateWorldDiameter. Drag the outEdges.Point output from the previous macrofilter to create the macrofilter input. Name it inEdgePoints.
-
Inside the CalculateWorldDiameter step, add the RemoveNils filter. Connect its input with the macrofilter's inEdgePoints* input.
-
Create a new global parameter of type RectificationTransform.
- Name it Transform.
- Click on the + button next to the Initialize value to show all parameters.
- Click on the ... button next to the CameraModel parameter to open the Editor:
- Load all images of the calibration board.
- In the Board Parameters section, choose the Chessboard. Set the Width to 25 and the Height to 18. Then, click the "Locate" button. The vertices of the chessboard squares should be marked in green.
- In the Camera Parameters section, leave the default settings.
- Click on the Compute Calibration Model. The results should be as on the picture below:
- Click on OK button to close the Editor window.
- Click on the ... button next to the Homography parameter and create a matrix as on the image below:
-
Go back to the CalculateWorldDiameter step. Add the ShiftWorldPlane filter to match inspected surface of discs. They are 13mm thick, which should be put as the inDeltaZ value. Connect the Transform global parameter to the inTransform input.
-
Add the ImagePointToWorldPlane filter. Connect the inTransform input to the ShiftWorldPlane output. Connect the inImagePoint input to the RemoveNils output.
-
Add the FitCircleToPoints filter. Connect the inPoints input to the output of the previous filter. Set the inOutlierSuppression to Huber. Drag the outCircle output to the Macrofilter Outputs section and name the new output outWorldCircle.
-
Click on Show/Hide Ports at the bottom of the filter and check the Radius option in the outCircle submenu.
-
To measure the diameter of the circles, you can use a formula. Drag the outCircle.Radius from the previous filter to create the input.
outDiameter = inCircleRadius * 2
-
Drag the formula output to the Macrofilter Outputs section.
-
Go back to the Main macrofilter.
-
You can create the label with diameter in millimeters to display. To do that, create a new Step macrofilter and name it CreateLabels.
-
Click on Show/Hide Ports at the bottom of the CalculateWorldDiameter macrofilter and check the Center option in the outWorldCircle submenu. Drag the new output to the CreateLabels macrofilter and name the new input inPoint.
-
Drag the outDiameter output from the CalculateWorldDiameter macrofilter to the CreateLabels macrofilter and name the new input inReal.
-
Inside the CreateLabels macrofilter, add the FormatRealToString and connect it to the inReal macrofilter input. Set the inFractionalDigitCount input to 2 and the inSuffix to mm.
-
Add the MakeStringLabel filter. Connect the inText input with the output of the previous filter. Connect the inPosition to the inPoint macrofilter input.
-
Drag the outLabel output to the Macrofilter Outputs section.