Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python not taking picture at highest resolution from Raspberry Pi Camera

I have a Raspberry Pi Camera version v2.1, capable of taking a picture with 3280x2464 resolution.

I have taken a test with raspistill command, and this seems to work out fine:

raspistill -o 8mp.png -w 3280 -h 2464

returns the info:

8mp.png JPEG 3280x2464 3280x2464+0+0 8-bit sRGB 4.524MB 0.010u 0:00.010

However, when I use the Python code to take a picture, it will refuse it. Here's the code I'm working with:

#!/usr/bin/python
import picamera

camera = picamera.PiCamera()
camera.resolution = (3280,2464)
camera.capture("test.png")
camera.close()

And this is the error:

mmal: mmal_vc_port_enable: failed to enable port vc.ril.image_encode:out:0(PNG ): ENOSPC
mmal: mmal_port_enable: failed to enable port vc.ril.image_encode:out:0(PNG )(0x700090) (ENOSPC)
Traceback (most recent call last):
  File "pic.py", line 6, in <module>
    camera.capture("test.png")
  File "/usr/local/lib/python2.7/dist-packages/picamera/camera.py", line 1383, in capture
    encoder.start(output)
  File "/usr/local/lib/python2.7/dist-packages/picamera/encoders.py", line 1024, in start
    super(PiCookedOneImageEncoder, self).start(output)
  File "/usr/local/lib/python2.7/dist-packages/picamera/encoders.py", line 394, in start
    self.output_port.enable(self._callback)
  File "/usr/local/lib/python2.7/dist-packages/picamera/mmalobj.py", line 813, in enable
    prefix="Unable to enable port %s" % self.name)
  File "/usr/local/lib/python2.7/dist-packages/picamera/exc.py", line 157, in mmal_check
    raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Unable to enable port vc.ril.image_encode:out:0(PNG ): Out of resources (other than memory)

I have noticed doing it with .jpg instead of .png will work. This seems a little odd to me, as the documentation says it should work, and the raspistill command also works with this resolution on .png.

Any ideas?

like image 841
user5740843 Avatar asked Aug 31 '16 14:08

user5740843


1 Answers

I ran into the same problem. I was able to solve it by adjusting the Pi's "Memory Split" setting to 256MB. This changes how much memory is available to the GPU.

You can access this setting by running sudo raspi-config. "Memory Split" is under "Advanced Options".

like image 148
ThomasGT Avatar answered Sep 18 '22 03:09

ThomasGT