I am using Picamera library in Python in combination ith the new HQ camera and I found that if I want to use the image port and take pictures in a loop, I must set the resolution again and again in the loop. Is this normal behaviour? It seems stupid to have to set it over and over (I checked the call that setting the resolution makes and it's not a very fast one).
Here is the code I am using:
from picamera.array import PiRGBArray
from picamera.camera import PiCamera
with PiCamera() as camera:
with PiRGBArray(camera) as output:
#camera.resolution = (1280, 720) #THIS DOES NOT WORK
while not self._stop_camera_stream:
camera.resolution = (1280, 720) #BUT THIS DOES
camera.capture(output, 'rgb')
print('Captured %dx%d image' % (output.array.shape[1], output.array.shape[0]))
#The line beginning here are for a preview inside a PyQt5 Window
image = output.array
h, w, ch = image.shape
bytesPerLine = ch*w
convertedToQtFormat = QImage(image, w, h, bytesPerLine, QImage.Format_RGB888)
p = convertedToQtFormat.scaled(640,480,Qt.KeepAspectRatio)
self.changePixmap.emit(p)
output.truncate(0)