我在代码下面收到以下错误:
TypeError:GetSize()缺少1个必需的位置参数:“ self”
import PySpin
system = PySpin.System.GetInstance()
cam_list = system.GetCameras()
# This works:
numCams = cam_list.GetSize()
# this fails:
numCams = PySpin.CameraList.GetSize()
print ("No. of cams: ", numCams)
为什么?
编辑:
class myMain(object):
def main(self):
numCams = PySpin.CameraList.GetSize()
print ("No. of cams: ", numCams)
答案 0 :(得分:1)
在调用它之前尝试对其进行初始化
cams = PySpin.CameraList()
numCams = cams.GetSize()
print ("No. of cams: ", numCams)