# Log Volume Measurement and Counting Based on Improved Cascade Mask R-CNN and Deep SORT
## 5 Discussion  
In this paper, we demonstrated the improved performance of the modified Cascade Mask R-CNN in detecting log ends. Furthermore, by combining it with the Deep SORT model, we successfully tracked and counted the log ends. As a result, we calculated the log volumes with an error of 4.07%. The quality of feature extraction by the backbone network is directly linked to the subsequent network's performance. A strong backbone network can efficiently capture vital information from the input data and relay it to the subsequent task networks, resulting in more valuable features for the model and better detection and segmentation performance. To verify the effectiveness of our backbone network improvement, we conducted a comparative analysis against well-established instance segmentation models, including CondInst [43], SOLOV2 [44], and Boxinst [45]. The comparative results are presented in Table 6. The results show that our model outperforms all other models, achieving the _AP_ score of 82.3, _AP\({}_{s}\)_ score of 75.3, _AP\({}_{m}\)_ score of 70.9, and _AP\({}_{l}\)_ score of 86.2. Additionally, we compared our approach with methods from the literature [11; 28]. The method in reference [11] employs the YOLOV8 to detect log end bounding box. We used the YOLOV8 instance segmentation model to segment the logs, and the results are shown in Table 6. Although YOLOV8 offers fast detection as a single-stage instance segmentation model, its accuracy is insufficient for precise calculation of log end volume. The method in reference [28], using PAFPN and RES2 Net models, also failed to perform well on our more complex dataset, yielding suboptimal results. These results underscore our improved segmentation model's effectiveness in precisely segmenting log ends of different sizes. The tracking and counting accuracy of Deep SORT is influenced by two key factors. First, it depends on the accuracy of the object detection model. The false and missed detection rates of the object detection model directly impact the performance of the Deep SORT model, as illustrated in Figure 9. This issue can be addressed through various optimizations to the object detection model. Secondly, there is the issue of \"ID jump\", which occurs when the unique identifier (ID) of an object experiences a sudden discontinuous change between consecutive frames, rather than being assigned sequentially. During our log tracking experiments, we observed that, when new objects appeared, IDs were not assigned in sequence, leading to discrepancies in log counting and resulting in counts that exceeded the actual number. This problem may arise from limitations in the algorithm itself or from object tracking crossovers. To mitigate this issue, we implemented an ID dictionary within the Deep SORT algorithm to record and distribute IDs sequentially, effectively addressing the challenges encountered in this study. Other studies have explored alternative solutions; for instance, [PERSON] [46] designed a mask collision line matching mechanism, and [PERSON] [47] utilized random simulation occlusion to enhance tracking performance. Given that log tracking demands a high level of counting accuracy, we plan to explore additional methods to rectify the ID jumping problem in future studies. Previous studies have explored the automated calculation of log volume using object detection algorithms. For instance, [PERSON] et al. [27] employed Mask R-CNN to segment log ends and subsequently calculate log volume, achieving an error of 4.5%, which closely aligns with our own error rate of 4.07%. Similarly, [PERSON] proposed an improved Wood Mask