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:
-
Open the sample in HDevelop: Open HDevelop, and drag the sample into HDevelop.
-
Step over the program (click the button in the toolbar repeatedly), until the Variable Inspect: MechEyeCamers window pops up.
-
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:.
user_name is the custom camera name. You can customize the camera name in Mech-Eye Viewer. -
Locate the following line, and replace MechEye with the copied unique_name or user_name.
DeviceInfo := 'MechEye'
-
Run the sample by clicking in the toolbar or pressing the F5 key.
-
The obtained point cloud is displayed in the Graphics Window. Click the Continue button in this window to resume the execution of the program.
-
After the program has been fully executed, click 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. -
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.
|
Adjust Parameters
If the quality of the obtained data is unsatisfactory, you can adjust the corresponding parameters.
|
To adjust the parameters, follow these steps:
-
Use the following operator to obtain the list of available parameter groups on the camera.
get_framegrabber_param (AcqHandle, 'UserSetSelector_values', ParameterGroupNames)
-
View the list of parameter groups in the ParameterGroupNames variable in the Control Variables area.
-
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')
-
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)
-
View the parameter value in the ParameterValues variable in the Control Variables area.
-
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')
-
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.