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 modification using information from the HMI.

Input

The Lena image from TestImage filter.

Output

Application with HMI as in the image below.

Hints

In this exercise most useful HMI controls are presented:

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

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

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

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

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 new window select "Variant Macrofilter" and select name "Effect".

    3. Define fork inEffectName of type String.

    4. Add an input inImage and an output outImage.

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

    6. Create the "Negate" variant.

    7. To this variant add NegateImage filter and connect inputs and outputs.

  3. To macrofilter Effect add new variants:

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

  5. Add Effect macro to program and connect outRgbImage to it.

  6. Create variant macrofilter "Blur" with fork input of type Bool. Add inputs inBlurLevel and "inImage". Create a new output outImage. Setup variants as follows:

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

    • In "True" variant input image should be blurred using SmoothImage_Gauss.

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

  8. Add CropImage to program and connect it to the output of macrofilter Blur.

  9. Add filter Not which will negate False value from ImpulseButton when button is not pressed.

  10. Add filter Loop to process program in loop. Connect to it outValue of filter Not.

Creating HMI form

  1. Open HMI Designer using main toolbar.

  2. From HMI Controls window add following controls:

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

    • Two VideoBox controls,

    • GroupBox named "Effects" with ComboBox,

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

    • GroupBox named "ROI" with SelectingVideoBox.

    • ImpulseButton named "Stop".

    The image below shows positions and sizes of added controls.

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

  4. Connect inImage input of first VideoBox to outRgbImage of TestImage filter.

  5. Connect inImage input of second VideoBox to outImage of CropImage filter.

  6. Connect outChecked of Checkbox to fork port of Blur macrofilter. Connect outValue of Knob control to inBlurLevel of Blur macrofilter.

  7. To inImage of SelectingVideoBox control connect outImage of macrofilter Blur. Connect outSelection to inSelection of filter CropImage.

  8. Connect outValue of control ImpulseButton to inValue of filter Not.

Macrofilter Main creates application loop and gathers information from HMI.

Macrofilter Blur(True) blurs image.

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