0

このコードに対して次のエラー メッセージが表示されます。

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

    cam_width, cam_height = self.camera.resolution
    #cam_width = 640
    #cam_height = 480
    print ('a')
    scr_range = self.display.displaywindow.resolution
    self.raw_images = numpy.empty((len(axes), cam_height, cam_width, bitrange))
    imgs = []
    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)
           imgs = numpy.tile(vector, (cam_height, 1))
           print ('b')
       self.display.displaywindow.show(imgs)  # TODO: handle sleep in display module
       time.sleep(0.25)
       self.raw_images[axis, :, :,  bitrange] = self.camera.capture()

    imgs_v = self.raw_images[0].reshape(cam_height, cam_width, -1)
    print('c')
    imgs_h = self.raw_images[1].reshape(cam_height, cam_width, -1)
    print('C')


    self.registration, self.modulation = decode(imgs_v, imgs_h, bitrange)
    print('d')
    self.sigCaptureDone.emit(self.registration)

    with h5py.File("test.h5", "w") as f:
        f.create_dataset("registration", data=self.registration)
        print('e')
        f.create_dataset("modulation", data=self.modulation)
        print('finish')

ファイル "............./GrayCodeWidget.py"、89 行目、capture_and_decode self.raw_images[軸、:、:、ビット範囲] = self.camera.capture() IndexError: インデックス 1サイズ 1 の軸 0 の範囲外です

4

1 に答える 1

0

Python には詳しくありませんが、通常、インデックスは 0 から開始する必要があります。

使用するのは合法でしょうか: def capture_and_decode(self, bitrange = 2, axes = [0]): ?

于 2016-11-25T10:54:35.540 に答える