Connect to Camera, Adjust Parameters, and Acquire Data

This topic introduces how to connect to the camera, adjust parameters, and acquire data with the connect_to_camera_and_capture_images sample on Windows.

Please refer to Usage Guide for HALCON Samples to obtain the samples and check the prerequisites for using the samples.

Run the Sample

Follow these steps to run the sample:

  1. Open the sample in HDevelop: Open HDevelop, and drag the sample into HDevelop.

  2. Step over the program (click the step over button in the toolbar repeatedly), until the Variable Inspect: MechEyeCamers window pops up.

  3. This window displays all the available cameras. Double-click the camera that you want to connect, and copy the name after unique_name: or user_name:.

    camera name
    user_name is the custom camera name. You can customize the camera name in Mech-Eye Viewer.
  4. Locate the following line, and replace MechEye with the copied unique_name or user_name.

    DeviceInfo := 'MechEye'
  5. Run the sample by clicking run in the toolbar or pressing the F5 key.

  6. The obtained point cloud is displayed in the Graphics Window. Click the Continue button in this window to resume the execution of the program.

  7. After the program has been fully executed, click reset in the toolbar to reset program execution.

    If the program execution is not reset in HDevelop, the camera cannot be connected in Mech-Eye Viewer.
  8. Check the 2D image and point cloud files obtained during this execution in the folder where the sample is located. The default file names are image2d.bmp and PointCloud.ply.

  • If the data acquisition process takes too long, you can increase the MTU size of the camera, and enable jumbo frames on your computer.

  • If the network connection is poor, you can reduce data loss by increasing the maximum number of allowed packet gaps with the following operator. Replace ParameterValues with the number of allowed packet gaps.

    set_framegrabber_param (AcqHandle, '[Stream]GevStreamMaxPacketGaps', ParameterValues)

Adjust Parameters

If the quality of the obtained data is unsatisfactory, you can adjust the corresponding parameters.

  • The camera provides the parameter group feature. By selecting a different parameter group, you can quickly change the parameter configuration for the camera. Camera parameters must be adjusted and saved in a parameter group.

  • If you need to add or delete a parameter group, you can do so in Mech-Eye Viewer.

To adjust the parameters, follow these steps:

  1. Use the following operator to obtain the list of available parameter groups on the camera.

    get_framegrabber_param (AcqHandle, 'UserSetSelector_values', ParameterGroupNames)
  2. View the list of parameter groups in the ParameterGroupNames variable in the Control Variables area.

  3. Use the following operator to select the parameter group to modify. UserSetSelector and UserSetLoad are the camera parameters used to select and load a parameter group, respectively. Replace ParameterGroupName with the actual parameter group name.

    The parameter group name displayed in HDevelop corresponds to the order of parameter groups in Mech-Eye Viewer. For example, UserSet0 in HDevelop is the first parameter group in Mech-Eye Viewer. For details, refer to Select Parameter Group in HALCON.
    set_framegrabber_param (AcqHandle, 'UserSetSelector','ParameterGroupName')
    set_framegrabber_param (AcqHandle, 'UserSetLoad','ParameterGroupName')
  4. Use the following operator to obtain the value of a specific parameter. Replace ParameterName with the actual camera parameter name. The parameter value is saved in the ParameterValues variable. You can change the variable name according to actual needs. Note that this variable does not need to be included in parentheses.

    get_framegrabber_param (AcqHandle, 'ParameterName', ParameterValues)
  5. View the parameter value in the ParameterValues variable in the Control Variables area.

  6. Use the following operator to adjust the value of the specified parameter. Replace ParameterName with the actual camera parameter name and NewParameterValue with the new parameter value.

    set_framegrabber_param (AcqHandle, 'ParameterName', 'NewParameterValue')
  7. Use the following operator to save the parameter value modification into the parameter group. UserSetSave is the camera parameter used to save the parameter group. Replace ParameterGroupName with the actual parameter group name.

    set_framegrabber_param (AcqHandle, 'UserSetSave', 'ParameterGroupName')

References

  • The parameters available in GenICam clients generally correspond with those available in Mech-Eye Viewer. For the detailed correspondence, refer to Camera Parameters Available in GenICam Client.

  • Adjusting camera parameters such as Auto-Exposure ROI, Depth Range and ROI usually requires the assistance of visualized tools for several rounds of fine tuning. Since GenICam clients do not provide visualized tools, you can set these parameters using the visualized tools provided by Mech-Eye Viewer. For details, refer to Adjust Camera Parameters Using Mech-Eye Viewer.

    You must disconnect from the camera in HDevelop before you can connect to it in Mech-Eye Viewer and adjust parameters. If you fail to connect the camera in Mech-Eye Viewer, close HDevelop and try again.