我有這個TypeError: capture_and_decode() missing 2 required positional arguments: 'bitrange' and 'axes'
Python TypeError:缺少2個必需的位置參數//我該如何解決它?
我的代碼是這一個:
def capture_and_decode(self, bitrange, axes):
cam_width, cam_height = self.camera.resolution
scr_range = self.display.displaywindow.resolution
self.raw_images = numpy.empty((len(axes), cam_height, cam_width, bitrange))
for axis in axes:
for bits in range(0,bitrange):
stripe_width = cam_width // 2 ** (bits + 1)
print(stripe_width)
binary = numpy.fromiter(GrayCode(bits + 1).generate_gray(), dtype=numpy.int) % 2
vector = numpy.repeat(binary, stripe_width)
img = numpy.tile(vector, (cam_height, 1))
self.display.displaywindow.show(img)
time.sleep(0.25)
self.raw_images[axis, :, :, bits] = self.camera.capture()
錯誤是在最後一行。
你在哪裏調用'capture_and_decode(..)'?你能分享你的部分代碼嗎? – gowrath
當你*調用*你沒有提供的函數:* 2需要位置參數*。您還需要發佈Python向您顯示的錯誤消息,因爲您在提供的代碼片斷中沒有對「capture_and_decode」進行調用。 –