当前位置: 首页 > article >正文

【Node-Red】使用文件或相机拍摄实现图像识别

使用相机拍照实现图像识别
请添加图片描述
首先需要下载节点 node-red-contrib-tfjs-coco-ssd,下载不上的朋友可以根据【Node-Red】最新版coco-ssd 1.0.6安装方法(windows)文章进行安装。

1、智能识别图片

使用本地文件的形式对图像进行识别
在这里插入图片描述

  • 时间戳(inject):作为触发点节点
  • 文件路径(file in):写入需要识别的图像路径,例如:D:\node-redPicture\123.jpeg,在输出中选择buffer流
  • tf coco ssd:此节点中,Threshold为分数阈值(0-1),也可通过传参msg.scoreThreshold 进行修改;
    Model Url为地址,尽量不要改动,修改为连接不成功的地址后node-red后台会崩溃;
    Passthru:可以选择图片显示模式;
    Box colour:当Passthru中选择为做过标注的图片,那就需要对标注颜色做设定
    在这里插入图片描述
  • msg:在msg节点中设置为与调试输出相同来查看完整输出信息
    payload为数组格式,当识别物体为多种时,都可以显示在数组中,在数组中还显示了标注框位置、类型、打分
    image为buffer类型的数组存放图片内容
    classes为识别类型及数量
    在这里插入图片描述

2、将识别信息显示在UI界面

根据如上输出的msg,将classes和image 进行输出。
在这里插入图片描述

  • base64:需要下载新的节点node-red-node-base64,并将属性改为image,实现对msg.image的buffer转为base64进行输出。
  • 识别信息(text):设置为{{msg.classes}}实现将识别类型和数量进行输出
  • template:将保存在msg.image中的base64码的图片进行输出
<img src="data:image/png;base64,{{msg.image}}"/>

3、将使用相机拍摄并智能识别

将文件路径节点换成webcam相机节点即可实现使用相机拍照并智能识别显示在UI界面。
在这里插入图片描述
Webcam节点:需要下载node-red-contrib-webcam节点,此节点支持多个相机的选择。

4、源码

包含有使用文件和相机识别的源码,导入后记得file in节点中修改文件路径为自己电脑上的图片哦。

[{"id":"951cc2fe955f0e75","type":"tab","label":"图像识别2","disabled":false,"info":"","env":[]},{"id":"cabe60bfdbc81940","type":"inject","z":"951cc2fe955f0e75","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":640,"wires":[["fe59fe71ec5f11ac"]]},{"id":"24114e412c2cc380","type":"tensorflowCoco","z":"951cc2fe955f0e75","name":"","modelUrl":"http://127.0.0.1:1880/coco/model.json","scoreThreshold":0.5,"passthru":"bbox","lineColour":"magenta","x":570,"y":640,"wires":[["8b8e5e51a76d5a90","95e0cee58947b315"]]},{"id":"8b8e5e51a76d5a90","type":"ui_text","z":"951cc2fe955f0e75","group":"6f6c46f5d5c922a6","order":2,"width":0,"height":0,"name":"","label":"识别信息","format":"{{msg.payload[0].class}}","layout":"row-spread","className":"","x":760,"y":600,"wires":[]},{"id":"1837101f551fce5b","type":"ui_template","z":"951cc2fe955f0e75","group":"6f6c46f5d5c922a6","name":"","order":4,"width":0,"height":0,"format":"<img src=\"data:image/png;base64,{{msg.image}}\"/>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":920,"y":640,"wires":[[]]},{"id":"95e0cee58947b315","type":"base64","z":"951cc2fe955f0e75","name":"","action":"","property":"image","x":760,"y":640,"wires":[["1837101f551fce5b"]]},{"id":"fe59fe71ec5f11ac","type":"ui_webcam","z":"951cc2fe955f0e75","name":"","group":"6f6c46f5d5c922a6","order":1,"width":"12","height":"6","countdown":false,"autoStart":false,"hideCaptureButton":false,"showImage":"2","mirror":true,"format":"jpeg","x":380,"y":640,"wires":[["24114e412c2cc380"]]},{"id":"4829dfb95f7b284e","type":"inject","z":"951cc2fe955f0e75","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":310,"y":240,"wires":[["13738fa2d9746405"]]},{"id":"eae555d1fe52e7e7","type":"tensorflowCoco","z":"951cc2fe955f0e75","name":"","modelUrl":"http://127.0.0.1:1880/coco/model.json","scoreThreshold":0.5,"passthru":"bbox","lineColour":"magenta","x":590,"y":240,"wires":[["733a983efa6b687d","103b3ab3b44be50b"]]},{"id":"733a983efa6b687d","type":"ui_text","z":"951cc2fe955f0e75","group":"6f6c46f5d5c922a6","order":2,"width":0,"height":0,"name":"","label":"识别信息","format":"{{msg.payload[0].class}}","layout":"row-spread","className":"","x":780,"y":200,"wires":[]},{"id":"696c782d27d5f7cf","type":"ui_template","z":"951cc2fe955f0e75","group":"6f6c46f5d5c922a6","name":"","order":4,"width":"12","height":"9","format":"<img src=\"data:image/png;base64,{{msg.image}}\"/>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":940,"y":280,"wires":[[]]},{"id":"103b3ab3b44be50b","type":"base64","z":"951cc2fe955f0e75","name":"","action":"","property":"image","x":760,"y":280,"wires":[["696c782d27d5f7cf","4e1f0383e3658067"]]},{"id":"13738fa2d9746405","type":"file in","z":"951cc2fe955f0e75","name":"文件路径","filename":"D:\\node-redPicture\\123.jpeg","filenameType":"str","format":"stream","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":440,"y":240,"wires":[["eae555d1fe52e7e7"]]},{"id":"4e1f0383e3658067","type":"debug","z":"951cc2fe955f0e75","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":990,"y":220,"wires":[]},{"id":"6f6c46f5d5c922a6","type":"ui_group","name":"图像识别","tab":"09e34f5af80a3ab6","order":4,"disp":true,"width":"12","collapse":false,"className":""},{"id":"09e34f5af80a3ab6","type":"ui_tab","name":"dashboard基础节点","icon":"dashboard","order":6,"disabled":false,"hidden":false}]

http://www.kler.cn/a/396029.html

相关文章:

  • vue3:computed
  • 使用 Python 和 OpenCV 实现摄像头人脸检测并截图
  • ‘视’不可挡:OAK相机助力无人机智控飞行!
  • python makedirs() 详解
  • 解读Nature:Larger and more instructable language models become less reliable
  • 卷积神经网络之Yolo详解
  • CSS盒子的定位> (下篇)#固定定位#笔记
  • Java基础知识03(内部类)【24.11.25】
  • nodejs和npm在gitbash中提示Not Found情况的解决办法
  • 嘉立创EDA 画PCB板子经验总结(二)
  • Windows系统 ElasticSearch,Kibana安装
  • 使用spring操作redis
  • idea使用技巧和推荐插件
  • 第六十四周周报 TCN-LSTM
  • SOLIDWORKS Toolbox:一键自动化,让紧固件与零部件管理更高效
  • WPF中Prism框架中 IContainerExtension 和 IRegionManager的作用
  • 什么是网络安全?网络安全包括哪几个方面?
  • ffmpeg视频编码
  • 物联网(RFID)全景:被装信息化监控应用与挑战
  • RA-L开源:Light-LOAM: 基于图匹配的轻量级激光雷达里程计和地图构建
  • Django中文教程
  • 大模型开发整体流程 基于个人知识库的问答助手 项目流程架构解析
  • QT6 QML vtk学习之(1)点云在QML窗口中显示
  • 深入理解UML用例图:概念、构成与应用实例
  • java瑞吉外卖
  • AI入驻电商江湖:智能算法如何打响“带货”大战?