picam icon indicating copy to clipboard operation
picam copied to clipboard

Very poor performance

Open jeroenhouben opened this issue 5 years ago • 7 comments

This library works great when using very low quality settings but as soon as as I set jpeg quality over like 30 or 40 I get timeouts. This is for still images. Also full hd 1920x1080 stills don't work with quality of 20. Is this why the default quality is set to 15?

I'm using a pi zero, so maybe it is just not powerful enough? I'm using nerves. I'll try installing raspbian and use the command line tools (https://www.raspberrypi.org/documentation/raspbian/applications/camera.md), see if they yield the same disappointed results.

jeroenhouben avatar Mar 09 '19 19:03 jeroenhouben

Fwiw, the Raspberry Pi camera commandline tools are installed in the default Nerves images.

fhunleth avatar Mar 09 '19 19:03 fhunleth

Hmm wel just using something like this works fine:

System.cmd("raspistill", ["-n", "-q", "75", "-o", "/root/2.jpg"], stderr_to_stdout: true)

this outputs a big jpg 4.5MB 3280 × 2464

jeroenhouben avatar Mar 10 '19 09:03 jeroenhouben

I believe the reason is that we allocate a static memory buffer for the video frames and it’s not very big. This is something I’d like to work on improving, because there’s no inherent reason to impose a hard limit, other than saving memory for other processes to use.

GregMefford avatar Mar 10 '19 19:03 GregMefford

@GregMefford Could we use a Stream somehow?

electricshaman avatar Mar 10 '19 20:03 electricshaman

Any update on this?

noozo avatar Mar 20 '20 14:03 noozo

Hmm wel just using something like this works fine:

System.cmd("raspistill", ["-n", "-q", "75", "-o", "/root/2.jpg"], stderr_to_stdout: true)

this outputs a big jpg 4.5MB 3280 × 2464

The Problem with this is, that you loose time while starting up the camera process. You have to run it in background all the time, otherwise it takes ~0.5 - 1 Second after you "pull" the trigger. More infos here: https://raspberrypi.stackexchange.com/questions/23698/raspistill-slow-to-trigger (not sure if this works with nerves)

herrnesto avatar Mar 24 '20 21:03 herrnesto

If I understand the original problem correctly, the issue isn't that it takes a long time, but that it fails altogether for larger resolutions at higher quality settings. I believe this is because the data buffer we allocate for storing the compressed JPEG data isn't very big but it is hard-coded in C, so we'd need to rework some things to make it support arbitrary-size frames. This is still something I'd like to fix, but I'm not that good at C and there are a lot of moving parts in there to make sure I don't break something else accidentally.

GregMefford avatar Oct 15 '20 02:10 GregMefford