我正在寻找一种方法来测试相机是否为 PTG 相机打开。
在 PyCapture2 中,以下代码有效,但假定的 PySpincam.DeviceConnectionStatus()
将不起作用,因为该函数似乎不存在。
PySpin 相机库版本:1.23.0.27
错误:
错误:Spinnaker:GenICam::AccessException= 功能不存在(引用无效):AccessException 抛出(文件 'IEnumerationT.h',第 341 行)[-2006](假,SpinnakerException(“Spinnaker:GenICam::AccessException= 功能不存在存在(引用无效):抛出 AccessException(文件 'IEnumerationT.h',第 341 行)[-2006]”))
我也尝试过PySpin.Camera.DeviceConnectionStatus()
,但无论是之前还是之后都会出现以下错误cam.Init()
:
Traceback (most recent call last): File "X.py", line 82, in YZ print (PySpin.Camera.DeviceConnectionStatus()) TypeError: 'property' object is not callable
工作 PyCapture2 代码:
def cameraOn(self, cam):
# Power on the Camera
cameraPower = 0x610
powerVal = 0x80000000
cam.writeRegister(cameraPower, powerVal)
# Waiting for camera to power up
retries = 10
timeToSleep = 0.1 #seconds
for i in range(retries):
sleep(timeToSleep)
try:
regVal = cam.readRegister(cameraPower)
except PyCapture2.Fc2error: # Camera might not respond to register reads during powerup.
pass
awake = True
if regVal == powerVal:
break
awake = False
if not awake:
print ("Could not wake Camera. Exiting...")
exit()