You are here: Start » Program Examples » Blister Inspection (NET GmbH)

Blister Inspection (NET GmbH)

Aim

The task is to detect missing and broken pills in a blister.

Input

An image of a blister. The position of the object is variable, but limited.

Output

Detected missing and broken pills:

Hints

As variations of the object positions are limited, it can be located accurately with a very standard and fast Shape Fitting approach. With two FitSegmentToEdges filters it is possible to locate the top and the left edges. The found rectangle can be used as a reference for further inspections.

In this case pills can be easily found using high level tools for color analysis like CheckPresence_PixelAmount.

Solution (AVS)

  1. Create variant macrofilter GrabImage with forking port inSource of type String.

  2. Add two variants Files and Camera. And create output of type Image.

  3. To the variant Files add EnumerateImages to get images from a directory. Connect a filter output to a macrofilter output.

  4. To the variant Camera add filter GigEVision_GrabImage to get images from your camera. If your camera does not support GigeVision standard use the other filter. Connect a filter output to a macrofilter output.

  5. Create macrofilter LocateBlister in which find a blister rectangle.

  6. To find blister horizontal and vertical edges must be found using a Shape Fitting technique. Add two FitSegmentToEdges filters and setup scanning paths like on the image below. Set inEdgeScanParams.EdgeTransition to DarkToBright.

  7. To find a top-left point of blister segments must be converted to lines. The top-left point will be the intersection of lines created from found segments. Add filter LineLineIntersection and connect found segments.

  8. To create a reference rectangle, rotation of the blister is necessary. To find rotation, add filter SegmentOrientation and connect to it segment found on the top of the blister.

  9. Add filter CreateRectangle and connect to it the top-left point of blister, connect rectangle orientation from SegmentOrientation.

  10. Size of the blister can be found using the measuring tool.

  11. Set inWidth to 1075. Set inHeight to 862.

  12. To make setting this parameters more convenient, extract inWidth and inHeight to global parameters BlisterWidth and BlisterHeight.

  13. To create reference CoordinateSystem2D add filter CreateCoordinateSystemFromRectangle and connect to it the previously created rectangle.

  14. Create a new macrofilter output outReference from the output of CreateCoordinateSystemFromRectangle.

  15. When reference system was found places where are pills should be set. Create a new global parameter of type Rectangle2DArray and name it Rectangles.

  16. Set Rectangles value like on the image below. Rectangles will be used to determine if marked pill is not damaged.

    Remember to set outReference as the Coordinate system in the Rectangle Editor.

  17. To improve color analysis, the input image should be blurred. Blurring makes colors on the image more uniform. Add filter SmoothImage_Gauss and set inStdDevX to 3.0.

  18. Check presence of the pill using filter CheckPresence_PixelAmount.

    Selected colors can be found in the outForeground output. Result is showed on the image below.

  19. To CheckPresence_PixelAmount ROI connect Rectangles and to inRoiAlignment connect outReference computed in LocateBlister.

  20. Using filter DrawEllipses_TwoColors draw results. Use data from the outIsPresent and outAlignedRoi.Frame.

Macrofilter Main

Macrofilter GrabImage(Files) loads images from a directory.

Macrofilter GrabImage(Camera) gets images from the camera using the GigEVision interface.

Macrofilter LocateBlister

Used Filters

Icon Name Description
EnumerateImages Emulates image acquisition with images stored on disk.
CreateRectangle Creates a rectangle from an aligned point.
CreateCoordinateSystemFromRectangle Most often used to define an object alignment from a filter like RegionBoundingRectangle.
DrawEllipses_TwoColors Draws ellipses on an image with two colors, depending on the status of each ellipse (usually: green or red for pass/fail status).
CheckPresence_PixelAmount Quick and easy presence verification, e.g. for missing caps, screws, labels.
GigEVision_GrabImage The most recommended filter for working with GigE Vision devices.
SegmentOrientation Computes the orientation of a segment.
SmoothImage_Gauss Removal of gaussian noise from images.
FitSegmentToEdges Precise detection of a straight edge, whose rough location is known beforehand.
LineLineIntersection Computes a common point of two lines.

Further Readings