You are here: Start » Program Examples » Parallel Image Saving

Parallel Image Saving


The task is to save the last image with drawn results.


An image containing a gasket.


Saved image with drawn results.


Read more about the original Gasket Inspection example here. In order to reduce the execution time, draw and save results using a Worker Task Macrofilter.

Labeling connections is explained in this article.

Solution (AVS)

  1. Use the code from the Gasket Inspection example to prepare the inspection.
  2. From the Project Explorer window create a new UserType named InspectionPacket. All the inputs, which need to be created, as well as their corresponding data types are shown in the image below.

  3. From the Project explorer window create a new SavingQueue with the InspectionPacket data type.

  4. From the Project explorer window create a new Worker Task called SaveLastImage.

  5. Add the Queue_Push filter to the main program's PROCESSING section and assign it the SavingQueue queue.

  6. Right click on the inValue of the Queue_Push filter and select "Expand Structure Fields".

  7. Connect created inputs using the following scheme:

  8. Go to the SaveLastImage Worker Task macrofilter.

  9. In the ACQUIRE section add the Queue_Pop and the Loop filters.

  10. In the PROCESS section add following filters in specified order: the DrawRectangles_SingleColor, the DrawCircles_SingleColor, the DrawCircles_SingleColor, the DrawSegments_SingleColor, the DrawArcs_SingleColor, the DrawArcs_SingleColor, the DrawSegments_SingleColor and the SaveImage.

  11. Right click on the outValues of the Queue_Pop filter, select the PropertyOutput and check all visible outputs.

  12. Connect created outputs by following the scheme in the image below.

  13. Set the inFile input of the SaveImage filter to LastResult.bmp.

  14. 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

Used Filters

Icon Name Description
EnumerateImages Emulates image acquisition with images stored on disk.
FitArcToEdges Precise detection of an arciform edge, whose rough location is known beforehand.
SaveImage Saves an image to a file.
PointToPointDistance Measures the distance between two points.
DrawSegments_SingleColor Draws segments on an image with a single color.
DrawRectangles_SingleColor Draws rectangles on an image with a single color.
FitCircleToEdges Precise detection of a circular object or hole, whose rough location is known beforehand.
Loop Put this filter into a task that should have a loop, but does not have any other loop generators (e.g. GrabImage).
DrawCircles_SingleColor Draws circles on an image with a single color.
DrawArcs_SingleColor Draws arcs on an image with a single color.
LocateSingleObject_Edges1 Detection of an object whose outlines are sharp and rigid. Often one of the first filters in a program.

Further Readings

  • Shape Fitting - This article presents usage of the Shape Fitting technique.
  • Template Matching - Most detailed description of the Template Matching technique.