查看: 250|回复: 9

[教程] 【智控万物】node-red–百度人流识别

[复制链接]

【简介】Node-RED 是构建物联网(IOT, Internet of Things)应用程序的一个强大工具,其重点是简化代码块的“连接”以执行任务。它使用可视化编程方法,允许开发人员将预定义的代码块(称为“节点”,Node)连接起来执行任务。连接的节点,通常是输入节点、处理节点和输出节点的组合,当它们连接在一起时,构成一个“流”(Flows)。

Node-RED最初是IBM在2013年末开发的一个开源项目,以满足他们快速连接硬件和设备到Web服务和其他软件的需求——作为物联网的一种粘合剂,它很快发展成为一种通用的物联网编程工具。重要的是,Node-RED已经迅速形成一个重要的、不断增长的用户基础和一个活跃的开发人员社区,他们正在开发新的节点,同时允许程序员复用Node-RED代码来完成各种各样的任务。

虽然Node-RED 最初是用来处理物联网的应用,也就是说,它与现实世界交互和控制设备,随着它的发展,它已经成为一个较为开放的物联网开发工具。本章内容将介绍一些Node-RED的示例,既可以了解其功能,也可以介绍基本概念。同时还将讨论Node-RED的历史及其起源,以便让您了解Node-RED是什么样的,哪些类型的任务最好留给传统的编程环境。

[Java] 纯文本查看 复制代码
[{"id":"67d823b3.ef82bc","type":"tab","label":"流程1","disabled":false,"info":""},{"id":"bc79945f.af5158","type":"baidu-face-configurator","z":"","name":"","client_id":"YDGYNo2mlufGUA4mGYw9x30V","client_secret":"moMRp76G8ZF4W5pAf6l44swHcyRwtAfR"},{"id":"959e55c8.cb3438","type":"wfwatch","z":"67d823b3.ef82bc","folder":"D://node-red","x":90,"y":280,"wires":[["5282de46.88d58"]]},{"id":"5282de46.88d58","type":"switch","z":"67d823b3.ef82bc","name":"","property":"payload.changeType","propertyType":"msg","rules":[{"t":"eq","v":"create","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":290,"y":280,"wires":[["7b7bb379.533b1c"]]},{"id":"7b7bb379.533b1c","type":"change","z":"67d823b3.ef82bc","name":"变量","rules":[{"t":"move","p":"payload.filePath","pt":"msg","to":"filename","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":280,"wires":[["e40922f2.38b97"]]},{"id":"e40922f2.38b97","type":"file in","z":"67d823b3.ef82bc","name":"","filename":"","format":"","chunk":false,"sendError":false,"x":610,"y":260,"wires":[["1e4aab6c.f24255"]]},{"id":"fbcee803.1e6a88","type":"change","z":"67d823b3.ef82bc","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"image","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":400,"wires":[["cfae5254.85193"]]},{"id":"cfae5254.85193","type":"baidu-dynamic-body-num","z":"67d823b3.ef82bc","name":"","baiduface":"bc79945f.af5158","image":"","show":true,"x":1020,"y":260,"wires":[["1b928060.c8ad9","ba005d5f.c1c0d"]]},{"id":"5f112f16.fc1cd","type":"change","z":"67d823b3.ef82bc","name":"转移变量","rules":[{"t":"move","p":"payload.image","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1360,"y":260,"wires":[["4aac981d.137d68"]]},{"id":"4aac981d.137d68","type":"image","z":"67d823b3.ef82bc","name":"","width":"600","data":"payload","dataType":"msg","thumbnail":false,"pass":false,"outputs":0,"x":1600,"y":260,"wires":[]},{"id":"ba005d5f.c1c0d","type":"change","z":"67d823b3.ef82bc","name":"转移变量","rules":[{"t":"move","p":"payload.person_num","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1220,"y":200,"wires":[["abecdf5.1a22c2"]]},{"id":"abecdf5.1a22c2","type":"debug","z":"67d823b3.ef82bc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1590,"y":200,"wires":[]},{"id":"ed41bcbc.11a6d","type":"inject","z":"67d823b3.ef82bc","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":200,"wires":[["49fbd35c.bfa7cc"]]},{"id":"49fbd35c.bfa7cc","type":"www-request","z":"67d823b3.ef82bc","name":"客厅摄像机获取图片","method":"GET","ret":"bin","url":"http://192.168.31.203/ISAPI/Streaming/channels/201/picture?videoResolutionWidth=1920&videoResolutionHeight=1080","follow-redirects":true,"persistent-http":false,"tls":"","x":280,"y":200,"wires":[["1e4aab6c.f24255"]]},{"id":"1e4aab6c.f24255","type":"base64","z":"67d823b3.ef82bc","name":"","action":"","property":"payload","x":140,"y":400,"wires":[["fbcee803.1e6a88"]]},{"id":"1b928060.c8ad9","type":"base64","z":"67d823b3.ef82bc","name":"","action":"","property":"payload.image","x":1220,"y":260,"wires":[["5f112f16.fc1cd"]]}]

【详细教程】

nodered–百度人流识别–动态版应用教程

【程序图】 60.jpg

【演示视频】



云天  初级技匠
 楼主|

发表于 2020-5-13 09:08:03

回复

使用道具 举报

云天  初级技匠
 楼主|

发表于 2020-5-13 09:08:04

[{"id":"a095c8c3.ed1eb8","type":"http request","z":"c36729e4.a181d8","name":"","method":"GET","ret":"bin","url":"http://wx2.sinaimg.cn/mw690/ac38503ely1fesz8m0ov6j20qo140dix.jpg","tls":"","x":600,"y":280,"wires":[["bd8b3c0f.fd67"]]},{"id":"bd8b3c0f.fd67","type":"image","z":"c36729e4.a181d8","name":"","width":160,"data":"payload","dataType":"msg","thumbnail":false,"active":true,"pass":false,"outputs":0,"x":840,"y":280,"wires":[]},{"id":"dc5de582.a9e1e8","type":"inject","z":"c36729e4.a181d8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":430,"y":280,"wires":[["a095c8c3.ed1eb8"]]}]
回复

使用道具 举报

云天  初级技匠
 楼主|

发表于 2020-5-13 17:37:08

[{"id":"130a126.83dd6ee","type":"tab","label":"流程2","disabled":false,"info":""},{"id":"733d5330.37e97c","type":"inject","z":"130a126.83dd6ee","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":220,"wires":[["88cda406.b73a38"]]},{"id":"88cda406.b73a38","type":"function","z":"130a126.83dd6ee","name":"向百度获取 Access Token","func":"msg.headers = {\n   \"Content-Type\" : \"application/x-www-form-urlencoded\"\n}\nmsg.payload = {\n   \"grant_type\" : \"client_credentials\",\n   \"client_id\" : \"CiXgX0p0B7YTxPqTkunoL4Lk\",\n   \"client_secret\" : \"FAkxw6nyRx9O18Gc9BlhKhFRTHHrdiXd\"\n}\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":220,"wires":[["897d4800.0c48e8"]]},{"id":"897d4800.0c48e8","type":"http request","z":"130a126.83dd6ee","name":"","method":"POST","ret":"obj","paytoqs":false,"url":"https://aip.baidubce.com/oauth/2.0/token","tls":"","persist":false,"proxy":"","authType":"","x":520,"y":220,"wires":[["57386b31.bb0914","d8cd9be4.bdcd68"]]},{"id":"57386b31.bb0914","type":"function","z":"130a126.83dd6ee","name":"保存","func":"flow.set('access_token', msg.payload.access_token); //将access_token储存\nreturn msg;","outputs":1,"noerr":0,"x":680,"y":220,"wires":[[]]},{"id":"d8cd9be4.bdcd68","type":"debug","z":"130a126.83dd6ee","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":660,"y":300,"wires":[]},{"id":"55c512b8.e03cec","type":"function","z":"130a126.83dd6ee","name":"通用物体识别","func":"msg.headers = {\n    \"Content-Type\" : \"application/x-www-form-urlencoded\"\n}\nmsg.url = `https://aip.baidubce.com/rest/2. ... neral?access_token=${flow.get('access_token')}`;\nmsg.payload = {\n    image:msg.payload, //图片Base64编码\n    baike_num:5 //返回百科信息的结果数量\n}\n\nreturn msg;\n","outputs":1,"noerr":0,"x":480,"y":400,"wires":[["1ea4d826.fc58c8"]]},{"id":"1ea4d826.fc58c8","type":"http request","z":"130a126.83dd6ee","name":"","method":"POST","ret":"obj","paytoqs":false,"url":"","tls":"","persist":false,"proxy":"","authType":"","x":640,"y":400,"wires":[["7c1c99f1.9a6798"]]},{"id":"9a3341a3.0b29d","type":"base64","z":"130a126.83dd6ee","name":"","action":"","property":"payload","x":320,"y":400,"wires":[["55c512b8.e03cec"]]},{"id":"7c1c99f1.9a6798","type":"debug","z":"130a126.83dd6ee","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload['result'][0].keyword","targetType":"msg","x":850,"y":400,"wires":[]},{"id":"f12b822e.17276","type":"inject","z":"130a126.83dd6ee","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":480,"wires":[["ba2b586e.7ddec8"]]},{"id":"ba2b586e.7ddec8","type":"http request","z":"130a126.83dd6ee","name":"","method":"GET","ret":"bin","paytoqs":false,"url":"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1589351820650&di=185576fb20e70cbd23bfaa5614bd55a6&imgtype=0&src=http%3A%2F%2Fimg.mp.itc.cn%2Fupload%2F20170511%2Fc7e0f3b327894aa68e07ffde167f9fb7_th.jpg","tls":"","persist":false,"proxy":"","authType":"","x":180,"y":400,"wires":[["9a3341a3.0b29d","d3fb0332.23feb"]]},{"id":"d3fb0332.23feb","type":"image","z":"130a126.83dd6ee","name":"","width":160,"data":"payload","dataType":"msg","thumbnail":false,"pass":false,"outputs":0,"x":340,"y":440,"wires":[]}]

百度通用物体识别
61.jpg

回复

使用道具 举报

DFHkeA4wKYU  见习技师

发表于 2020-5-13 22:51:31

不错的资源啊
回复

使用道具 举报

云天  初级技匠
 楼主|

发表于 2020-5-14 10:18:24

回复

使用道具 举报

云天  初级技匠
 楼主|

发表于 2020-5-16 12:04:31

216.58.211.78        withgoogle.com

C:\Windows\System32\drivers\etc
回复

使用道具 举报

云天  初级技匠
 楼主|

发表于 2020-5-16 12:09:01

回复

使用道具 举报

gray6666  初级技神

发表于 2020-5-21 20:31:47

这个有意思
回复

使用道具 举报

pATAq  版主

发表于 2020-5-31 22:05:09

很好的教程,感谢分享
回复

使用道具 举报

高级模式
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2020 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail