## 2 IoT System Description
### Software: NN-Based and SPF Algorithms for Emergency Management and Social Distancing  
The framework of the proposed IoT system is depicted in Figure 3. In particular, the system includes the WSN (which was described in the previous section and is represented by box 1 in Figure 3) and a procedure, consisting in several steps (represented by boxes 2 to 13 in Figure 3), which allows one to analyze the data that come from the WSN (i.e., sensing nodes and cameras). The sensing nodes of the WSN (see box 1 in Figure 3) gather data from the environment using their sensors, while the Wi-Fi cameras detect the people's position in a given area. Sensing nodes and cameras are fed by a photovoltaic-based power supply system. The aforementioned data are sent, with a proper timing (e.g., every five minutes), to a local server (see box 2 in Figure 3) for analysis/backup purposes. At the same time, the IoT board converts the collected data to text strings (JSON format) and sends the converted data to a web server (see box 3 in Figure 3) using the MQTT protocol (e.g., the MQTT broker Eclipse Mosquito(tm)) for backup purposes. Note that, sampling and data transmission frequencies are defined so as to minimize the transmission cost, latency, network bandwidth, and resource requirements, and to increase data privacy and data transfer reliability. The data stored in the web local server can be accessed by an authorized customer of the system (i.e., subscribing to a specific topic) for further analyses, while the data stored in the local server are analyzed as follows using three different algorithms (see boxes 4-6 in Figure 3). Figure 2: (**a**) Map of the theme park where the WSN was installed and three self-powered wireless sensing nodes installed on (**b**) a road pavement, (**c**) a masonry structure, and (**d**) a light pole in the park. The first algorithm (Algorithm 1, represented in box 4 in Figure 3) is used to process the data that come from the cameras using computer vision to define the spatiotemporal distribution of the people in each area and trigger the overcrowding alarm (if people in a given area exceed a predefined threshold). Hence, Algorithm 1 can be used as an automatic tool when the social distancing measure must be respected or to limit the access to a given area, avoiding overcrowding. In more detail (cf. Table 3), this algorithm uses object detection frameworks to classify and locate objects in a visual field. Facial detection would take an image input of some kind, check for the person or face class of the objects, and locate them in the frame. Additionally, facial recognition would pick out eyes, mouths, and various other features to compare them to a known dataset. The applications detect humans in the visual field via processing blocks pre-trained by crunching a huge number of images with a deep learning artificial intelligence system. The extracted features, as the number of humans and the direction of the people flow, are used in the following to determine the spatiotemporal distribution. The second algorithm (Algorithm 2; see box 5 in Figure 3) is used to process the raw data from the sensors (cf. Table 4). In particular, raw data are preprocessed in order to extract meaningful features (i.e., statistical indicators such as maximum, minimum, average, root mean square, etc. ), which are used as input in a NN for clustering purposes. This NN is used to identify the occurrence of one or  
Figure 3: Framework of the proposed IoT system. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Scopes** & **Input** & **Output** & **Steps** \\ \hline Count the number of & \(\bullet\) & Video stream from & \(\bullet\) \\ people entering and & cameras installed at & & - \\ leaving a given area & strategic points of & leaving a & - \\ using data from cameras. & the theme park. & given area. & - \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Main characteristics of the Algorithm #1.  
more environmental and/or structural alarms detected by one or more sensing nodes of the WSN.