Apply perameters in HALCON from JSON file for Ensenso B57

General Information

  • Product: B57-4-Color
  • Serial Number: 245368
  • Ensenso SDK Version: 4.1.1033
  • Operating System: Windows 10
  • HALCON Version: Halcon 24.11 Steady-Progress
  • Data Attachments

Problem / Question

Hey,

I am connecting an Ensenso B57 camera through the HALCON NxLib interface as explained in the HALCON examples provided through the SDK installation. I do not have a problem with finding and connecting the camera in HALCON or acquiring images through HALCON.

After the connection is established, I want to apply the settings contained in a JSON file that I saved through the NxViewer. To load those settings, I am using the HALCON functionality to directly apply settings from a JSON file to the camera (compare example in HDevelop script). After the settings are applied, I extract the settings from the camera and save them to another JSON file. After comparing the two JSON files, I realized that the settings of the first JSON file are never applied to the camera.

Now my question is: Did I miss a step to correctly apply the settings from the JSON file?

In advance, thank you for your help.

Kind regards,

Braitmaier

Hi Braitmaier,

your settings file contains a complete camera node, but you only need the parameters subnode. To do this, first load the entire settings file into a temporary or ‘dummy’ node. Then, extract just the ‘Parameters’ subnode from it. Alternatively, modify the settings file so that it only contains the parameter object.

Kind regards,
Peter

Hey Mr Birrer,

thank you for your quick response!

I adjusted the settings file according to your comment. The new JSON file is this one:settings_to_apply.json (5.1 KB)

After loading the parameters are correctly set, except for the enabling of the Texture image. As you can see in this JSON file settings_from_cam.json (5.1 KB) extracted from the camera, the Texture image is still distabled.

Can I enable the Texture image through the JSON file or should I enable it with an extra call to the corresponding HALCON procedure?

Again thank you for your help!

Kind regards

Hey Mr Braitmaier,

The NxLib API does not perform any type casting by itself. As a result, if you supply input values with unexpected types, NxLib will simply ignore them. In your case, the issue stems from specifying boolean values as integers in the JSON settings file. Because HALCON itself lacks native boolean support, our HALCON interface converts them to and from integers when setting or retrieving them at the node level. This conversion does not occur when the full JSON string is applied.

To resolve this, please ensure that any boolean settings in your JSON file use the proper boolean syntax (i.e., true or false) so that NxLib recognizes and applies them correctly.

Kind regards,
Peter

Hey Mr Birrer,

thank you for your respones. I did not pay attention to the casting of the boolean values from true/false style to 1/0 style. Now everything seems to work as intended.

I have another question to ask: Did you previously experience a significant increase of the acquisition time through the Halcon interface comparing to the NxViewer snapshot acquisition time?

Kind regards,

Braitmaier