# Internet of Things Meets Computer Vision to Make an Intelligent Pest Monitoring Network
## 3 Proposed Approach
### IoT Network  
As depicted in Figure 6, we developed a star topology network with cameras (at the edge) placed in crops, the backend centralised in a private cloud, a pest monitoring application for the users obtain insights, and all communications using the HTTP protocol. The chosen architecture (star topology) allowed the development of a very efficient and inexpensive network. Furthermore, this type of topology allows us to easily scale the network to other crops just by adding new edge devices. The cameras used at the edge (ESP32-CAM), although low cost, allow the obtaining of images with enough quality to not influence the performance of the CV models.  
If we had used the fog layer, the cost would have increased significantly; each crop would need a fog device and solar panels to power them. The goal of this system is not to obtain images in real-time, so the lower latency of the fog (over the cloud) was not a decision factor. Another advantage of fog that was not important to us was the mobility of its devices, as we wanted to leave the devices in the same location for a long time (the most autonomous possible). However, introducing a fog layer could be a good solution for cultures without internet access or if the backend is on a public cloud.  
The chosen communication protocol (HTTP) allowed us to send the images to the cloud without the payload size restriction that MQTT sometimes has when dealing with images. HTTP power consumption was not an issue because each edge node sent only a daily image to the cloud to perform daily monitoring). HTTP memory consumption was not a constraint, as we did not send high resolution images. However, the use of MQTT would result in a lower memory and energy consumption, but as this protocol was developed to send small amounts of data, the size of the images would have to be reduced to have viable transfers. As MQTT was designed to be lightweight, it does not use a security mechanism for data transmission. In that case, we would have to implement, for instance, Transport Layer Security (TLS), to guarantee the encryption of the transmitted images.  
Using the application for automatic monitoring, the user only needs to visualise the graph with the daily evolution of the pest in order to choose which intervention to take. Nevertheless, this limits the monitoring to available nodes at the edge. With that in mind, we introduced a feature for the user to use their phone's camera to take a picture of a trap. With that, he can point the camera at any yellow sticky trap and is not limited to the ones  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Metric** & **Faster R-CNN** & \begin{tabular}{c} **YOLOv5** \\ **(Small)** \\ \end{tabular} & \
\begin{tabular}{c} **YOLOv5** \\ **(XLarge)** \\ \end{tabular} &
\begin{tabular}{c} **Scaled-YOLOv4** \\ **(Large)** \\ \end{tabular} \\ \hline \hline mAP (\%) & 76.15 & 81.20 & **89.70** & 82.50 \\ \hline Memory (MB) & 244 & **14** & 167 & 101 \\ \hline Average Time (S) & 1.5 & **0.01** & 0.13 & 0.03 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Computer Vision models performance.  
Figure 6: Proposed IoT network.  
at the edge. However, this changes how images are obtained and introduces the possibility of human error, which can influence the performance of CV models.  
The next subsections describe the edge and cloud of the IoT network and show part of the application.