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[axis, :, :, bitrange] = self.camera.capture() IndexError: index 1对于大小为 1 的轴 0 超出范围

4

1 回答 1

0

我不熟悉 Python,但通常索引应该以 0 开头。

使用: 是否合法 def capture_and_decode(self, bitrange = 2, axes = [0]):

于 2016-11-25T10:54:35.540 回答