Calculating normal vectors using Halcon

The processing time of this calculation method depends on factors like camera resolution, computer performance, and the quantity of point clouds.

Calculation method sample

The sample is as follows.
Modify the 'MechEye' field in the 'open_framegrabber' operator to the actual camera being used.
Then, modify the 'mls' field in the 'surface_normals_object_model_3d' operator to the computational model in use.

open_framegrabber (‘GigEVision2’, 1, 1, 0, 0, 0, 0, ‘default’, -1, ‘default’, -1, ‘false’, ‘default’, ‘MechEye’, 0, -1, AcqHandle)
set_framegrabber_param (AcqHandle, ‘grab_timeout’, 8000)
set_framegrabber_param (AcqHandle, ‘[Stream]GevStreamMaxPacketGaps’, 500)
set_framegrabber_param (AcqHandle, ‘create_objectmodel3d’, ‘enable’)
set_framegrabber_param (AcqHandle, ‘add_objectmodel3d_overlay_attrib’, ‘enable’)
set_framegrabber_param (AcqHandle, ‘DeviceScanType’, ‘Areascan3D’)
grab_data(Image3d, Region, Contur, AcqHandle, ObjectModel3D)
surface_normals_object_model_3d (ObjectModel3D, ‘mls’, [], [], ObjectModel3D)
close_framegrabber (AcqHandle)

Optimizing calculation time

  1. Use the ‘xyz_mapping’ model for calculating normal vectors
    Taking the PRO M with a resolution of 1920x1200 as an example, on the same computer and under the same scenario, using the ‘xyz_mapping’ model takes about 0.5 seconds, while using the ‘mls’ model takes about 1.7 seconds.

  2. Set point cloud ROI
    Similarly, using the PRO M model with a resolution of 1920*1200, the following program was tested. After setting the point cloud ROI to half its original size, the time spent on calculating normal vectors reduced by approximately 50% compared to the previous settings.

set_framegrabber_param (AcqHandle, ‘Scan3DROITop’,0)
set_framegrabber_param (AcqHandle, ‘Scan3DROILeft’,0)
set_framegrabber_param (AcqHandle, ‘Scan3DROIWidth’,960)
set_framegrabber_param (AcqHandle, ‘Scan3DROIHeight’,1200)
  1. Reduce point cloud quantity through binning
    This method reduces the quantity of point clouds so it is not recommended when accurate point cloud data is needed.