Node-Red with OpenCV

I am using a similar setup with some RPis running Motion.

I have Node-RED running on another machine, where I can capture a still image using an ffmpeg from an exec node, and process the image with node-red-contrib-image-tools. Mainly reducing size and quality for use in a Telegram bot.

Here's a basic flow for that, just change IP and port of your Motion server:

[{"id":"370d8c79.3d439c","type":"exec","z":"93b1388c.f7fc4","command":"ffmpeg -i http://ip:port/ -vframes 1 -f image2 -","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"cam1","x":770,"y":180,"wires":[["480b8a7d.851f6c"],[],[]]},{"id":"480b8a7d.851f6c","type":"jimp-image","z":"93b1388c.f7fc4","name":"","data":"payload","dataType":"msg","ret":"img","parameter1":".5","parameter1Type":"num","parameter2":"","parameter2Type":"none","parameter3":"","parameter3Type":"msg","parameter4":"","parameter4Type":"msg","parameter5":"","parameter5Type":"msg","parameter6":"","parameter6Type":"msg","parameter7":"","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","parameterCount":2,"jimpFunction":"scale","selectedJimpFunction":{"name":"scale","fn":"scale","description":"scale the image by the factor f","parameters":[{"name":"f","type":"num","required":true,"hint":"f the factor to scale the image by"},{"name":"mode","type":"resizeMode","required":false,"hint":"a scaling method (e.g. Jimp.RESIZE_BEZIER)"}]},"x":970,"y":180,"wires":[["55fb53fd.007284"]]},{"id":"55fb53fd.007284","type":"jimp-image","z":"93b1388c.f7fc4","name":"","data":"payload","dataType":"msg","ret":"buf","parameter1":"50","parameter1Type":"num","parameter2":"","parameter2Type":"msg","parameter3":"","parameter3Type":"msg","parameter4":"","parameter4Type":"msg","parameter5":"","parameter5Type":"msg","parameter6":"","parameter6Type":"msg","parameter7":"","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","parameterCount":1,"jimpFunction":"quality","selectedJimpFunction":{"name":"quality","fn":"quality","description":"Set the quality of the image. Usefull for reducing size of image before calling the write function.","parameters":[{"name":"quality","type":"num","required":true,"hint":"Quality value 1 ~ 100"}]},"x":1110,"y":180,"wires":[["499e37a0.8638e8"]]},{"id":"499e37a0.8638e8","type":"debug","z":"93b1388c.f7fc4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1290,"y":180,"wires":[]},{"id":"f93cbddc.ff3f68","type":"inject","z":"93b1388c.f7fc4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":580,"y":180,"wires":[["370d8c79.3d439c"]]}]
2 Likes