我正在写一个测试脚本。我想将不同的位显示为模式并将其保存在图像下。 对于位1 = a0.png 对于位2 = a2.png ... 对于位8 = a8.png
我的程序会从相机中保存图片,但不会显示window.show。
这里有什么问题?
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()