You are here: Start » Program Examples » Tablets
Tablets
Aim
The aim of the program is to detect missing or damaged tablets on a conveyor belt.
Input
A series of images from the conveyor of a production line.
Output
Detected missing or damaged tablets:
Hints
To detect damaged tablets it is recommended to consider using a DetectMultipleCircles filter together with a CheckPresence_Intensity filter to verify object presence by analyzing pixel intensities. To ensure that the inspection is performed once for an every batch of tablets, you can specify a Region Of Interest, where the inspection should be performed, as an input of CheckPresence_EdgeAmount filter.
Solution (FIS)
-
Add an EnumerateImages filter to get load consecutive images of some disk directory.
-
Add a CheckPresence_EdgeAmount filter.
- Connect outImage from the previous filter to inImage of the current one.
- In Properties window in the bottom left corner set inEdgeScale to 2.
- Set inMinAmount to 0.27 to determine the minimum amount of the pixels that should be detected.
- Click on the CheckPresence_EdgeAmount filter and select inRoi parameter in the Properties window to mark the ROI.
-
In Project Explorer find a "Create New Global Parameter" icon and click it. Set name to Roi and type to Region. Mark the ROI as follows:
-
Now create a new Variant Step Macrofilter and name it AnalyzeTablets. Define forking port of Bool data type and name the input inTabletsPresent.
- Connect outImage to newly-created macrofilter.
- Connect outIsPresent to inTabletsPresent.
-
Now step into the AnalyzeTablets macrofilter. In "False" variant no changes should be made.
-
In variant "True" add a DetectMultipleCircles filter.
- Connect macrofilter input inImage with inImage.
- Connect global parameter Roi to inRoi.
- Set inRadius to 7 (approximate radius of tablets), inMaxOverlap to 0 (to avoid overlapping), inMinScore to 15 (in order not to miss any tablet) and inEdgeThreshold to 6 (the minimum accepted edge magnitude).
-
Add a CircleBoundingBox filter. Connect outCircles.Circle to inCircle.
-
Add a CheckPresence_Intensity filter.
- Connect macrofilter input inImage with inImage.
- Right-click on inRoi and select Expand structure fields.
- Connect outBoundingBox with inRoi.Frame.
- Set inMinContrast to 18 to avoid detecting bad tablets as good ones by checking their contrast.
-
Add a DrawCircles_TwoColors filter.
- Connect macrofilter's input inImage to inImage.
- Connect outCircles.Circle to inCircles.
- Connect outIsPresent from previous filter to inConditions of the current one.
- Set inColorIfTrue to green, inColorIfFalse to red.
- Set inDrawingStyle.Opacity to 0.3.
- Set inDrawingStyle.Filled to True.
-
Add a CropImage filter.
- Connect outImage to inImage.
- In inSelection choose the area to be cropped. If there is no reference image available, try to run the program first.
-
Connect outImage to macrofilter output.
-
Go back to Main and add a LastNotNil filter (click "Choose later" while generic filter choosing) and connect macrofilter's output outImage with inObject.
-
Now create HMI by clicking on HMI Designer in the upper toolbar.
- Add videoBox and connect outImage to its input inImage. It is going to display the images from the production line.
- Add other videoBox and connect outImage from AnalyzeTablets to its input inImage.
Macrofilter Main
Macrofilter AnalyzeTablets(True) performs inspection when the pills caret is position.
Macrofilter AnalyzeTablets(False)
Used Filters
Icon | Name | Description |
---|---|---|
![]() |
EnumerateImages | Emulates image acquisition with images stored on disk. |
![]() |
DetectMultipleCircles | Detection of circular or close-to-circular objects like holes, pins, pills, particles. |
![]() |
CropImage | Reduction of the amount of image data to be stored in memory. |
![]() |
CheckPresence_EdgeAmount | Quick and easy presence verification, e.g. for missing caps, screws, labels. |
![]() |
CircleBoundingBox | Computes the smallest box containing a circle. |
![]() |
CheckPresence_Intensity | Quick and easy presence verification, e.g. for missing caps, screws, labels. |
![]() |
LastNotNil | Returns the last value passed that existed. |
Further Readings
- Image Analysis - List of filters analyzing images.