0

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)
  • did you try to set resolution before `PiRGBArray(camera)` ? – furas May 24 '20 at 02:58
  • maybe ask on RPi forum: https://www.raspberrypi.org/forums/ – furas May 24 '20 at 02:59
  • or maybe read all in documetation [PiCamera](https://picamera.readthedocs.io/en/release-1.13/) – furas May 24 '20 at 03:04
  • I've read the doc over and over in the past week and I found nothing that mentions this. I try will furas recommendation and I'll come back in a few hours max. – Zacharie McCormick May 24 '20 at 15:00
  • I just tried to set the resolution before the call to create the PiRGBArray but it does not work either. I also tried passing the camera resolution in the size parameter of PiRGBArray call but it didn't do anything different. – Zacharie McCormick May 24 '20 at 15:11

0 Answers0