2016-11-23 8 views
-3

私はこの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() 

エラーが最後の行です。

+0

ここで、 'capture_and_decode(..)'を呼び出しますか?コードのその部分を共有できますか? – gowrath

+3

あなたが提供していない関数を*呼び出すと* * 2必要な位置引数*。また、 'capture_and_decode'への呼び出しが行われていないため、スニペットでPythonが表示するエラーメッセージを投稿する必要があります。 –

答えて

1

あなたのコードは次のようになりますように見えます:

obj.capture_and_decode() 

最初の引数(self)はあなたのために供給していますが、彼らはオプションである場合は、他の2

を考慮する必要があり、変更されます

def capture_and_decode(self, bitrange=10, axes=[]) 
1

あなたcapture_and_decode()方法は二つの位置引数を取るように設計されています。例えば、デフォルトを含むようにあなたの関数の定義;すなわち、ビット範囲と軸。このメソッドを呼び出すときは、次のように引数を指定する必要があります。

cam = CameraClass() 
cam.capture_and_decode(500, 4) # or whatever the values should be. 
関連する問題