You are here: Start » Program Examples » Parallel Enumeration

Parallel Enumeration

Aim

The task of this example is to check the number of bottles, their orientation, level of liquid and presence of foam in the shortest possible execution time using Worker Task Macrofilters.

Input

An image of bottles. The position of the bottles may change both in relation to the camera as well as other bottles.

Output

An image with the result of the inspections drawn. If a defect is detected, a rectangle is drawn around it.

Hints

The location of the object is variable. Inspection steps of this program have been described in the Bottle Inspection example.

Compared to the original example, in order to reduce execution time image enumeration should be performed in parallel to the inspection.
To achieve this, a Worker Task Macrofilter should be used.

Labeling connections is explained in this article.

Solution (AVS)

  1. Load the program from the Bottle Inspection example.

  2. From the Project Explorer window create a new Worker Task Macrofilter named ImageEnumerator.

  3. From the Project Explorer window create a new ImageToInspect queue with Image data type.

  4. Go to the ImageEnumerator Worker Task Macrofilter and in the ACQUIRE section add EnumerateImages filter.

  5. Provide a proper path to the images in inDirectory input.

  6. In the PROCESS section add Queue_Push filter and assign ImageToInspect queue to it.

  7. Connect the outImage output from EnumerateImages filter to the inValue input of Queue_Push filter.

  8. Go back to the Main program.

  9. In the ACQUIRE section add Queue_Pop filter and assign ImageToInspect queue to it.

  10. Replace the connection from the outImage output with connection from the outValue output of Queue_Pop filter.

  11. Remove or disable EnumerateImages filter in Main.

  12. Program is ready to use. In the current version, programs using worker tasks can be properly run only in the Run mode (F5)

Macrofilter Main

Macrofilter ImageEnumerator

Used Filters

Icon Name Description
EnumerateImages Emulates image acquisition with images stored on disk.
CreateRectangle Creates a rectangle from an aligned point.
LocateSingleObject_Edges Detection of an object whose outlines are sharp and rigid. Often one of the first filters in a program.
ScanMultipleStripes Very fast detection of multiple pairs of opposite edges - usually for counting or width measurements.
CreateCoordinateSystemFromPoint Most often used to define an object alignment from results of 1D Edge Detection or Blob Analysis.
CheckPresence_Intensity Quick and easy presence verification, e.g. for missing caps, screws, labels.
ScanSingleEdge Very fast detection of an object (e.g. horizontal displacement of a bottle) and simple measurements (e.g. liquid level in a bottle).
AlignRectangle Required when there is a rectangle defined in a local coordinate system, but the next image-related filter in the program does not have any inAlignment input.
SegmentCenter Computes the center point of a segment.
Loop Put this filter into a task that should have a loop, but does not have any other loop generators (e.g. GrabImage).

Further Readings