Evaluate Results by HDevEngine

You are viewing an old version of the documentation. You can switch to the documentation of the latest version by clicking the top-right corner of the page.

Function

This Step runs a predefined Halcon vision program through HDevEngine and outputs the calculation result to Mech-Vision.

Usage Scenario

This Step is used for calling some of the procedures in Halcon.

Input and Output

  • Inputs: determined by the data type entered in the Input Ports Desc parameter.

  • Outputs: determined by the data type entered in the Output Ports Desc parameter.

Parameter Description

Program Settings

The parameters in “Program Settings” are shown in the figure below.

evaluate results by hdevengine parameter 1
hDev Program Path

Description: This parameter is used to specify the path of the HDev program, i.e., the path of the main program in Halcon HDevelop.

Eternal Procedure Folder

Description: This parameter is used to specify the path where the Halcon external procedures are stored (Multiple paths can be added by separating them with semicolons, “;”).

Procedure Name

Description: This parameter is used to set the name of the external procedure. You can select the name in the drop-down list.

Debugging Settings

The parameters in “Debugging Settings” are shown in the figure below.

evaluate results by hdevengine parameter 2
Online Debugging

Description: Select to activate the debug server. Then you can check the data input by Mech-Vision in real-time in Halcon HDevelop and debug the program.

Default setting: Unselected.

Tuning instruction: Once Online Debugging is selected, go to the menu bar of HALCON HDevelop and click Execute  Attach To Process..., and click OK in the pop-up window to activate the debug server. If the debug server is not activated in Halcon, Mech-Vision may be lagging during the execution.

Tuning recommendation: Please select the option according to the actual requirement.

Input Settings

The parameters in “Input Settings” are shown in the figure below.

evaluate results by hdevengine parameter 3

The Input Settings can only be configured after the Procedure Name is entered, or else the relevant parameters will not appear.

Input Ports Desc

Description: This parameter is used to specify the data type(s) of the input port(s).

Input Ctrl Var Names

Description: This parameter is used to set the list of names of the input control data.

Input Iconic Var Names

Description: This parameter is used to set the list of names of the input iconic data.

Output Settings

The parameters in “Output Settings” are shown in the figure below.

evaluate results by hdevengine parameter 4
Output Ports Desc

Description: This parameter is used to specify the data type(s) of the output port(s).

Output Ctrl Var Names

Description: This parameter is used to set the list of names of the output control data.

Output Iconic Var Names

Description: This parameter is used to set the list of names of the output iconic data.

Instructions

Prerequisites

To use the “Evaluate Results by HDevEngine” Step, the following two prerequisites should be met, or else the Step cannot be found in the Step library.

  1. The Halcon HDevelop software with a license has been installed on your computer.

  2. Copy the related DLL files, as shown in the figure below, in the Installation folder\bin\x64-win64 of Halcon HDevelop to the installation folder of Mech-Vision. If Mech-Vision is already opened, Mech-Vision should be restarted to make the changes take effect.

    evaluate results by hdevengine dll file

Supported Methods to Call Halcon Programs

  • Call an HDev main program in Mech-Vision, and there are no external procedures in the main program.

  • Call an HDev main program in Mech-Vision, and there are multiple external procedures in the main program.

  • Call only one external procedure in Mech-Vision.

Data Types Supported for Conversion

In the Mech-Vision project, when other Steps input data to this Step, the data types supported by Mech-Vision will be converted to data types supported by Halcon. When this Step outputs data to other Steps, the data types supported by Halcon will be converted to data types supported by Mech-Vision.

The detailed information on the supported data types for conversion is as follows.

  • Iconic Data Types

Halcon data type Mech-Vision Data type Note

Image

Image

The data types supported by Mech-Vision and Halcon can be converted to each other.

  • Control Data Types

Halcon data type Mech-Vision Data type Note

Tuple

NumberList, String, StringList, Variant, VariantList

When other Steps input data to this Step, the input Mech-Vision data type can be converted to tuples, which can be a collection of heterogeneous data. When this Step outputs data to other Steps, only tuples with a single type of data can be converted to the data type supported by Mech-Vision.

integer

NumberList

Only when the Step outputs data to other Steps, the data types supported by Halcon can be converted to the data types supported by Mech-Vision.

real

NumberList

Only when the Step outputs data to other Steps, the data types supported by Halcon can be converted to the data types supported by Mech-Vision.

string

String

Only when the Step outputs data to other Steps, the data types supported by Halcon can be converted to the data types supported by Mech-Vision.

Notes

Please pay attention to the following issues when using the “Evaluate Results by HDevEngine” Step to run the Halcon program.

  • Parameters of Input Settings do not need to be configured when only the main program is executed.

  • Running the main program and external procedures at the same time is not supported.

  • If you want to debug or modify the codes in the Halcon program, please select “Reload File” in Execution Flags, and then the latest Halcon program can be reloaded every time the project is run. If the “Reload File” option is not selected, the unmodified program will be loaded when the project is run again.

Usage Examples

Example 1: Call an HDev main program without any external procedures

The Halcon program used in this example is shown below.

read_image (Image, 'fabrik')

regiongrowing (Image, Regions, 1, 1, 3, 200)

area_center (Regions, Area, Row, Column)

After saving the above program in Halcon HDevelop, you can call the program in Mech-Vision. The operation workflow includes the following steps.

  1. Set the path of the main program. Set the hDev Program Path in the Step Parameters of the “Evaluate Results by HDevEngine” Step.

  2. Set the output ports. According to the data types used in Halcon, set the Output Ports Desc parameter.

  3. Set the names of the output data. According to the corresponding data names in Halcon, set Output Ctrl Var Names and Output Iconic Var Names.

After finishing the above operations, the Step parameters are shown below.

evaluate results by hdevengine example main paramter

The Mech-Vision project corresponding to this example is shown below. You can double-click the dataflow corresponding to the output ports to check the output results.

evaluate results by hdevengine example main

Example 2: Call an HDev main program with multiple external procedures

The Halcon program used in this example is shown below.

* atoms.hdev: Locates irregularities in an atomic grid structure
*
dev_close_window ()
dev_update_window ('off')
* ****
* Acquire image
* ****
read_image (Image, 'atoms')
get_image_size (Image, Width, Height)
crop_rectangle1 (Image, Image, Height / 2, 0, Height - 1, Width - 1)
get_image_size (Image, Width, Height)
*dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowID)
*set_display_font (WindowID, 14, 'mono', 'true', 'false')
dev_set_draw ('margin')
dev_set_line_width (2)
dev_display (Image)
*disp_message (WindowID, 'Original image', 'window', 12, 12, 'black', 'true')
*disp_continue_message (WindowID, 'black', 'true')
stop ()
* ****
* Segment image
* ****
* -> Using watershed
gauss_filter (Image, ImageGauss, 5)
watersheds (ImageGauss, Basins, Watersheds)
dev_display (Image)
dev_set_colored (12)
dev_display (Watersheds)
*disp_message (WindowID, 'Watersheds', 'window', 12, 12, 'black', 'true')
*disp_continue_message (WindowID, 'black', 'true')
stop ()
* ****
* Process regions
* ****
* -> Skip regions at the border of the image
smallest_rectangle1 (Basins, Row1, Column1, Row2, Column2)
select_shape (Basins, SelectedRegions1, 'column1', 'and', 2, Width - 1)
select_shape (SelectedRegions1, SelectedRegions2, 'row1', 'and', 2, Height - 1)
select_shape (SelectedRegions2, SelectedRegions3, 'column2', 'and', 1, Width - 3)
select_shape (SelectedRegions3, Inner, 'row2', 'and', 1, Height - 3)
* -> Select irregularly shaped atoms
select_shape (Inner, Irregular, ['moments_i1','moments_i1'], 'or', [0,9.5e8], [1.5e8,1e10])
dev_display (Image)
dev_set_line_width (1)
dev_set_color ('white')
dev_display (Inner)
dev_set_line_width (3)
dev_set_color ('red')
dev_display (Irregular)
*disp_message (WindowID, 'Defects', 'window', 12, 12, 'black', 'true')

After saving the above program in Halcon HDevelop, you can call the program in Mech-Vision. The operation workflow includes the following steps.

  1. Set the path of the main program. Set the hDev Program Path in the Step Parameters of the “Evaluate Results by HDevEngine” Step.

  2. Set the path of the external procedures. Set the path for the external procedures in External Procedure Folder in the Step Parameters of the “Evaluate Results by HDevEngine” Step.

  3. Set the output ports. According to the data types used in Halcon, set the Output Ports Desc parameter.

  4. Set the names of the output data. According to the corresponding data names in Halcon, set Output Ctrl Var Names and Output Iconic Var Names.

After finishing the above operations, the Step parameters are shown below.

evaluate results by hdevengine example procedure paremter

The Mech-Vision project corresponding to this example is shown below. You can double-click the dataflow corresponding to the output ports to check the output results.

evaluate results by hdevengine example procedure

Example 3: Call only one external procedure

The Halcon program used in this example is shown below.

gauss_filter(Image, Image_Gauss, Kernel_Size)

regiongrowing (Image_Gauss, Regions, 1, 1, 3, 200)

area_center (Regions, Area, Row, Column)

return ()

After saving the above program in Halcon HDevelop, you can call the program in Mech-Vision. The operation workflow includes the following steps.

  1. Set the path of the external procedures. Set the path for the external procedures in External Procedure Folder in the Step Parameters of the “Evaluate Results by HDevEngine” Step.

  2. Set the name of the external procedure. Select the name of the external procedure in the drop-down list of the Procedure Name parameter.

  3. Set the input ports. According to the parameter list of the external procedure, set the Input Ports Desc parameter.

  4. Set the names of the input data. According to the corresponding data names in Halcon, set Input Ctrl Var Names and Input Iconic Var Names.

  5. Set the output ports. According to the data types used in Halcon, set the Output Ports Desc parameter.

  6. Set the names of the output data. According to the corresponding data names in Halcon, set Output Ctrl Var Names and Output Iconic Var Names.

After finishing the above operations, the Step parameters are shown below.

evaluate results by hdevengine example procedure name paramter

The Mech-Vision project corresponding to this example is shown below. You can double-click the dataflow corresponding to the output ports to check the output results.

evaluate results by hdevengine example procedure name

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.