Reading/Writing Camera Parameter Files

<< Click to Display Table of Contents >>

Navigation:  NxLib API > HowTo's > Basic Camera Operations >

Reading/Writing Camera Parameter Files

This example shows how to open a camera, apply a saved parameter set from a json parameter file saved from NxView and modify single parameters thereafter.

Format of JSON parameter files

A parameter file is a text file and contains the complete camera tree structure with all node names and values in JSON format. When saving parameter files from NxView you can choose to save the tree below two different nodes:

the subtree Parameters of the Camera node (see picture, red frame), or

the entire Camera node (see picture, blue frame), which includes the Parameters subtree, but additionally all other information like the camera calibration, model name, serial number, etc.

Parameter-Subtrees

Depending on the content of the parameter file you have different options how to restore the parameters onto an open camera:

Full Camera node in json file

oOverwrite the entire Camera node of you opened camera with the JSON content of the parameter file:
This will restore all camera settings in the Parameters subnode, but will also apply the calibration data from the Calibration subnode of the parameter file onto the Calibration node of the opened camera. Make sure to not overwrite the calibration with a calibration of a different camera.

oExtract the Parameters subtree from the file and overwrite only the camera's Parameters subtree with this. The extraction is easily done by saving the entire JSON content of the file into a temporary NxLib tree item. The camera will then keep its calibration and adopt all other settings from the file.

Only Parameters subtree in json file

oHere you can directly overwrite the camera's Parameters node with the content of the file. The camera will keep its calibration and adopt all other settings from the file.

Code Examples

Open camera and read parameter file

hmtoggle_plus1C++
hmtoggle_plus1Halcon/HDevelop

 

Write parameter file

As explained above there are two options to write the settings file, one containing the entire camera node, and one containing only the parameters subtree. In the example the constant 'StoreEntireCameraNode' switches between these two options.

hmtoggle_plus1C++
hmtoggle_plus1Halcon/HDevelop