HObject is a class that represents iconic objects.
In HALCON, iconic objects model a hierarchy:
object | |--------|--------| | | | v v v image region xld | |----------|----------|----------|----------| | | | | | v v v v v xld_cont xld_poly xld_para xld_mod_para xld_ext_para
HALCON/Python does not model this object hierarchy with a class hierarchy, rather it only provides a single class HObject.
Iconic objects in HALCON can represent collections of objects, such as a sequence of images, or multiple regions etc. HALCON/Python mirrors this behavior:
img = ha.read_image('pcb') img_seq = ha.concat_obj(img, ha.read_image('fuse')) width, height = ha.get_image_size(img_seq) assert width == [1109, 768] assert height == [871, 576]
Here, img_seq represents two images, and follow-up operators like get_image_size work in a batch fashion accordingly.
HObject behaves similarly to lists in Python:
assert len(img_seq) == 2 for single_img in img_seq: assert ha.get_image_size_s(single_img) > (600, 400) assert ha.get_image_size_s(img_seq[1]) == (768, 576) assert ha.get_image_size_s(img_seq[-2]) == (1109, 871) assert ha.get_image_size(img_seq[:4]) == ([1109, 768], [871, 576]) assert ha.get_image_size(img_seq[1:4]) == ([768], [576])
This includes support for len, iteration, positive and negative indexing, and efficient slicing.