網(wǎng)站建設(shè)合同范本下載網(wǎng)銷怎么銷售的
使用相機拍照實現(xiàn)圖像識別
首先需要下載節(jié)點 node-red-contrib-tfjs-coco-ssd
,下載不上的朋友可以根據(jù)【Node-Red】最新版coco-ssd 1.0.6安裝方法(windows)文章進行安裝。
1、智能識別圖片
使用本地文件的形式對圖像進行識別
- 時間戳(inject):作為觸發(fā)點節(jié)點
- 文件路徑(file in):寫入需要識別的圖像路徑,例如:D:\node-redPicture\123.jpeg,在輸出中選擇buffer流
- tf coco ssd:此節(jié)點中,Threshold為分數(shù)閾值(0-1),也可通過傳參msg.scoreThreshold 進行修改;
Model Url為地址,盡量不要改動,修改為連接不成功的地址后node-red后臺會崩潰;
Passthru:可以選擇圖片顯示模式;
Box colour:當(dāng)Passthru中選擇為做過標(biāo)注的圖片,那就需要對標(biāo)注顏色做設(shè)定
- msg:在msg節(jié)點中設(shè)置為與調(diào)試輸出相同來查看完整輸出信息
payload為數(shù)組格式,當(dāng)識別物體為多種時,都可以顯示在數(shù)組中,在數(shù)組中還顯示了標(biāo)注框位置、類型、打分
image為buffer類型的數(shù)組存放圖片內(nèi)容
classes為識別類型及數(shù)量
2、將識別信息顯示在UI界面
根據(jù)如上輸出的msg,將classes和image 進行輸出。
- base64:需要下載新的節(jié)點
node-red-node-base64
,并將屬性改為image,實現(xiàn)對msg.image的buffer轉(zhuǎn)為base64進行輸出。 - 識別信息(text):設(shè)置為
{{msg.classes}}
實現(xiàn)將識別類型和數(shù)量進行輸出 - template:將保存在msg.image中的base64碼的圖片進行輸出
<img src="data:image/png;base64,{{msg.image}}"/>
3、將使用相機拍攝并智能識別
將文件路徑節(jié)點換成webcam相機節(jié)點即可實現(xiàn)使用相機拍照并智能識別顯示在UI界面。
Webcam節(jié)點:需要下載node-red-contrib-webcam
節(jié)點,此節(jié)點支持多個相機的選擇。
4、源碼
包含有使用文件和相機識別的源碼,導(dǎo)入后記得file in節(jié)點中修改文件路徑為自己電腦上的圖片哦。
[{"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基礎(chǔ)節(jié)點","icon":"dashboard","order":6,"disabled":false,"hidden":false}]