You are here: Start » Getting Started » Introduction to Data Flow Programming

Introduction to Data Flow Programming

Important: Adaptive Vision Studio does not require the user to have any experience in low-level programming. Nevertheless, it is a highly specialized tool for professional engineers and a fully-fledged visual programming language. You will need to understand its four core concepts: Data, Filters (Tools), Connections, Macrofilters and an additional handy feature - Sections.

Data

Adaptive Vision Studio is a data processing environment so data is one of its central concepts. The most important fact about data that has to be understood is the distinction between types (e.g. Point2D) and values (e.g. the coordinates (15.7, 4.1)). Types define the protocol and guide the program construction, whereas values appear during program execution and represent information that is processed. Examples of common types of data are: Integer, Rectangle2D, Image.

Adaptive Vision Studio also supports arrays, i.e. variable-sized collections of data items that can be processed together. For each data type there is a corresponding array type. For example, just as 4 is a value of the Integer type, the collection {1, 5, 4} is a value of the IntegerArray type. Nested arrays (arrays of arrays) are also possible.

Filters(Tools)

Filters are the basic data processing elements in data flow programming. In a typical machine vision application there is an image acquisition filter at the beginning followed by a sequence of filters that extract information about regions, contours, geometrical primitives and then produce a final result such as a pass/fail indication.

A filter usually has several inputs and one or more outputs. Each of the ports has a specific type (e.g. Image, Point2D etc.) and only connections between ports with compatible types can be created. Values of unconnected inputs can be set in the Properties window, which also provides graphical editors for convenient defining of geometrical data. When a filter is invoked (executed), its output data can be displayed and analyzed in the Data Preview panels.

Connections

Connections transmit data between filters, but they also play an important role in encapsulating much of the complexity typical for low-level programming constructs like loops and conditions. Different types of connections support: basic flow of data , automatic conversions , array (for-each) processing and conditional processing . You do not define the connection types explicitly – they are inferred automatically on the do what I mean basis. For example, if an array of regions is connected to an input accepting only a single region, then an array connection is created and the individual regions are processed in a loop.

Macrofilters

Macrofilters provide a means for building bigger real-life projects. They are reusable subprograms with their own inputs and outputs. Once a macrofilter is created, it appears in the Project Explorer window and since then can be used in exactly the same drag and drop way as any regular filter.

Most macrofilters (we call them Steps) are just substitutions of several filters that help to keep the program clean and organized. Some other, however, can create nested data processing loops (Tasks) or direct the program execution into one of several clearly defined conditional paths (Variant Steps). These constructs provide an elegant way to create data flow programs of any complexity.

Data and types are very similar to what you know from C++. We also have a generic collection type – array – which is very similar to std::vector. Filters and macrofilters are just equivalents of functions. But, instead of a single returned value they often have several output parameters. Connections correspond to local variables, which do not have to be named. On the other hand loops and conditions in Adaptive Vision Studio are a bit different to C++ – the former are done with array connections or with Task macrofilters, for the latter there are conditional connections and Variant Step macrofilters. See also: Quick Start Guide for the C/C++ Programmers.

Sections

In order to improve clarity of applications and make it easier for the user to manage the data flow, starting from Adaptive Vision Studio 5.0 we have introduced a new feature called "Sections". These special areas visible in the Program Editor are responsible for dividing the application code into four consecutive stages. Placing filters in the right section makes the application more readable and reduces necessity of using macrofilters in simple applications.

Currently, there are four sections available: INITIALIZE, ACQUIRE, PROCESS and FINALIZE.

INITIALIZE – this section should consist of filters that have to be executed only once, before the loop. Such filters are usually responsible for initiation of connection (e.g. GigEVision_StartAcquisition, TcpIp_Accept) or setting values of constant parameters for application execution.

ACQUIRE – this section is intended to include filters from loop generation category like EnumerateImages or GigEVision_GrabImage that generate stream of data that will be processed or analyzed in the next section.

PROCESS – this section is suitable for various types of filters, especially those responsible for analyzing, processing and calculation of data. In most applications the PROCESS section will be largest one because its main purpose is to perform all the key tasks of the application.

FINALIZE – filters placed in this section are executed only once after the loop. In most cases this section is used to close all the connections and save or show the inspection results (e.g. GigEVision_StopAcquisition, TcpIp_Close, SaveText).

By default, sections are not visible inside Step and Variant Step macrofilter(s). However, the view in these macrofilters can be extended with INITIALIZE and PROCESS sections. In Worker Task and Task macrofilter the default view consist of ACQUIRE and PROCESS sections and can be extended to all four sections.

To change the default view of the sections in the Program Editor right-click on empty space and chose the "Show Sections" option from the context menu. Moreover, you can manage your sections in the Project Explorer in the same way.

Previous: Application Settings Next: Running and Analysing Programs