Speeding up picture taking

I'm using a pi0 with the webcamera.

It's meant to take a picture, send it to openALPR, and for that I'm using cURLPOST, I'm also using raspistill for the dashboard. I've tried removing one or the other just to test if there would be any improvement in speed but there was no change.

Right now it's taking me 6 to 8 seconds JUST to take a picture, which is way too long for what I need. Is there any way to shave off some of this time?

I'm trying to get the whole node to run a bit faster but this is my first choke point.

Here is my node:

[
     {
         "id": "2df99d57.1a24c2",
         "type": "subflow",
         "name": "photo",
         "info": "",
         "category": "",
         "in": [
             {
                 "x": 40,
                 "y": 120,
                 "wires": [
                     {
                         "id": "1356f62e.baa3ea"
                     }
                 ]
             }
         ],
         "out": [
             {
                 "x": 700,
                 "y": 40,
                 "wires": [
                     {
                         "id": "610cff3d.a0cfb",
                         "port": 0
                     }
                 ]
             }
         ]
     },
     {
         "id": "74a1fa33.029444",
         "type": "exec",
         "z": "2df99d57.1a24c2",
         "command": "sudo curl -X POST \"https://api.openalpr.com/v2/recognize?secret_key=[sk removed]&recognize_vehicle=1&country=eu&return_image=0&topn=10\" -F image=@/home/pi/Pictures/car-photo.jpeg",
         "addpay": false,
         "append": "",
         "useSpawn": "false",
         "timer": "",
         "oldrc": false,
         "name": "cURL POST",
         "x": 330,
         "y": 80,
         "wires": [
             [
                 "610cff3d.a0cfb"
             ],
             [],
             []
         ]
     },
     {
         "id": "610cff3d.a0cfb",
         "type": "json",
         "z": "2df99d57.1a24c2",
         "name": "JSON",
         "pretty": false,
         "x": 470,
         "y": 40,
         "wires": [
             [
                 "46d7d4e2.2aaefc"
             ]
         ]
     },
     {
         "id": "1356f62e.baa3ea",
         "type": "camerapi-takephoto",
         "z": "2df99d57.1a24c2",
         "filemode": "1",
         "filename": "car-photo.jpeg",
         "filedefpath": "0",
         "filepath": "/home/pi/Pictures/",
         "fileformat": "jpeg",
         "resolution": "1",
         "rotation": "0",
         "fliph": "0",
         "flipv": "0",
         "brightness": "50",
         "contrast": "0",
         "sharpness": "0",
         "quality": "",
         "imageeffect": "none",
         "exposuremode": "auto",
         "agcwait": "",
         "awb": "auto",
         "name": "Take Photo",
         "x": 150,
         "y": 120,
         "wires": [
             [
                 "74a1fa33.029444",
                 "2cfcabfa.cc0194"
             ]
         ]
     },
     {
         "id": "46d7d4e2.2aaefc",
         "type": "debug",
         "z": "2df99d57.1a24c2",
         "name": "curlpostD",
         "active": true,
         "tosidebar": true,
         "console": false,
         "tostatus": true,
         "complete": "payload",
         "x": 580,
         "y": 40,
         "wires": []
     },
     {
         "id": "2cfcabfa.cc0194",
         "type": "exec",
         "z": "2df99d57.1a24c2",
         "command": "raspistill",
         "addpay": false,
         "append": "-w 320 -h 240 -o -",
         "useSpawn": "false",
         "timer": "",
         "oldrc": false,
         "name": "",
         "x": 320,
         "y": 160,
         "wires": [
             [
                 "97900490.a979b8"
             ],
             [],
             []
         ]
     },
     {
         "id": "4b2b18a3.59a398",
         "type": "template",
         "z": "2df99d57.1a24c2",
         "name": "",
         "field": "payload",
         "fieldType": "msg",
         "format": "handlebars",
         "syntax": "mustache",
         "template": "<img width=\"800px\" height=\"600px\" src=\"data:image/jpg;base64,{{{payload}}}\">",
         "output": "str",
         "x": 580,
         "y": 140,
         "wires": [
             [
                 "19811dc8.aec422"
             ]
         ]
     },
     {
         "id": "19811dc8.aec422",
         "type": "ui_template",
         "z": "2df99d57.1a24c2",
         "group": "5d45298.aa40cd8",
         "name": "",
         "order": 5,
         "width": "4",
         "height": "4",
         "format": "<div ng-bind-html=\"msg.payload\"></div>",
         "storeOutMessages": true,
         "fwdInMessages": true,
         "templateScope": "local",
         "x": 700,
         "y": 140,
         "wires": [
             [
                 "925201c4.a192a"
             ]
         ]
     },
     {
         "id": "97900490.a979b8",
         "type": "base64",
         "z": "2df99d57.1a24c2",
         "name": "",
         "action": "str",
         "property": "payload",
         "x": 460,
         "y": 140,
         "wires": [
             [
                 "4b2b18a3.59a398"
             ]
         ]
     },
     {
         "id": "6e8932d0.9405ac",
         "type": "ui_button",
         "z": "2df99d57.1a24c2",
         "name": "",
         "group": "5d45298.aa40cd8",
         "order": 1,
         "width": "1",
         "height": "1",
         "passthru": false,
         "label": "Foto",
         "color": "",
         "bgcolor": "",
         "icon": "camera_alt",
         "payload": "",
         "payloadType": "str",
         "topic": "",
         "x": 150,
         "y": 160,
         "wires": [
             [
                 "2cfcabfa.cc0194",
                 "77cec238.14305c"
             ]
         ]
     },
     {
         "id": "77cec238.14305c",
         "type": "debug",
         "z": "2df99d57.1a24c2",
         "name": "",
         "active": true,
         "tosidebar": true,
         "console": false,
         "tostatus": false,
         "complete": "foto_manual_start",
         "x": 360,
         "y": 200,
         "wires": []
     },
     {
         "id": "925201c4.a192a",
         "type": "debug",
         "z": "2df99d57.1a24c2",
         "name": "",
         "active": true,
         "tosidebar": true,
         "console": false,
         "tostatus": false,
         "complete": "foto_manual_end",
         "x": 860,
         "y": 140,
         "wires": []
     },
     {
         "id": "5d45298.aa40cd8",
         "type": "ui_group",
         "z": "",
         "name": "Controls",
         "tab": "402648fd.9eb5f8",
         "disp": true,
         "width": "6",
         "collapse": false
     },
     {
         "id": "402648fd.9eb5f8",
         "type": "ui_tab",
         "z": "",
         "name": "Auto",
         "icon": "directions_car",
         "order": 1
     }
 ]

Unfortunately your post is not importable. Please see this for how to format it. You can go back and edit the previous post.
However please make it clear at what point the delay is occurring, it is not clear from your post.

Thanks, already edited the post.

Basically I want to take pictures faster. There are other issues with my work but I think I can fix those. The picture taking is the one that's giving me a hard time.

The quickest way to speed the flow up is probably to buy a faster raspberrypi.
Other than that, make sure you have a fast SDcard from a trusted source (there are many that are fakes and a lot slower than they should be), also ensure you have a power supply that is guaranteed to deliver what the raspberry pi requires.

1 Like

Not correctly. You need a line with backticks before the flow and one after. You can tell when you have got it right because it will look like the example in the link posted.
But you have not told us which bit of the flow takes the time. Put debug nodes at the output of each node then you will be able to compare the times in each output to see where the delay is. In fact do that first and just post the bit where the biggest delay is. However if the delay is waiting for the reply to the curl command then there is nothing you can do about that in node-red.

Sorry, I think I got it now.

Which bit of the flow? I'm only putting the relevant code. It's just the cURLPOST and the raspistill related nodes.

I removed cURLPOST and took pictures with raspistill. The speed change was negligible and on par with sending info to an external service.

The way the code is written it already has debugs, hence why I know exactly how long it is taking.

I see...

I'm using a class 10 SD card from a company supplier. It's all running off an official Raspberry Pi power supply.

I may save the whole thing and test it on a 3B but the end product should run on a Pi0. If I can't speed the picture taking I'll have to live with it and try solving other problems with it.

So is most of the delay in the raspistill node?
If you run raspistill from the command line does it take a similar time?

Both are similar. cURLPOST maybe takes 2 seconds more.

When hooking up a monitor to raspberry pi I can see the image for a couple of seconds (from the point of clicking the button, to where I can see a picture on the dashboard in a second monitor).

Could we maybe reduce the amount of time that preview is displayed? This is meant to be an automated system, I'll never actually see that preview.

I am still a bit confused. Are you trying to speed up the curl and the raspistill so they take less than the time they take when running from the command line, or is node-red apparently adding some overheads you want to reduce?
In other words is this a node-red issue or a Pi issue?

I'm trying everything.

I need more speed. I'll take it from wherever I can get it.

Node red seems to be adding a bit more time to the operation compared to when I use cmd so, to me it appears to be node-red related.

Right now I'm just asking if there's any way we can change the settings in node red so that at least when it gives the order to take the picture it does so without such a long, even if compared to cmd, preview.

What is it that is doing the preview?

Well, both curpost and raspistill are forcing previews.

Disabling one has negligible results (leaving raspistill in is marginally faster because it's not sending something to an online system).

I haven't used raspistill but google suggest that the -t option may do what you want. Possibly something like
-t 1000

Thanks, I'll try that and report on Monday.

Sorry for the delay, had some vacation.

It worked. Got it running faster, thanks.

Shaved off a couple seconds but I still want it to be faster. Did some testing and it's all up to OpenALPR now.