Python 接口以其简单性和快速原型开发能力而著称。导入 HALCON/Python 模块后,HALCON 算子可作为独立函数直接调用。还要注意的是,HALCON/Python 中的算子参数分为函数参数(输入)和返回值(输出)。
以下代码读取图像并计算其中 连接区域 的数量。
img = ha.read_image('pcb') region = ha.threshold(img, 0, 122) num_regions = ha.count_obj(ha.connection(region)) print(f'Number of Regions: {num_regions}')
有关前提条件和详细说明,请参阅 程序员指南,第 4 部分,第一个示例。