The HDevEngine/Python interface is similar to the HDevEngine/.NET and HDevEngine/C++ interface. Most concepts and functions have a one-to-one mapping.
A short reference of the C++ classes for the HDevEngine can be found in section “Overview of the Classes”. The Python classes are similar.
This chapter only describes HDevEngine/Python specifics. If a topic e.g., error handling is not mentioned, the relevant part in Part “Programming With HALCON/Python” applies.
This section explains how to create a simple HDevEngine/Python applicaton. For a more comprehensive description, read section “HDevEngine/Python Interface”.
mkdir hdevengine_example cd hdevengine_example pip install mvtec-halcon==21050
import os import halcon as ha if __name__ == '__main__': example_dir = ha.get_system_s('example_dir') procedure_path = os.path.join(example_dir, 'hdevengine', 'procedures') hdev_engine = ha.HDevEngine() hdev_engine.set_procedure_path(procedure_path) img = ha.read_image('fin2') procedure = ha.HDevProcedure.load_external('detect_fin') proc_call = ha.HDevProcedureCall(procedure) proc_call.set_input_iconic_param_by_name('Image', img) proc_call.execute() fin_area = proc_call.get_output_control_param_by_name('FinArea')[0] print(f'Fin Area: {fin_area}')
python hdevengine_example.py
As as result, you should see the following output 'Fin Area: 1634'.