CameraImageProvider.py 654 B

123456789101112131415161718
  1. from PyQt5.QtGui import QImage
  2. from PyQt5.QtQuick import QQuickImageProvider
  3. from PyQt5.QtCore import QSize
  4. from UM.Application import Application
  5. class CameraImageProvider(QQuickImageProvider):
  6. def __init__(self):
  7. QQuickImageProvider.__init__(self, QQuickImageProvider.Image)
  8. ## Request a new image.
  9. def requestImage(self, id, size):
  10. for output_device in Application.getInstance().getOutputDeviceManager().getOutputDevices():
  11. try:
  12. return output_device.activePrinter.camera.getImage(), QSize(15, 15)
  13. except AttributeError:
  14. pass
  15. return QImage(), QSize(15, 15)