You are here: Start » Program Examples » Parallel Image Saving
Parallel Image Saving
Aim
The task is to save the last image with drawn results.
Input
An image containing a gasket.
Output
Saved image with drawn results.
Hints
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 (FIS)
- Use the code from the Gasket Inspection example to prepare the inspection.
-
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.
-
From the Project explorer window create a new SavingQueue with InspectionPacket data type.
-
From the Project explorer window create a new Worker Task called SaveLastImage.
-
Add Queue_Push filter to the main program's PROCESSING section and assign it the SavingQueue queue.
-
Right click on the inValue of Queue_Push filter and select "Expand Structure Fields".
-
Connect created inputs using the following scheme:
- Connect outImage output of the EnumerateImages filter with the inValue.Image input of Queue_Push filter,
- Connect outMatch output of the LocateSingleObject_Edges1 filter with the inValue.Rectangle input of Queue_Push filter,
- Connect outCircle output of the first FitCircleToEdges filter with the inValue.Circle1 input of Queue_Push filter,
- Connect outCircle output of the the second FitCircleToEdges filter with the inValue.Circle2 input of Queue_Push filter,
- Connect outConnectingSegment output of the first PointToPointDistance filter with the inValue.Segment1 input of Queue_Push filter,
- Connect outArc output of the first FitArcToEdges filter with the inValue.Arc1 input of Queue_Push filter,
- Connect outArc output of the second FitArcToEdges filter with the inValue.Arc2 input of Queue_Push filter,
- Connect outConnectingSegment output of the the second PointToPointDistance filter with the inValue.Segment2 input of Queue_Push filter.
-
Go to the SaveLastImage Worker Task macrofilter.
-
In the PROCESS section add following filters in specified order: DrawRectangles_SingleColor, DrawCircles_SingleColor, DrawCircles_SingleColor, DrawSegments_SingleColor, DrawArcs_SingleColor, DrawArcs_SingleColor, DrawSegments_SingleColor and SaveImage.
-
Right click on outValues of the Queue_Pop filter, select PropertyOutput and check all visible outputs.
-
Connect created outputs by following the scheme in the image below.
-
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 |
---|---|---|
![]() |
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. |
![]() |
FitArcToEdges | Precise detection of an arciform edge, whose rough location is known beforehand. |
![]() |
LocateSingleObject_Edges1 | Detection of an object whose outlines are sharp and rigid. Often one of the first filters in a program. |
![]() |
SaveImage | Saves an image to a file. |
![]() |
Loop | Put this filter into a task that should have a loop, but does not have any other loop generators (e.g. GrabImage). |
![]() |
EnumerateImages | Emulates image acquisition with images stored on disk. |
![]() |
DrawArcs_SingleColor | Draws arcs on an image with a single color. |
![]() |
DrawCircles_SingleColor | Draws circles on an image with a single color. |
![]() |
PointToPointDistance | Measures the distance between two points. |
Further Readings
- Shape Fitting - This article presents usage of the Shape Fitting technique.
- Template Matching - Most detailed description of the Template Matching technique.