Advice for using node-red-contrib-image-tools

I am using these nodes to do some image processing on a locally hosted 567 KB file (see sample attached jpeg)

This flow works on a RPi Zero. It takes about 30 seconds for the output to appear in the debug node, and another 30-45 seconds for the image to appear in the Viewer node:

[{"id":"7b5298742b600106","type":"file in","z":"7ab8211d86815752","name":"","filename":"/home/rpi0c/test1.jpg","filenameType":"str","format":"","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":340,"y":620,"wires":[["2f63038ac579084d","09aee8b775bb98b8"]]},{"id":"a75dd86ce191280d","type":"inject","z":"7ab8211d86815752","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":620,"wires":[["7b5298742b600106"]]},{"id":"2f63038ac579084d","type":"debug","z":"7ab8211d86815752","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":620,"y":740,"wires":[]},{"id":"09aee8b775bb98b8","type":"image viewer","z":"7ab8211d86815752","name":"","width":160,"data":"payload","dataType":"msg","active":true,"x":610,"y":540,"wires":[[]]}]

However, adding more complexity like this causes Node-RED to crash (or at least that is what I believe is happening):

[{"id":"7b5298742b600106","type":"file in","z":"7ab8211d86815752","name":"","filename":"/home/rpi0c/test1.jpg","filenameType":"str","format":"","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":380,"y":320,"wires":[["2f63038ac579084d","6b9ff5cfae66000a"]]},{"id":"a75dd86ce191280d","type":"inject","z":"7ab8211d86815752","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":320,"wires":[["7b5298742b600106"]]},{"id":"2f63038ac579084d","type":"debug","z":"7ab8211d86815752","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":580,"y":500,"wires":[]},{"id":"6b9ff5cfae66000a","type":"jimp-image","z":"7ab8211d86815752","name":"","data":"payload","dataType":"msg","ret":"buf","parameter1":".7","parameter1Type":"num","parameter2":"","parameter2Type":"msg","parameter3":"","parameter3Type":"msg","parameter4":"","parameter4Type":"msg","parameter5":"","parameter5Type":"msg","parameter6":"","parameter6Type":"msg","parameter7":"","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","sendProperty":"payload","sendPropertyType":"msg","parameterCount":0,"jimpFunction":"greyscale","selectedJimpFunction":{"name":"greyscale","fn":"greyscale","description":"remove colour from the image","parameters":[]},"x":620,"y":320,"wires":[["df118e676152ee4f","750771f347d6065f"]]},{"id":"df118e676152ee4f","type":"image viewer","z":"7ab8211d86815752","name":"","width":160,"data":"payload","dataType":"msg","active":true,"x":670,"y":380,"wires":[[]]},{"id":"750771f347d6065f","type":"jimp-image","z":"7ab8211d86815752","name":"","data":"payload","dataType":"msg","ret":"buf","parameter1":"","parameter1Type":"msg","parameter2":"","parameter2Type":"msg","parameter3":"","parameter3Type":"msg","parameter4":"","parameter4Type":"msg","parameter5":"","parameter5Type":"msg","parameter6":"","parameter6Type":"msg","parameter7":"","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","sendProperty":"payload","sendPropertyType":"msg","parameterCount":0,"jimpFunction":"invert","selectedJimpFunction":{"name":"invert","fn":"invert","description":"invert the image colours","parameters":[]},"x":790,"y":320,"wires":[["59ea95591285fe1a","12e432d2a2a5e34d"]]},{"id":"59ea95591285fe1a","type":"image viewer","z":"7ab8211d86815752","name":"","width":160,"data":"payload","dataType":"msg","active":true,"x":850,"y":380,"wires":[[]]},{"id":"12e432d2a2a5e34d","type":"file","z":"7ab8211d86815752","name":"","filename":"digits.png","filenameType":"str","appendNewline":true,"createDir":false,"overwriteFile":"true","encoding":"none","x":960,"y":320,"wires":[["2fdea0775e5675af"]]},{"id":"2fdea0775e5675af","type":"debug","z":"7ab8211d86815752","name":"debug 10","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1120,"y":320,"wires":[]}]


Again, it takes about 30 seconds for the output to appear, but in this case after about 8 minutes, no images appear and this is what the log looks like:
image

Any ideas what could be causing this? Am I over reaching by using a RPi Zero for this? I only need to process the image (which changes regularly) about once per minute.

What does top look like while it is thinking?

Here is what I see after the first debug message appears:

and here it is after another 3-4 minutes:

Maybe the Pi Zero is not the right tool for this task?

I think I was grabbing too large of an image. It's obviously a seven-segment LCD with two digits and two colors. I downsized to 640 x 480 and it runs in < 1 minute:

Do you know what size, in memory a 567KB JPEG takes? This image appears to be a 1920x1080 24bit image. Each pixel uses 3 bytes . So, the maximum size of a 1920x1080 image with 3-byte pixels is approximately 6,220,800 bytes (6.22 megabytes). Thats without the overhead of the node (which holds the packed and unpacked parts of the image)

Then each time your flow branches, a clone is made.

In short, it is not surprising since an RPi Zero has only 512MB to play with.

Does this REALLY need to be an image? 7 seg displays can be made easily with a few lines of HTML+CSS

If you must work with images on such a limited device, my recommendations are as follows.

  1. NEVER branch the outputs (one wire per output)
  2. Dont use the viewer, but if you do, use it in-line (thats why there is an output pin on it)
  3. Where sensible, work with smaller images (your HTML can always set width and height)

640 x 480 x 3 is still 1MB to shift around. Try to follow my recommendations in prev post and this will be a lot quicker.

Thanks for the advice / tips. I resized the image even further (when taking the photo) and was able to do some tricks using the ssocr program running on the Pi, and thus eliminate the use of the image tools. Pi camera snaps a photo every minute or so of the 2-digit display and then SSOCR picks it up to analyze it.

Each time you branch, msg is cloned.

Also, I would recommend not writing to SD card. You can pass the image data as a buffer to a tesseract node for OCR instead of a commandline tool

I put the viewer in my flow only for purposes of the screenshot to show what I was doing.

I tried the tesseract node several months ago and had mixed results with it.

I will look into not storing the file on the SD and instead just passing the buffer.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.