Node-Red Azure Computer Vision Photo Recognition Complete Example

Capture a Photo from webcam, image file, or URL, use the Computer Vision API to analyze the photo. Display the result analysis and also play it using text to speech. Use the Node-Red dashboard to display output, button press capture, and URL input.

Blog post and video tutorial coming soon at http://electronhacks.com

[{"id":"f93767d8.41b058","type":"file in","z":"1f27e1dd.2ccd6e","name":"","filename":"C:\\Users\\Johnathan\\Pictures\\Trump.jpg","format":"","x":480,"y":399,"wires":[["87ab4330.d781a"]]},{"id":"fad8aae1.730728","type":"ui_audio","z":"1f27e1dd.2ccd6e","name":"","group":"c501cd59.36ab1","voice":"0","always":"","x":845,"y":561,"wires":[]},{"id":"4e60a724.24add8","type":"ui_button","z":"1f27e1dd.2ccd6e","name":"","group":"c501cd59.36ab1","order":0,"width":0,"height":0,"passthru":false,"label":"Get File","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":97,"y":397,"wires":[["f93767d8.41b058"]]},{"id":"87ab4330.d781a","type":"Computer Vision","z":"1f27e1dd.2ccd6e","operation":"description","name":"","x":854,"y":405,"wires":[["26983a28.3e4ef6","fad8aae1.730728","377d3668.bd3baa"]]},{"id":"26983a28.3e4ef6","type":"debug","z":"1f27e1dd.2ccd6e","name":"Debug","active":true,"console":"false","complete":"payload","x":835,"y":485,"wires":[]},{"id":"c19a61c0.e3064","type":"ui_text_input","z":"1f27e1dd.2ccd6e","name":"","label":"URL","group":"c501cd59.36ab1","order":0,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"","x":91,"y":537,"wires":[["7289583b.a68788"]]},{"id":"e52311f.4fef3f","type":"http request","z":"1f27e1dd.2ccd6e","name":"","method":"GET","ret":"bin","url":"","tls":"","x":570,"y":549,"wires":[["87ab4330.d781a"]]},{"id":"3609641.ff0779c","type":"inject","z":"1f27e1dd.2ccd6e","name":"Test","topic":"","payload":"http://cdn2-www.dogtime.com/assets/uploads/gallery/30-impossibly-cute-puppies/impossibly-cute-puppy-8.jpg","payloadType":"str","repeat":"","crontab":"","once":false,"x":92,"y":576,"wires":[["7289583b.a68788"]]},{"id":"7289583b.a68788","type":"function","z":"1f27e1dd.2ccd6e","name":"Create URL from string","func":"msg.url = msg.payload\nreturn msg;","outputs":1,"noerr":0,"x":357,"y":551,"wires":[["e52311f.4fef3f"]]},{"id":"377d3668.bd3baa","type":"ui_text","z":"1f27e1dd.2ccd6e","group":"c501cd59.36ab1","order":0,"width":0,"height":0,"name":"","label":"Output","format":"{{msg.payload}}","layout":"col-center","x":836,"y":521,"wires":[]},{"id":"474c4c06.79adc4","type":"exec","z":"1f27e1dd.2ccd6e","command":"C:\\Users\\Johnathan\\CommandCam.exe","addpay":false,"append":"/preview /delay 5000","useSpawn":true,"timer":"","name":"","x":455,"y":109.5,"wires":[[],[],[]]},{"id":"f503d9a2.2e3628","type":"inject","z":"1f27e1dd.2ccd6e","name":"Test","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"x":93,"y":134,"wires":[["474c4c06.79adc4"]]},{"id":"e5a5e65f.557898","type":"ui_button","z":"1f27e1dd.2ccd6e","name":"","group":"c501cd59.36ab1","order":0,"width":0,"height":0,"passthru":false,"label":"Take Picture","color":"","bgcolor":"","icon":"","payload":"true","payloadType":"bool","topic":"","x":118,"y":95,"wires":[["474c4c06.79adc4"]]},{"id":"14f618d4.26ff67","type":"watch","z":"1f27e1dd.2ccd6e","name":"Watch for file change","files":"C:\\Users\\Johnathan\\image.bmp","x":149,"y":247,"wires":[["f412e58c.ff2798","f3b3b903.abed38"]]},{"id":"f412e58c.ff2798","type":"file in","z":"1f27e1dd.2ccd6e","name":"","filename":"C:\\Users\\Johnathan\\image.bmp","format":"","x":506,"y":360,"wires":[["87ab4330.d781a"]]},{"id":"f3b3b903.abed38","type":"exec","z":"1f27e1dd.2ccd6e","command":"start C:\\Users\\Johnathan\\image.bmp","addpay":false,"append":"","useSpawn":false,"timer":"","name":"","x":907,"y":246.5,"wires":[[],[],[]]},{"id":"2a0c37f8.0fece8","type":"comment","z":"1f27e1dd.2ccd6e","name":"Takes a picture from webcam via Command Line ","info":"Download CommandCam for Windows. \nExecute it via command line to open a preview window,\nWait 5 seconds, take snapshot. \nExample: C:\\Users\\Johnathan\\CommandCam.exe /preview /delay 5000\n\nIf using a Raspbery Pi camera module you can use \nraspistill.\nExample: raspistill -o /home/pi/Pictures/image.jpg -q 5 --vflip","x":210,"y":55,"wires":[]},{"id":"ba67c802.ff49c8","type":"comment","z":"1f27e1dd.2ccd6e","name":"Watch for new webcam image","info":"Watch for the image file to change, if so get the \nimage and send it for analysis","x":147,"y":206,"wires":[]},{"id":"404748e6.cc5e68","type":"comment","z":"1f27e1dd.2ccd6e","name":"Optional, open the new image after it changes","info":"","x":884,"y":198,"wires":[]},{"id":"9d59517f.0986e","type":"comment","z":"1f27e1dd.2ccd6e","name":"Get local image file","info":"","x":113,"y":354,"wires":[]},{"id":"7ec3cd3f.656864","type":"comment","z":"1f27e1dd.2ccd6e","name":"Get image from URL","info":"","x":124,"y":498,"wires":[]},{"id":"cf66a0fb.f6527","type":"comment","z":"1f27e1dd.2ccd6e","name":"Output to debug window, text, speech","info":"","x":907,"y":598,"wires":[]},{"id":"aba92673.ba5958","type":"comment","z":"1f27e1dd.2ccd6e","name":"Microsoft Computer Vision API","info":"Sign up for a Microsoft Azure account.\nCreate a Computer Vision API service in the \n  West US Region.\nCopy and paste one of the keys.\n","x":880,"y":364,"wires":[]},{"id":"c501cd59.36ab1","type":"ui_group","z":"","name":"MsftCognative","tab":"b2549c07.5d13e","disp":true,"width":"6"},{"id":"b2549c07.5d13e","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]
ElectronHacks

Flow Info

created 1 month, 1 week ago

Node Types

Core
  • comment (x7)
  • debug (x1)
  • exec (x2)
  • file in (x2)
  • function (x1)
  • http request (x1)
  • inject (x2)
  • watch (x1)
Other
  • Computer Vision (x1)
  • ui_audio (x1)
  • ui_button (x2)
  • ui_group (x1)
  • ui_tab (x1)
  • ui_text (x1)
  • ui_text_input (x1)

Tags

  • Azure
  • Computer
  • Vision
  • Microsoft
  • Photo
  • Recognition
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option