# Log Volume Measurement and Counting Based on Improved Cascade Mask R-CNN and Deep SORT
## 4 Results
### Log Volume Calculation  
We conducted field measurements of logs, the image of which is shown in Figure 10. Initially, we utilized a binocular stereo camera to capture images of log ends and depth information. Subsequently, we employed an improved Cascade Mask R-CNN model to detect the log ends and derive the contour mask. Next, we applied the improved long and short diameter search algorithm [40] to the mask to calculate the long and short diameters of the log end. The outcomes are presented in Figure 11, where the two perpendicular lines correspond to the long and short diameters of the log. It is important to note that the long and short diameters obtained now are represented in pixel values. Subsequently, the pixel values for the short and long diameters are converted into actual measurements by incorporating the depth information provided by the binocular stereo camera. The diameter and volume of the log end are then calculated sequentially according to the Chinese Log Measurement Standards GB/T 144-2013 [41] and GB/T 4814-2013 [42], respectively. The calculation processes for diameter, log grading, and volume are illustrated in Formulas (11)-(13), respectively. For logs shorter than 14 cm, standard rounding is applied. For logs greater than 14 cm, even numbers are rounded down while odd numbers are rounded up. This process is referred to as log grading. In the formula, \(d_{s}\) represents the short diameter, \(d_{l}\) stands for the long diameter, L denotes the length of the log measured in meters (m), D signifies the diameter of the log measured in centimeters (cm), and V is the volume measured in cubic meters m\({}^{3}\). The calculation standards for log volumes vary across different countries and regions due to definitions, industrial needs, wood utilization efficiency, and irregular shapes. Therefore, China's log inspection standards use a formula (Equation (13)) that differs from conventional cylindrical volume calculations. \[D=\left\{ \begin{array}{ll}d_{s}&(d_{l}-d_{s})\leq 2\\ (d_{l}+d_{s})/2&(d_{l}-d_{s})>2\end{array} \right. \tag{11}\]  
Figure 11: Short and long diameter search results, where the two straight lines represent the short and long diameters, respectively. Figure 10: Log stacks in outdoor scenes for log tracking counting and volume measurement experiments. \[R(D)=\left\{\begin{array}{ll} \begin{array}{ll}\lfloor D\rfloor&\text{if $D\%2<1$ and $D\geq 14$}\\ \lfloor D\rfloor+1&\text{if $D\%2\geq 1\ D\geq 14$}\\ \lfloor D+0.5\rfloor&\text{if $D<14$}\end{array} \right. \tag{12}\]  
\[V=0.8L(R(D)+0.5L)^{2}/10000 \tag{13}\]  
Our log volume measurements are detailed in Table 4. In this table, \"Length\" refers to the length of the logs in meters. The abbreviations \"M_Short\" and \"M_Long\" denote the manually measured short and long diameters in centimeters, respectively. In contrast, \"D_Short\" and \"D_Long\" represent the short and long diameters obtained through our proposed automated method, also measured in centimeters. Additionally, \"M_Dia\" and \"D_Dia\" indicate log diameter calculations based on Chinese log inspection standards, where \"M_Dia\" represents manual measurements and \"D_Dia\" represents automated measurements, both in centimeters. The terms \"M_Vol\" and \"D_Vol\" signify the manually measured and method-calculated timber volumes in cubic meters. The \"Error\" column illustrates the volume measurement error for each log in cubic meters, with a negative value indicating that our proposed method produces a smaller volume measurement compared to manual measurements. Further details on measurement errors are provided in Table 5. We found a short diameter error of 0.86 cm and a long diameter error of 0.88 cm, which aligns closely with the results from our previous work [40]. The slight increase in error may be attributed to variations in lighting conditions. As shown in Table 4, a comparison of the manually measured volume with the volume automatically computed using our proposed method reveals an average error of 0.0008 m\({}^{3}\) and a percentage error of 4.07%.