# Log Volume Measurement and Counting Based on Improved Cascade Mask R-CNN and Deep SORT
## 1 Introduction  
Forests are vital for maintaining the ecological environment and supplying important timber resources. Wood, a key component of forests, has numerous applications, including furniture manufacturing, construction, and papermaking. As a fundamental raw material, wood is essential for daily life and various industries. Currently, existing methods are labor-intensive and lack accuracy and efficiency [1]. This significantly raises the risk of timber resource wastage. Additionally, accurate and efficient log volume measurement is advantageous for the timber industry [2]. Consequently, automated log volume measurement technology can enhance the effective use of timber resources, support forest conservation efforts, and boost the economic benefits of the timber industry. The key to measuring log volume lies in detecting log ends. Traditional log end detection methods can be divided into two main categories: those that utilize image color information and those that rely on feature extraction. The color information-based approach typically involves techniques such as color space conversion and image grayscaling. For example, [PERSON] uses color information and geometric operators across multiple color spaces to segment images, employing the Circular Hough Transform (CHT) [3] algorithm for the automatic detection and counting of wood logs [4]. In contrast, [PERSON] focuses on grayscale variation, image binarization, and a hole-filling algorithm to extract log end contours from color images, subsequently using the Hough circle transform to measure the diameters ofthe log ends [5]. However, these methods are highly sensitive to variations in lighting and noise, leading to degraded performance in images with uneven illumination or significant noise. On the other hand, feature extraction methods primarily utilize Histograms of Oriented Gradients (HOGs) [6]. [PERSON] introduced a log edge detection algorithm that combines HOGs with Local Binary Patterns (LBPs) [7], while [PERSON] integrates HOGs with random decision forests for log detection [8]. These methods perform well with clear, unobstructed images. However, they may struggle with scenes containing overlaps or occlusions, making accurate segmentation difficult. To overcome this challenge, [PERSON] incorporated the Graph-cut algorithm for log segmentation, integrating the CHT and the Local Circularity Measure (LCM) [9] to determine weights for the Graph-cut algorithm, resulting in more stable segmentation outcomes [10]. With the development of deep learning, researchers have increasingly integrated object detection models into the automation of log measurements, significantly improving both the efficiency and accuracy of these processes [11; 12; 13]. Object detection models are primarily categorized into two types: bounding box-based methods, such as You Only Look Once (YOLO) [14] and Single Shot MultiBox Detector (SSD) [15], and mask-based methods, including the Mask Region-based Convolutional Neural Network (Mask R-CNN) [16]. For instance, [PERSON] utilized the YOLO algorithm for detecting log ends on trucks and employed Direct Linear Transformation (DLT) to estimate the size of these sections, achieving an error margin of less than 4 cm [17]. To improve the detection of small log ends, [PERSON] integrated a Squeeze Excitation (SE)-based self-attention mechanism and spatial pyramid pooling (SPP) [18] into the YOLOv4-Tiny network. By using K-median clustering to select more suitable multiscale anchor boxes, [PERSON] achieved accuracies of 91.87%, 94.91%, and an F1 score of 0.93 [19]. Similarly, [PERSON] combined a Bidirectional Feature Pyramid Network (BiFPN) [20] with YOLOv5s to yield positive results in detecting small log ends, realizing improvements of 20.96% in detection recall and 21.13% in average precision compared to the original model [21]. Additionally, [PERSON] developed an automatic wood diameter grading sorting system utilizing the YOLOv5-SEG model and binocular cameras for precise measurements, achieving errors of less than 5 mm [22].