python-3.7pyspin

TypeError: GetSize() missing 1 required positional argument: 'self'


I am getting the following error iwht below code:

TypeError: GetSize() missing 1 required positional argument: '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)

Why?

Edit:

class myMain(object):
    def main(self):
        numCams  = PySpin.CameraList.GetSize()
        print ("No. of cams: ", numCams)

Solution

  • Try initializing it before you call it

    cams = PySpin.CameraList()
    numCams = cams.GetSize()
    print ("No. of cams: ", numCams)