Solution:
Here is a Guide for Set/Get Camera Parameters in eBUS SDK for JAI
The eBUS SDK for JAI supports USB3 Vision and GigE Vision cameras from JAI. Camera parameters may be different for each camera model. This document describes the methods to set/get parameters when using the eBUS Python for JAI.
1. Method to Set/Get Values to/from parameters
The functions in the eBUS SDK for JAI are common for both USB3 Vision and GigE Vision. The following functions can be used to set/get values to/from known parameters.
class eBUS.PvGenInteger(*args, **kwargs) |
SetValue(int) |
class eBUS.PvGenFloat(*args, **kwargs) |
SetValue(float) |
class eBUS.PvGenEnum(*args, **kwargs) |
SetValue(int) |
class eBUS.PvGenBoolean(*args, **kwargs) |
SetValue(boolean) |
class eBUS.PvGenString(*args, **kwargs) |
SetValue(str) |
class eBUS.PvGenCommand(*args, **kwargs) |
Execute() → PvResult, |
Detailed descriptions of each function can be found in the help file of the eBUS SDK for JAI.
To achieve setting/getting values, “aName” (type string) is needed to specify the parameter. Since the
actual name of “aName” would vary for each camera model, the SDK manual does not specify the names.
Instead, “aName” is defined in the XML file in each camera. The next section shows how you can determine the right value for “aName.”
1.1 Finding "aName"
The easiest way to determine the correct “aName” parameter is by using the eBUS Player. After
connecting a camera, open “Device Control”, "Communication control" or "Image stream control".
These 3 define the parameter we can get/set from, each have their own array of parameters we can select from.
In the Device Control window, click on a parameter and the detail information for that parameter will appear at the bottom of Device Control window.
The string provided for “Feature Name” is the “aName” parameter for this feature. Also note the
“Type” field. This provides the parameter type and therefore the type of function that must be used
to get/set parameters.
2. Application flow
To get access to the parameter of the camera we first have to connect to a device, in most sample code this will look like this:
connection_ID = psu.PvSelectDevice()
if connection_ID:
device = connect_to_device(connection_ID)
if device:
stream = open_stream(connection_ID)
Once we have a device we have access to device parameter, same goes for stream parameter and communication parameter, these correspond to menus in eBUS Player define in section "1.1 Finding 'aName'". To access them we call GetParameters() / GetCommunicationParameter
device_params = device.GetParameters()
com_params = device.GetCommunicationParameters()
stream_params = stream.GetParameters()
These all return a PvGenParameterArray object that we can use for multiple case
2.1 Get function
with the PvGenParameterArray we can use the Get() function:
gen_parameter = device_params.Get("DeviceVersion")
gen_parameter = com_params.Get("HeartbeatInterval")
gen_parameter = stream_params.Get("AcquisitionRate")
This will return a PvGenParameter which we can use to inspect whether its a Integer, String, Float etc. by getting the type and match it to a class:
#/ Get the parameter type
result, gen_type = gen_parameter.GetType();
if eb.PvGenTypeInteger == gen_type:
result, value = gen_parameter.GetValue()
print(f"Integer: {value}")
elif eb.PvGenTypeEnum == gen_type:
result, value = gen_parameter.GetValueString()
print(f"Enum: {value}")
elif eb.PvGenTypeBoolean == gen_type:
result, value = gen_parameter.GetValue()
if value:
print(f"Boolean: TRUE")
else:
print(f"Boolean: FALSE")
elif eb.PvGenTypeString == gen_type:
result, value = gen_parameter.GetValue()
print(f"String: {value}")
elif eb.PvGenTypeCommand == gen_type:
print(f"Command")
elif eb.PvGenTypeFloat == gen_type:
result, value = gen_parameter.GetValue()
print(f"Float: {value}")
As you see here most parameter can be call with Get() follow by GetValue() except Enum where you have to get it as a string or Int.
pv_result, value = device_params.Get("AcquisitionFrameRate").GetValue()
2.1 GetXXX variable functions
With the PvGenParameterArray we can use the the help method to return the PvGenParameter casted as a PvGenInteger, PvGenFloat, PvGenEnum, PvGenBoolean, PvGenString, PvGenRegister, PvGenCommand.
gen_parameter = device_params.GetInteger("Width")
gen_parameter = device_params.GetFloat("Width")
gen_parameter = device_params.GetEnum("TriggerSelector")
gen_parameter = device_params.GetBoolean("GevDeviceModeIsBigEndian")
gen_parameter = device_params.GetCommand("AcquisitionStartip")
gen_parameter = device_params.GetString("DeviceVersion")
Revision note:
Date | Comment |
24/10/2024 | Added article |
Comments
0 comments
Please sign in to leave a comment.