5.4.2   HCopyObj

HCopyObj (see figure 5.18) creates a new iconic object (image, region, or XLD) that contains the same components as an already existing iconic object specified by its database key obj_key. The new iconic object is stored in the HALCON database of iconic objects and appended to the list of iconic objects in the output iconic parameter with the index par_num. The database key of the new image object is returned in obj_key.

Note that HCopyObj automatically checks the result state of the underlying procedure with the macro HCkP (see section “HCkP”). Thus, you must not use HCkP on HCopyObj yourself.

    Hkey       obj_key_in,obj_key_out,reg_key_out;
    Hrlregion  *region_in;
    Hrlregion  *region_out;
    INT4_8     num_objs;
    ...
    par_in  = 1;  /* index of input parameter  */
    par_out = 1;  /* index of output parameter */
    HReadGVA(proc_handle,HGnum_obj,&num_objs,par_in);
    for (o=1; o<=num_objs; o++) {
      HGetObj(proc_handle,par_in,o,&obj_key_in);
      HGetFDRL(proc_handle,obj_key_in,&region_in);
      /* compute some region transformation ... */
      transform(region_in,region_out);
      HCopyObj(proc_handle,obj_key_in,par_out,&obj_key_out);
      HPutDRL(proc_handle,obj_key_out,region_out,&reg_key_out);
    }

Figure 5.20: Create an image object with HCopyObj and insert a region component.

Similar to HCrObj, the components of a new image object can be reassigned using HDefObj etc. HCopyObj is especially useful, when output iconic objects hardly differ from the corresponding input objects.