Skip to content

Creating an application with HALCON Script EngineπŸ”—

Preview restriction

HALCON Script Engine only supports C++ at the moment. Hence, only this language is described in the following.

At a glanceπŸ”—

The following settings are required for a project to use HALCON Script Engine:

  • Include path: %HALCONROOT%\include
  • Library path: %HALCONROOT%\lib\%HALCONARCH%
    (runtime libraries: hscriptenginecpp.dll and halconcpp.dll)
  • Include file: hscriptenginecpp\HScriptEngine.h
  • Link libraries: hscriptenginecpp.lib and halconcpp.lib (as the API is based on HALCON/C++)
  • Include path: $HALCONROOT/include
  • Library path: $HALCONROOT/lib/$HALCONARCH
  • Include file: hscriptenginecpp/HScriptEngine.h
  • Link libraries: libhscriptenginecpp.so and libhalconcpp.so (as the API is based on HALCON/C++)

For the available classes and methods, see About the main classes and methods of HALCON Script Engine.

How to develop applications with HALCON Script EngineπŸ”—

With HALCON Script Engine, you can execute complete HALCON Script programs or individual procedures. Which way is better depends on the stage of development and on your task:

  • When developing the image processing part of your application, you create a HALCON Script program. Thus, as a first test of your application, it is useful to execute the program via HALCON Script Engine. This test will already assure that the general configuration of your application (environment variables, procedure path, etc.) is correct. The HALCON Script Engine program itself should of course use the same procedures that you plan to execute from the programmed application.
  • After you finished its development, you integrate the image processing part into your programmed application by executing the corresponding procedures. Typically, you display image processing results by using the methods of the underlying HALCON programming language interface (i.e., HALCON/C++ for HScriptEngine/C++), but you can also encapsulate recurring display tasks in HSCRIPT procedures.

Further, keep the following in mind:

  • You can execute only procedures with public scope using the HALCON Script Engine. However, you can execute procedures with private scope either as part of a public procedure or an entire HALCON Script β€œmain” program.
  • All occurrences of the stop operator are ignored when executing a program using the HALCON Script Engine.

How to create an executable program with HScriptEngine/C++πŸ”—

The general workflow to create an application with HScriptEngine/C++ is as follows:

  1. In your application, include the main header file HScriptEngine.h and use the corresponding namespaces:

    #include "hscriptenginecpp/HScriptEngine.h"
    
    using namespace HalconCpp;
    using namespace HScriptEngineCpp;
    
  2. Compile the application using the following include paths:

    /I "$(HALCONROOT)\include" /I "$(HALCONROOT)\include\halconcpp"
    /I "$(HALCONROOT)\include\hscriptenginecpp"
    
    -I$HALCONROOT/include -I$HALCONROOT/include/halconcpp
    -I$HALCONROOT/include/hscriptenginecpp
    
  3. Link the following libraries:

    /libpath:"$(HALCONROOT)\lib\$(HALCONARCH)" hscriptenginecpp.lib halconcpp.lib
    
    -L$HALCONROOT/lib/$HALCONARCH -lhscriptenginecpp -lhalconcpp
    

For more information, see the example project.