I have a device from which I read images. Every image is an array of 8b grayscale pixels row by row. How can I display the image sequence as a video?
Something like this:
while !terminated:
image = readImage(...)
widget.updateImage(image, width, height)
Specifications:
My best solution with PyQt:
#! /usr/bin/python2
import sys
from PyQt4 import QtGui
from PyQt4 import QtCore
class Preview(QtGui.QWidget):
def __init__(self):
super(Preview, self).__init__()
self.setWindowTitle('Preview')
self.previewImage = QtGui.QLabel(self)
vbox = QtGui.QVBoxLayout()
vbox.addWidget(self.previewImage)
self.setLayout(vbox)
self.updater = QtCore.QTimer()
self.updater.setSingleShot(True)
self.updater.setInterval(10)
self.updater.timeout.connect(self.update)
self.show()
self.updater.start()
def update(self):
data = get_pgm(...) # this function reads device and adds PGM header
pixmap = QtGui.QPixmap()
pixmap.loadFromData(data)
self.previewImage.setPixmap(pixmap)
self.previewImage.show()
self.updater.start()
def main():
app = QtGui.QApplication(sys.argv)
preview = Preview()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With