12.3   Using HDevelop Programs

You can use HDevelop programs or procedures in two ways in your .NET application:

The latter method is described in this section.

12.3.1   Using the Template Application

In most cases, you will manually integrate the exported code into your application. To quickly test the exported code, you can integrate it into the so-called template project (available for C# and Visual Basic .NET) in the subdirectory HDevelopTemplate (or HDevelopTemplateWPF, depending on your preferred GUI platform) as follows:

  1. Move or copy the exported source code file into subdirectory source of the template application.
  2. Open the solution file, right-click the current project in the Solution Explorer, and select the menu item Add Existing Item. Navigate to the source code file and select Add As Link, which is accessed via the arrow on the right side of the Add button (see figure 12.2).

    Figure 12.2: Linking existing items to an application.

  3. When you run the application, the form depicted in figure 12.3 appears. Click Run to start the exported HDevelop program.

    Figure 12.3: The template form for exported code.

  4. If you did not add the exported code correctly, the error message depicted in figure 12.4 appears. In Visual Basic .NET, different error messages appear.

    Figure 12.4: Error message upon running a template without exported code.

12.3.2   Combining the Exported Code with the HALCON/.NET Classes

The exported code does not use the classes like HImage described in the previous chapter. Instead, all operators are called via the special class HOperatorSet. Iconic parameters are passed via the class HObject (which is the base class of HImage, HRegion, and HXLD), control parameters via the class HTuple.

You can combine the exported code easily with “normal” HALCON/.NET code because iconic classes provide constructors that initialize them with instances of HObject. Furthermore, iconic classes can be passed to methods that expect an HObject.