----------------------------------------------
Install Visual Studio code
----------------------------------------------
sudo snap install --classic code
----------------------------------------------
Preparing your MQTT Broker
----------------------------------------------
sudo nano /etc/mosquitto/mosquitto.conf
----------------------------------------------
bind_address 0.0.0.0
port 1884
-----------------------------------------------
sudo systemctl restart mosquitto.service
sudo systemctl status mosquitto.service
----------------------------------------------
Include MQTT in the docker for Video analytics
----------------------------------------------
numpy==1.18.0
paho-mqtt==1.4.0
----------------------------------------------
Include mqtt in the udf
----------------------------------------------
import paho.mqtt.client as mqtt
client = mqtt.Client()
client.connect("192.168.100.21", 1884, 60)
-----------------------------------------------
client.publish("/ais/",json.dumps({"Result":defects}))
----------------------------------------------
Modify UDF: Provision, build and run
----------------------------------------------
cd provision && sudo -E ./provision.sh ../docker-compose.yml
cd .. && docker-compose -f docker-compose-build.yml build
docker-compose up -d
--------------------------------------
NODE-RED INSTALLATION
--------------------------------------
sudo npm install -g --unsafe-perm node-red
--------------------------------------
node-red
--------------------------------------
http://127.0.0.1:1880/
----------------------------------------------
Installing node-red module : Dashboard
----------------------------------------------
npm install node-red-dashboard@2.29.3
----------------------------------------------
Creating node-red dashboard : add video stream
----------------------------------------------
https://localhost:5000
----------------------------------------------
----------------------------------------------
Creating node-red dashboard : Subscribe mqtt
----------------------------------------------
/ais/
----------------------------------------------
192.168.100.21
1884
------------------------------------------------
Creating node-red dashboard : Add function node
------------------------------------------------
var n = msg.payload.Result
msg.new = n.length
var i;
for (i = 0; i < n.length; i++) {
if(msg.payload.Result[i].type === "hand"){
msg.payload = "Violation" ;
msg.color = 'red'
msg.icon="font-awesome/fa-automobile"
msg.img = "red.jpeg"
return msg;
}else if (msg.payload.Result[i].type=== "glove" )
{
msg.payload = "Safe" ;
msg.color= 'green'
msg.img = "Green.jpeg"
msg.icon="font-awesome/fa-automobile"
return msg;
}else if (msg.payload.Result[i].type=== "dot" )
{
msg.payload = "Glove defect" ;
msg.color= 'red'
msg.img = "red.jpeg"
msg.icon="font-awesome/fa-automobile"
return msg;
}
}
------------------------------------------------
Creating node-red dashboard : Display message
------------------------------------------------
{{msg.payload}}
----------------------------------------------------
Creating node-red dashboard : Add image as indicator
----------------------------------------------------
----------------------------------------------------
Creating node-red dashboard : Trigger actuator
----------------------------------------------------
Modbus slave simulator download link : https://www.modbusdriver.com/diagslave.html
----------------------------------------------------
cd diagslave/
sudo linux_x86-64/diagslave -m tcp
-----------------------------------------------------
if (msg.payload === "Violation"){
msg.payload = "100";
return msg
}
------------------------------
Data storage:store DATA to CSV
------------------------------
if (msg.payload === "Violation"){
var currentDate = new Date();
msg.payload = currentDate + " " + "Violation";
return msg
}
/home/ais/Desktop/Storage/Result.csv