You are here: Start » Program Examples » Tablets
Tablets
Aim
The aim of the program is to inspect a conveyor of a production line detecting missing or damaged tablets.
Input
A series of images from the conveyor of a production line. The image below is one of them.
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 analysing 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 previous filter with inImage of the current one.
- In Properties window in the lower left corner set inEdgeScale to 2.
- In Properties window in the lower left corner set inMinAmount to 0.27.
- Right-click on inRoi and select Expand structure fields. In inRoi.Frame mark the ROI.
- In Project Explorer find a "Create New Global Parameter" icon and click it. Set name to Roi and type to Region.
- 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 with 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, inMaxOverlap to 0, inMinScore to 15 and inEdgeThreshold to 6.
- Add CircleBoundingBox filter. Connect outCircles.Circle with inCircle.
- Add 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.
- Add DrawCircles_TwoColors filter.
- Connect macrofilter's input inImage with inImage.
- Connect outCircles.Circle with inCircles.
- Connect outIsPresent from previous filter with inConditions of the current one.
- Set inColorIfTrue to green, inColorIfFalse to red.
- Set inDrawingStyle.Opacity to 0.3.
- Set inDrawingStyle.Filled to True.
- Add CropImage filter.
- Connect outImage with inImage.
- In inSelection choose the area to be cropped. If there is no reference image available, try to run the program first.
- Connect outImage with macrofilter output.
- Go back to Main and add 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.