About the example program🔗
The following example shows how to use HDevEngine to load an HDevelop program and execute one of its procedures from an application.
The example below follows the standard HDevEngine pattern: create the engine, set the procedure path, load the HDevelop source, execute the program or procedure, and then retrieve the output values.
#include "HalconCpp.h"
#include "HDevEngineCpp.h"
using namespace HalconCpp;
using namespace HDevEngineCpp;
int main()
{
clHDevEngineName engine;
engine.SetProcedurePath("C:/path/to/my/procedures");
clHDevProgramName program(engine, "example.hdev");
clHDevProgramCallName program_call(program);
program_call.Execute();
clHDevProcedureName proc(engine, "detect_part");
clHDevProcedureCallName proc_call(proc);
// set input parameters
// proc_call.SetInputObject(...);
// proc_call.SetInputTuple(...);
proc_call.Execute();
// read output parameters
// HObject region = proc_call.GetOutputObject("region");
return 0;
}
using System;
using System.IO;
using HalconDotNet;
class Program
{
static void Main()
{
HDevEngine engine = new HDevEngine();
string exampleDir = HSystem.GetSystem("example_dir");
string procedurePath = Path.Combine(exampleDir, "hdevengine", "procedures");
engine.SetProcedurePath(procedurePath);
HDevProgram program = new HDevProgram("example.hdev");
HDevProgramCall programCall = new HDevProgramCall(program);
programCall.Execute();
HDevProcedure procedure = new HDevProcedure("detect_part");
HDevProcedureCall procCall = new HDevProcedureCall(procedure);
// set input parameters
// procCall.SetInputIconicParamObject("Image", image);
procCall.Execute();
// read output parameters
// HTuple result = procCall.GetOutputCtrlParamTuple("Result");
}
}
This pattern is the foundation of the HDevEngine execution model:
clHDevEngineNameorHDevEnginemanages the engine settingsHDevProgramorclHDevProgramNameloads the HDevelop sourceHDevProgramCallorclHDevProgramCallNameexecutes itHDevProcedureCallorclHDevProcedureCallNamehandles parameters and resultsclHDevEngineExceptionNamereports runtime problems
The classic HDevEngine example applications in HALCON are organized around the same idea: load the HDevelop source, execute it, and redirect display operations to your own application-specific implementation if needed.
For a full application example, see the HALCON examples directory and the code patterns described in Creating an application with HDevEngine.