0

I am writing a test script. I want to display different bits as a pattern and save these under images. For bits 1 = a0.png For bits 2 = a2.png ... for bits 8 = a8.png

My program saves me the pictures from the camera but the window.show is not displayed.

What is the problem here?

app = QtGui.QApplication(sys.argv)
win = QtGui.QMainWindow()
win.show()
height = 1024
width = 768
bitrange = 8
imgs = []
window = FullscreenWindow(0)
for bits in range(0,bitrange):
    stripe_width = 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.append(numpy.tile(vector,(height,1)))
    window.show(imgs[bits])


    with Vimba() as vimba:

        system = vimba.getSystem()
        system.runFeatureCommand("GeVDiscoveryAllOnce")
        time.sleep(1)
        camera_ids = vimba.getCameraIds()
        for cam_id in camera_ids:
            print("Camera found: ", cam_id)
        c0 = vimba.getCamera(camera_ids[0])
        c0.openCamera()
        print(c0.AcquisitionMode)
        c0.AcquisitionMode = 'SingleFrame'
        frame0 = c0.getFrame()
        frame0.announceFrame()
        i=0
        while i < 1:
            c0.startCapture()
            frame0.queueFrameCapture()
            c0.runFeatureCommand('AcquisitionStart')
            c0.runFeatureCommand('AcquisitionStop')
            frame0.waitFrameCapture()
            imgData = frame0.getBufferByteData()
            moreUsefulImgData = np.ndarray(buffer=frame0.getBufferByteData(),
                                       dtype=np.uint8,
                                       shape=(frame0.height,
                                              frame0.width,
                                              1))
            rgb = cv2.cvtColor(moreUsefulImgData, cv2.COLOR_BAYER_RG2RGB)
            cv2.imwrite('a{}.png'.format(bits), rgb)
            print("image {} saved".format(bits))
            i+=1
            c0.endCapture()
        c0.revokeAllFrames()
        c0.closeCamera()
ekhumoro
  • 115,249
  • 20
  • 229
  • 336
A.D
  • 3
  • 1
  • 1
  • 7

0 Answers0