介绍
node-red-contrib-rpi-imagecapture
是一个用于 Raspberry Pi 的 Node-RED 的节点,它可以用于捕获照片或视频,并将其发送到 Node-RED 流程中进行处理或显示。您可以使用该节点在 Raspberry Pi 上捕获实时视频或静态照片,也可以配置自动拍照或录制时间间隔,拍摄一个时间段内的多张照片或视频。
安装
在您的 Node-RED 实例中,打开终端并输入以下命令进行安装:
npm install -g node-red-contrib-rpi-imagecapture
使用
捕获照片
将
rpi-camera
节点拖放到 Node-RED 工作区域。配置节点属性,包括图像质量、图像宽度和高度等。
创建一个输出节点,例如
debug
节点。点击
Deploy
按钮。在
debug
节点中查看捕获的图像数据。
示例代码:
[{"id":"b8e4527d.29e25","type":"rpi-camera","z":"d7e27550.4289b","name":"Capture Image","quality":"10","width":"640","height":"480","strips":false,"flip":false,"rotate":"270","shutter":0.1,"awb":"Auto","brightness":50,"contrast":0,"iso":0,"sharpness":0,"debug":false,"preview":false,"fullscreen":false,"bayer":false,"ss_r":0,"ss_b":0,"tn_r":"","tn_b":"","tn_g":"","output":"jpeg","x":276,"y":325,"wires":[["e757c172.917d58"]]},{"id":"e757c172.917d58","type":"debug","z":"d7e27550.4289b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":474,"y":308,"wires":[]}]
捕获视频
将
rpi-camera
节点拖放到 Node-RED 工作区域。配置节点属性,例如视频编解码器、视频帧率和视频质量等。
创建一个输出节点,例如
rtmp-out
节点。点击
Deploy
按钮。在
rtmp-out
节点中查看捕获的实时视频。
示例代码:
[{"id":"b8e4527d.29e25","type":"rpi-camera","z":"d7e27550.4289b","name":"Capture Video","fps":"5","quality":"5","width":"640","height":"480","strips":false,"flip":false,"rotate":"270","shutter":0.1,"awb":"Auto","brightness":50,"contrast":0,"iso":0,"sharpness":0,"debug":false,"preview":false,"fullscreen":false,"bayer":false,"ss_r":0,"ss_b":0,"tn_r":"","tn_b":"","tn_g":"","output":"h264","x":276,"y":325,"wires":[["52c7af05.592ea"]]},{"id":"52c7af05.592ea","type":"rtmp-out","z":"d7e27550.4289b","name":"","url":"rtmp://example.com:1935/live/stream","debug":false,"x":532,"y":330,"wires":[]}]
自动拍照
将
rpi-time-lapse
节点拖放到 Node-RED 工作区域。配置节点属性,例如拍摄时间间隔、照片数量等。
创建一个输出节点,例如
email
或telegram-bot
节点。点击
Deploy
按钮。在
email
或telegram-bot
节点中查看捕获的图像。
示例代码:
[{"id":"d44b57f9.7dec","type":"inject","z":"d7e27550.4289b","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"*/5 * * * *","once":false,"onceDelay":0.1,"x":256,"y":112,"wires":[["b9f2c1a8.30f698"]]},{"id":"b9f2c1a8.30f698","type":"function","z":"d7e27550.4289b","name":"Get Timestamp","func":"msg.payload = new Date().getTime();\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":112,"wires":[["1886f715.6f3a6a"]]},{"id":"848a8e4a.e1ad4","type":"email","z":"d7e27550.4289b","server":"smtp.gmail.com","port":"465","secure":true,"tls":true,"name":"Email","dname":"Email","x":798,"y":241,"wires":[]},{"id":"313b237c.a64636","type":"rpi-email","z":"d7e27550.4289b","name":"Send Email","interval":"5","counter":"3","to":"user@example.com","subject":"Raspberry Pi Camera","message":"Check out this cool time-lapse!","x":793,"y":385,"wires":[[]]},{"id":"b77609b7.209d78","type":"inject","z":"d7e27550.4289b","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":174,"y":269,"wires":[["1c6116dd.6556dc"]]},{"id":"1c6116dd.6556dc","type":"telegram sender","z":"d7e27550.4289b","name":"Telegram Bot","bot":"","outputs":1,"x":473,"y":267,"wires":[[]]},{"id":"1886f715.6f3a6a","type":"change","z":"d7e27550.4289b","name":"Reset counter","rules":[{"t":"set","p":"counter","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":574,"y":107,"wires":[["f8de5c29.c67b9"]]},{"id":"f8de5c29.c67b9","type":"rpi-time-lapse","z":"d7e27550.4289b","name":"Time-Lapse","fps":"5","quality":"5","width":"640","height":"480","strips":false,"flip":false,"rotate":"270","shutter":0.1,"awb":"Auto","brightness":50,"contrast":0,"iso":0,"sharpness":0,"debug":false,"save":"file","savePath":"/home/pi/Pictures/","keepFiles":"10","maxFiles":"50","output":"jpeg","x":571,"y":193,"wires":[["313b237c.a64636"],["848a8e4a.e1ad4"],["1c6116dd.6556dc"]]}]
结论
node-red-contrib-rpi-imagecapture
是一个功能强大而简单易用的 Node-RED 节点,它可以帮助您轻松地捕获照片或视频,并将其发送到流程中进行后续处理或显示。通过本文的介绍和示例,我们相信您已掌握了如何使用该节点进行 Raspberry Pi 的图像处理。如果您在使用中遇到任何问题或有任何建议,请随时在评论区留言,我们会尽力为您解决问题。
来源:JavaScript中文网 ,转载请注明来源 https://www.javascriptcn.com/post/60056f5d81e8991b448e79cc