pypylon
pypylon copied to clipboard
Cannot create new camera instance from device info after changing user defined name in camera info
Hi I am enumerating transport layer devices and iterating over them, then I want to change the user defined name inside the device information and finally use the new device information to create a new camera object. I am getting the following error. Here is my snippet too. Any help would be appreciated!
os.environ["PYLON_CAMEMU"] = "5"
tlf = py.TlFactory.GetInstance()
for tl in tlf.EnumerateDevices():
tl.SetUserDefinedName("TestCam")
cam = py.InstantCamera(py.TlFactory.GetInstance().CreateDevice(tl))
Traceback (most recent call last):
File "/home/kareem/Basler_ws/src/pylon_ros/CameraEmulator.py", line 18, in
cam = py.InstantCamera(py.TlFactory.GetInstance().CreateDevice(tl))
File "/home/kareem/.local/lib/python3.8/site-packages/pypylon/pylon.py", line 1604, in CreateDevice
return _pylon.TlFactory_CreateDevice(self, *args)
_genicam.RuntimeException: Device creation failed. : RuntimeException thrown (file 'TransportLayerPrivateImpl.h', line 847)
if I remove the the line tl.SetUserDefinedName('TestCam') the code works so I am sure it is a matter of name change that is causing it.
the function SetUserDefinedName normally used to configure an empty DeviceInfo object, but in your case you are trying to set a valid info object.
If you wanted to change the user define name of the camera, then open the camera then set the user define name on camera object.