You are here: Start » Tutorial Exercises » Image Modification Using the HMI (hmi_checkbox)

Image Modification Using the HMI (hmi_checkbox)

Aim

Create an application that will perform several image modifications using information from the HMI.

Input

The Lena image from TestImage filter.

Output

Application with HMI as shown in the image below.

Hints

In this exercise most useful HMI controls are presented:

  • ImpulseButton - button control is used to terminate application,
  • ComboBox - selecting image modification that should be applied to the input image,
  • CheckBox - two state control which allows to change the process' state,
  • VideoBox - control which presents an image in the HMI,
  • Knob - control which allows to change a real value.

In this exercise all communication with HMI should be performed in Main macrofilter.

To create an application that uses HMI controls, loop generator should be added to the project.

In this example variant macrofilters should be used to perform actions depending on the state of the HMI controls.

Labeling connections is explained in this article.

Solution (AVS)

Creating basic program

  1. Add TestImage filter to the project.

  2. Create a new Variant macrofilter Effect.

    1. Open Project Explorer and click button Create New Macrofilter....

    2. In the new window select "Variant Macrofilter" and select its name: "Effect".

    3. Define inEffectName fork of String type.

    4. Add inImage input and outImage output.

    5. Click "Add New Variant.." in Macrofilter Navigator.

    6. Create "Negate" variant.

    7. Add NegateImage filter to this variant and connect its inputs and outputs.

  3. Add new variants to the Effect macrofilter:

  4. In "default" variant of the Effect macrofilter connect input with output to pass the input image without any changes.

  5. Add the Effect macrofilter to the program and connect it with outRgbImage.

  6. Create "Blur" variant macrofilter with Bool type fork input. Add inBlurLevel and inImage inputs. Create a new outImage output. Change the "False" variant to "default" by clicking "Edit" in the variant dropdown menu (see the image in step 2.5). Setup the variants as follows:

    • In "default" variant the input image should be passed to output.

    • In "True" variant the input image should be blurred using SmoothImage_Gauss Show the filter's inStdDevX input and connect it to the macrofilter's inBlurLevel input.

  7. Add the Blur macrofilter to the program and connect it with the Effect macrofilter.

  8. Add CropImage filter to the program and connect it to the Blur macrofilter's output.

  9. Add Repeat filter to process the program in loop. Connect value from ImpulseButton to inUntil so that the program stops when the button is pressed.

Creating the HMI form

  1. Open HMI Designer using the main toolbar.

  2. From HMI Controls window add the following controls:

    • Two Label controls and set their Text properties to: "Input image" and "Output image" in Properties window,

    • Two VideoBox controls,

    • GroupBox named "Effects" with ComboBox,

    • GroupBox named "Blur" with Knob and CheckBox named "Enabled",

    • GroupBox named "ROI" with SelectingVideoBox.

    • ImpulseButton named "Stop".

    The image below shows positions and sizes of the added controls.

  3. Fill List property of ComboBox control with the names of Effect variants (without default). Values must be exactly the same as variant names. Connect outText output to the Effect macrofilter's inEffectName input. Select value 0 in Selection property. Add "None" option to disable the effects. When "None" is selected, "default" variant is executed.

  4. Connect inImage input of the first VideoBox to outRgbImage of TestImage filter. In Properties window of the VideoBox set SizeMode to StretchImage.

  5. Connect inImage input of the second VideoBox to outImage of CropImage filter. In Properties window of the VideoBox set SizeMode to StretchImage.

  6. Connect outChecked of Checkbox to fork port of Blur macrofilter. Connect outValue of Knob control to inBlurLevel of Blur macrofilter. Get inside the macrofilter and connect inBlurLevel with inStdDevX.

  7. Connect outImage of Blur macrofilter to inImage of SelectingVideoBox control. Connect outSelection to inSelection of CropImage filter. In Properties window of SelectingVideoBox control change the default value of Selection by clicking on "..." button and set default dimensions of a rectangle and change SizeMode property to StretchImage.

  8. Connect outValue of ImpulseButton control to inUntil of Repeat filter.

Macrofilter Main creates an application loop and gathers information from HMI.

Macrofilter Blur(True) blurs an image.

Macrofilter Blur(default) passes an input image to the output without modifications.

Further Readings