IDS Peak comfortSDK, genericSDK, IPL, and AFL developer manuals are external documents. Please contact us if you need them.
The camera parameters are accessible in the NodeMap of the RemoteDevice.
// Get the RemoteDevice NodeMap
auto nodeMapRemoteDevice = device->RemoteDevice()->NodeMaps().at(0);
|
// Get the RemoteDevice NodeMap
var nodeMapRemoteDevice = device.RemoteDevice().NodeMaps()[0];
|
Exceptions
Generally, you should enclose all calls to the IDS peak API with a try/catch block (see Error handling with try/catch). In case of an error, IDS peak API throws various exceptions. If such an exception is not handled, it will cause the program to terminate. This is illustrated by the following complete example.
|
Note: If an exception occurs, the program execution is interrupted in the try block at the location of the error and the program immediately jumps to the catch block. In this case, all subsequent calls will not be executed. To avoid this, you must enclose all calls of IDS peak API with try/catch blocks individually.
|
genericC++
|
try
{
// Here are the function calls
}
// This exception type catches all kinds of peak exceptions
catch (const std::exception& e)
{
// e.what() contains the error message string as a null terminated const char*
}
|
The exceptions can be treated by their specific type to allow different error handling. The default exception handler should take effect last.
genericC++
|
try
{
...
}
catch (const peak::core::OutOfRangeException& e)
{
// The value is out of range, e.g. higher than Maximum or lower than Minimum
}
catch (const peak::core::BadAccessException& e)
{
// The NodeAccess was not suitable for the intended task, e.g. the node was ReadOnly
}
catch (const peak::core::NotAvailableException& e)
{
// The node is not available, camera configuration could block current availability
}
catch (const peak::core::NotFoundException& e)
{
// The node could not be found, check misspelling of the node name
}
catch (const peak::core::NotImplemented& e)
{
// The node is not implemented
}
catch (const std::exception& e)
{
// all other exceptions
}
|
Finding a parameter
The camera parameters can be found in the NodeMap using the FindNode() function. To set the value, execute the SetValue() function. A complete list of available camera parameters is provided in the Camera feature reference.
genericC++
|
nodeMapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ExposureTime")->SetValue(1000.0);
|
You can get the currently set value using the Value() function.
genericC++
|
double exposureTime = nodeMapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ExposureTime")->Value();
|
You can get the range (minimum, maximum and increment) as follows.
genericC++
|
double min = nodeMapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ExposureTime")->Minimum();
double max = nodeMapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ExposureTime")->Maximum();
double inc = nodeMapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ExposureTime")->Increment();
|
Some parameters do not have an increment. In this case, calling the Increment() function throws an exception. To avoid this, you can extend the increment query with the following check.
genericC++
|
if (nodeMapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ExposureTime")->HasConstantIncrement())
{
double inc = nodeMapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ExposureTime")->Increment();
}
|
Complete example: Getting the range for the exposure time and the current value and setting a new, valid value
Prerequisite: The IDS peak API and a camera was opened (Device). See also Opening a camera (API)
try
{
// Get the NodeMap of the RemoteDevice
auto nodeMapRemoteDevice = device->RemoteDevice()->NodeMaps().at(0);
double minExposureTime = 0;
double maxExposureTime = 0;
double incExposureTime = 0;
// Get exposure range. All values in microseconds
minExposureTime = nodeMapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ExposureTime")->Minimum();
maxExposureTime = nodeMapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ExposureTime")->Maximum();
if (nodeMapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ExposureTime")->HasConstantIncrement())
{
incExposureTime = nodeMapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ExposureTime")->Increment();
}
else
{
// If there is no increment, it might be useful to choose a suitable increment for a GUI control element (e.g. a slider)
incExposureTime = 1000;
}
// Get the current exposure time
double exposureTime = nodeMapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ExposureTime")->Value();
// Set exposure time to maximum
nodeMapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ExposureTime")->SetValue(maxExposureTime);
}
catch (const std::exception& e)
{
std::string strError = e.what();
// ...
}
|
try
{
// Get the NodeMap of the RemoteDevice
var nodeMapRemoteDevice = device.RemoteDevice().NodeMaps()[0];
double minExposureTime = 0;
double maxExposureTime = 0;
double incExposureTime = 0;
// Get exposure range. All values in microseconds
minExposureTime = nodeMapRemoteDevice.FindNode<peak.core.nodes.FloatNode>("ExposureTime").Minimum();
maxExposureTime = nodeMapRemoteDevice.FindNode<peak.core.nodes.FloatNode>("ExposureTime").Maximum();
if (nodeMapRemoteDevice.FindNode<peak.core.nodes.FloatNode>("ExposureTime").HasConstantIncrement())
{
incExposureTime = nodeMapRemoteDevice.FindNode<peak.core.nodes.FloatNode>("ExposureTime").Increment();
}
else
{
// If there is no increment, it might be useful to choose a suitable increment for a GUI control element (e.g. a slider)
incExposureTime = 1000;
}
// Get the current exposure time
double exposureTime = nodeMapRemoteDevice.FindNode<peak.core.nodes.FloatNode>("ExposureTime").Value();
// Set exposure time to maximum
nodeMapRemoteDevice.FindNode<peak.core.nodes.FloatNode>("ExposureTime").SetValue(maxExposureTime);
}
catch (Exception e)
{
var strError = e.Message;
// ...
}
|
try:
# Get the NodeMap of the RemoteDevice
node_map_remote_device = device.RemoteDevice().NodeMaps()[0]
min_exposure_time = 0;
max_exposure_time = 0;
inc_exposure_time = 0;
# Get exposure range. All values in microseconds
min_exposure_time = node_map_remote_device.FindNode("ExposureTime").Minimum()
max_exposure_time = node_map_remote_device.FindNode("ExposureTime").Maximum()
if node_map_remote_device.FindNode("ExposureTime").HasConstantIncrement():
inc_exposure_time = node_map_remote_device.FindNode("ExposureTime").Increment()
else:
# If there is no increment, it might be useful to choose a suitable increment for a GUI control element (e.g.a slider)
inc_exposure_time = 1000;
# Get the current exposure time
exposure_time = node_map_remote_device.FindNode("ExposureTime").Value()
# Set exposure time to maximum
node_map_remote_device.FindNode("ExposureTime").SetValue(max_exposure_time)
except Exception as e:
str_error = str(e)
# ...
|