Hi, thanks for posting that. Unfortunately the code doesn't run for me, so I made what seemed to me the smallest edits that I could that would make it work. I ended up with:That seems to run OK for me, but please let us know if that isn't replicating the problem you're having. Another suggestion might be to replace the configuration with this:Here I've changed the the main output stream to YUV420 format which is more efficient than the default (32-bit ARGB), though whether that works for you will depend on what you want to do with it. I've also chosen to display the low resolution stream instead, which can be smaller and therefore cheaper. I also changed it to a "video" configuration which will default to 30fps, and increased the buffer_count, as this can prevent frame drops too in some circumstances.
Code:
from PyQt5.QtWidgets import QApplicationfrom picamera2 import Picamera2from picamera2.previews.qt import QGlPicamera2app = QApplication([])class VideoWidget: def __init__(self): self.camera = Picamera2() config = self.camera.create_preview_configuration( main={"size": (1920, 1080)} ) self.camera.configure(config) self.box = QGlPicamera2(self.camera) def start_stream(self): self.camera.start() def stop_stream(self): self.camera.stop()video = VideoWidget()video.box.show()video.start_stream()app.exec()
Code:
config = self.camera.create_preview_configuration( main={"size": (1920, 1080), "format": "BGR888"}, lores={"size": (960, 540), "format": "YUV420"}, display="lores", buffer_count=12 )
Statistics: Posted by therealdavidp — Wed Aug 07, 2024 4:13 pm