Однако инструкции по коду, которые я там нашел, похоже, не работают.
Ниже: небольшой автономный фрагмент кода:
Код: Выделить всё
from pypylon import pylon
_tlf: pylon.TlFactory = pylon.TlFactory.GetInstance()
devices: list[pylon.DeviceInfo] = list(filter(lambda d: d.GetModelName() == "a2A4200-12gcBAS", _tlf.EnumerateDevices()))
print([d.GetFriendlyName() for d in devices])
cam_array: pylon.InstantCameraArray = pylon.InstantCameraArray(len(devices))
for device, cam in zip(devices, cam_array, strict=True):
cam.Attach(_tlf.CreateDevice(device))
cam.Open()
for cam in cam_array:
assert cam.IsOpen()
cam.PtpEnable.Value = True
Код: Выделить всё
['Basler a2A4200-12gcBAS (40400219)', 'Basler a2A4200-12gcBAS (40400220)', 'Basler a2A4200-12gcBAS (40400221)', 'Basler a2A4200-12gcBAS (40400222)']
Код: Выделить всё
Traceback (most recent call last):
File "/home/samdm/Safe/0041-VFE/rt-vfe/packages/vfe_rt_plugin_basler/scripts/ptp_stackoverflow.py", line 14, in
cam.PtpEnable.Value = True
^^^^^^^^^^^^^^^^^^^
File "/home/samdm/Safe/0041-VFE/rt-vfe/packages/vfe_rt_plugin_basler/.venv/lib/python3.12/site-packages/pypylon/genicam.py", line 2073, in SetValue
return _genicam.IBoolean_SetValue(self, Value, Verify)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_genicam.AccessException: Node is not writable. : AccessException thrown in node 'PtpEnable' while calling 'PtpEnable.SetValue()' (file 'BooleanT.h', line 61)
Я пропустил шаг?
Подробнее здесь: https://stackoverflow.com/questions/793 ... er-cameras