# Greenhouse Ventilation Equipment Monitoring for Edge Computing
## 2 Methods
### Extracting Regions of Interest Based on Tracking  
In surveillance scenarios, as depicted in Figure 5, the targets usually occupy a minimal portion of the visual field. Processing the entire image for detection purposes incurs significant computational resource expenditure. Consequently, focusing on regions of interest within the image for detection can substantially mitigate computational demands when employing deep learning algorithms for target detection. Figure 4: Model Training Schematic. Methods for region extraction are categorized into two main approaches: those that employ deep learning techniques [17] and those that do not [18; 19]. Deep learning-based approaches are characterized by their high accuracy and ability to interpret scene content, albeit at the cost of significant computational resources. Alternatively, methods such as optical flow, edge detection, and template matching are employed for region extraction in a more resource-efficient manner. These techniques, however, necessitate the manual identification of certain features to generate region proposals. Given the frequent need for target tracking in continuous video frames within systems, employing such methodologies for the predictive positioning of targets in subsequent frames proves advantageous. By centering multiple rectangles on the predicted centers of identified objects, these methods effectively encapsulate areas of interest without imposing additional computational demands. The method's data flow, as illustrated in Figure 6, is depicted as follows: initially, the region extractor, utilizing the preceding frame's object tracking predictions, isolates images containing the object. Subsequently, a modified YOLOv7 algorithm detects each region, with the outputs amalgamated for comprehensive post-processing. Object tracking then correlates targets across frames, forecasting future positions to inform region extraction. The final step involves a classifier discerning the object's state from its embedding. In our context, fans exhibit two states: active and inactive. Experimental results demonstrate that the LSTM classifier suffices for accurate categorizations of state. For the target-tracking aspect, our approach refers to the SORT algorithm [20], employing Kalman filtering and Intersection over Union (IOU) matching for efficient tracking. SORT, renowned for its real-time performance and simplicity, is pivotal in multi-target-tracking scenarios. Its core principle revolves around utilizing Kalman filtering for modeling target velocity and position in video frames, followed by the application of the Hungarian algorithm to align predicted and detected values in subsequent frames. This methodology excels in minimizing mismatch errors and is characterized by low computational complexity, rendering it ideal for real-time applications. In our study, we utilize IoU-based matching, aligning positions and sizes predicted by the Kalman filter with those determined by the target detector. Figure 5: Fan monitoring in a greenhouse environment. Figure 6: Methodological data flow diagram. In our experiment, Kalman filtering accomplishes tracking by establishing a 6-dimensional state vector which includes the center coordinates (x, y), the dimensions (width, height) of the bounding box, and the velocity of center coordinate changes (\(\Delta\)x, \(\Delta\)y). This form allows for an effective representation of the target's dynamics, not just capturing its spatial positioning but also incorporating its movement speed, facilitating precise target tracking through sequential video frames. At the start of a tracking algorithm loop, the algorithm updates this vector using the state transition matrix to predict the positions of targets at that moment, in our case, by adding the last two dimensions to the first two dimensions. Subsequently, targets in consecutive frames are matched based on the CIOU. Finally, the state vector is updated using the matching results according to the Kalman filter's state update equation.