Wood volume measuring method, system, equipment and medium

By adding channel attention and VoVGSCSP modules to the YOLOv8 model, combined with camera parameter correction, the problem of large wood cross-section fitting errors in the existing technology is solved, and accurate measurement of wood volume is achieved.

CN119338891AInactive Publication Date: 2025-01-21ZHAOQING UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411370638.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2025-01-21
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the prior art, it is necessary to fit irregular wood cross-sectional profiles into regular shapes, resulting in large errors in volume calculations.

Method used

By adding two layers of channel attention to the YOLOv8 backbone network and replacing the C2F module in the neck with the VoVGSCSP module, an optimized YOLOv8 model is constructed for identifying wood cross-section areas. Then, the internal and external parameters of the camera and the lens distortion coefficient are used for correction, the actual area of ​​each pixel is obtained, the actual area of ​​the wood cross-section area is counted and calculated, and finally the wood volume is obtained based on the actual area and the length of the wood.

Benefits of technology

The wood cross-section area is accurately identified through the recognition model, which avoids fitting errors and achieves accurate measurement of wood volume.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119338891A_ABST
    Figure CN119338891A_ABST
Patent Text Reader

Abstract

The invention discloses a wood volume measuring method, system, equipment and medium, and relates to the technical field of wood volume automatic calculation, and the method comprises the steps: adding two layers of channel attention in a YOLOv8 backbone network, replacing a C2F module in a YOLOv8 neck with a VoVGSCSP module, so as to construct an optimized YOLOv8 model; the optimized YOLOv8 model is trained, and a recognition model used for recognizing the wood section is obtained; shooting a wood section image of to-be-detected wood and inputting the identification model to identify a wood section area; correcting radial distortion and tangential distortion of the wood section area according to internal and external parameters of the camera and a lens distortion coefficient; acquiring an actual area corresponding to the area of each pixel according to the pixel resolution of the camera, counting the pixel number of the corrected wood section area, and acquiring the actual area of the wood section area; and obtaining the wood volume according to the actual area and the wood length. According to the method, the irregular section contour can be identified to obtain the accurate wood volume.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of automatic calculation of wood volume, and in particular to a method, system, equipment and medium for measuring wood volume. Background Art

[0002] Wood has very important utilization value in human life. Forest farms usually need to calculate the volume of the wood when they stack the collected wood.

[0003] In the prior art, method one is a wood volume calculation method based on image processing, which mainly obtains the edge of the wood cross section by processing the neatly arranged wood images, and then performs circle or ellipse fitting on the edge to obtain the wood diameter and area. After measuring the length of the wood, the wood volume can be obtained; method two is to use the deep learning framework Mask-RCNN to segment the wood, and then perform edge fitting to obtain the wood diameter and area, and finally obtain the wood volume after measuring the length of the wood.

[0004] However, the above method needs to fit the irregular wood cross-sectional contour edge into a regular shape, so that there is an error between the actual cross-sectional area and the area of ​​the regular shape after fitting, which ultimately leads to a larger error in the obtained wood volume. Summary of the invention

[0005] The embodiments of the present invention provide a method, system, device and medium for measuring the volume of wood, which can solve the problem in the prior art that the irregular cross-sectional profile of wood needs to be fitted into a regular shape, resulting in large errors in the obtained volume.

[0006] The embodiment of the present invention provides a method for measuring the volume of wood, comprising the following steps: using a camera to shoot a wood cross-section image and marking the cross-section contour; obtaining internal and external parameters of the camera and a lens distortion coefficient; adding two layers of channel attention to a YOLOv8 backbone network, replacing a C2F module in a YOLOv8 neck with a VoVGSCSP module to construct an optimized YOLOv8 model; training the optimized YOLOv8 model to obtain a recognition model for identifying the wood cross-section; shooting a wood cross-section image of a wood to be measured and inputting the recognition model to identify the wood cross-section area; correcting radial distortion and tangential distortion of the wood cross-section area according to the internal and external parameters of the camera and the lens distortion coefficient; obtaining the actual area corresponding to the area of ​​each pixel according to the camera pixel resolution, counting the number of pixels in the corrected wood cross-section area and obtaining the actual area of ​​the wood cross-section area; and obtaining the wood volume according to the actual area and the length of the wood.

[0007] Furthermore, two layers of channel attention are added to the YOLOv8 backbone network, and the specific steps include: in YOLOv8, the first layer of channel attention assigns different weights to the three RGB channels so that the important channels in the RGB channels receive higher attention; the second layer of channel attention uses a 1×1 convolution kernel to convert the 3-channel feature map into an 8-channel feature map, and the 8-channel feature map is input into a fully connected network containing 48 hidden layer neurons to distribute weights according to the feature importance of the 8 channels.

[0008] Furthermore, the method of photographing a wood cross-section image of the wood to be tested and inputting it into a recognition model to identify the wood cross-section area specifically includes the following steps: photographing a wood cross-section image of the wood to be tested; extracting wood cross-section image features through a backbone network including two layers of channel attention to obtain image features; performing feature fusion on the image features through a neck including a VoVGSCSP module; and predicting a result of the feature fusion through a head to identify the wood cross-section area.

[0009] Furthermore, the method of using a camera to capture wood cross-sectional images and marking the cross-sectional contour includes the following specific steps: using a camera to capture one hundred wood cross-sectional images; using Gaussian noise, salt and pepper noise, upside down flipping, left-right flipping, and 90° rotation methods to enhance the cross-sectional images; and marking the cross-sectional contour of the enhanced cross-sectional images.

[0010] Furthermore, the obtaining of the internal and external parameters and lens distortion coefficient of the camera specifically includes: calibrating the camera using a checkerboard method, and pasting the checkerboard on a wood cross section to obtain the lens distortion coefficient and camera resolution that cause image distortion in the camera.

[0011] An embodiment of the present invention provides a system for measuring wood volume, comprising:

[0012] The data acquisition module is used to take a cross-sectional image of the wood using a camera and mark the cross-sectional profile; obtain the internal and external parameters of the camera and the lens distortion coefficient;

[0013] A model optimization module is used to add two layers of channel attention to the YOLOv8 backbone network, replace the C2F module in the YOLOv8 neck with the VoVGSCSP module to build an optimized YOLOv8 model; train the optimized YOLOv8 model to obtain a recognition model for identifying wood cross sections;

[0014] The volume measurement module is used to take a wood cross-section image of the wood to be tested and input it into a recognition model to identify the wood cross-section area; correct the radial distortion and tangential distortion of the wood cross-section area according to the internal and external parameters of the camera and the lens distortion coefficient; obtain the actual area corresponding to the area of ​​each pixel according to the camera pixel resolution, count the number of pixels in the corrected wood cross-section area and obtain the actual area of ​​the wood cross-section area; and obtain the wood volume according to the actual area and the length of the wood.

[0015] An embodiment of the present invention provides a computer device, comprising: a memory and a processor; the memory stores a computer program, and the processor implements the above-mentioned method for measuring the volume of wood when executing the computer program.

[0016] An embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned method for measuring the volume of wood is implemented.

[0017] The embodiments of the present invention provide a method, system, device and medium for measuring the volume of wood. Compared with the prior art, the beneficial effects thereof are as follows:

[0018] The complete wood cross-sectional area is accurately identified through the recognition model. In order to accurately obtain the area of ​​the wood cross-sectional area, the actual area corresponding to the area of ​​each pixel is obtained according to the camera pixel resolution, the number of pixels in the wood cross-sectional area is counted and the actual area of ​​the wood cross-sectional area is obtained. There is no error caused by fitting irregular shapes into regular shapes. Finally, the accurate wood volume can be obtained according to the length of the wood. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 A flow chart for calculating the volume of wood provided by an embodiment of the present invention;

[0020] Figure 2 The RGB histogram of the wood cross section provided by the embodiment of the present invention;

[0021] Figure 3 A flow chart after adding channel attention provided by an embodiment of the present invention;

[0022] Figure 4 A structural diagram of the VoVGSCSP module provided by an embodiment of the present invention;

[0023] Figure 5 The optimized YOLOv8 structure diagram provided by the embodiment of the present invention;

[0024] Figure 6The optimized YOLOv8 wood segmentation effect diagram provided in the embodiment of the present invention, wherein (a) is a wood segmentation effect diagram piled on the ground, and (b) is a wood segmentation effect diagram piled on a vehicle. DETAILED DESCRIPTION

[0025] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present invention, so the present invention is not limited by the specific embodiments disclosed below.

[0026] See also Figure 1 to Figure 6 The present invention provides a method for measuring the volume of wood, comprising the following steps:

[0027] Step 1: Collect a wood cross-sectional image with a marked cross-sectional profile; use a camera to shoot the cross-sectional images of the front and rear ends of the wood to obtain the cross-sectional images, and obtain the internal and external parameters of the camera and the lens distortion coefficient.

[0028] Step 2: Add two layers of channel attention to the YOLOv8 backbone network, replace the C2F module in the YOLOv8 neck with the VoVGSCSP module for improving feature extraction and fusion functions to build an optimized YOLOv8 model; use the wood cross-section image set to train the optimized YOLOv8 model to obtain a recognition model.

[0029] Step 3: Take a cross-sectional image of the wood to be tested and input it into the recognition model to identify the cross-sectional area of ​​the wood; correct the radial distortion and tangential distortion of the cross-sectional area of ​​the wood according to the internal and external parameters of the camera and the lens distortion coefficient.

[0030] The correction mainly considers the radial distortion and tangential distortion of the lens. The correction formula is as follows:

[0031]

[0032]

[0033] Among them, k1, k2 are radial distortion coefficients, p1, p2 are tangential distortion coefficients, and x d ,y d is the coordinate before correction, x p ,y p are the corrected coordinates.

[0034] Step 4: Obtain the actual area corresponding to the area of ​​each pixel according to the camera pixel resolution, count the number of pixels in the corrected wood cross-sectional area and obtain the actual area of ​​the wood cross-sectional area; obtain the wood volume according to the actual area and the length of the wood.

[0035] 100 wood cross-section images were collected, and the wood contours were marked using the image annotation tool Labelme software. Salt and pepper noise, Gaussian noise, upside-down flipping, left-right flipping, and 90-degree rotation were added to the marked images to enhance the dataset.

[0036] The YOLOV8 module is optimized. The YOLOV8 structure can be divided into the backbone network, the neck network and the detection layer. The backbone network is divided into three parts.

[0037] Optimization 1:

[0038] from Figure 2 The RGB histogram of the wood cross section shows that the red channel wood cross section pixels are more obvious. In order to better focus on the channels with more obvious wood cross sections, a channel attention module is added to the first stage of the YOLOV8 backbone network. The process is as follows:

[0039] (1) First, the three-channel feature map of size 3×H×W is compressed to 3×1×1 through average pooling.

[0040] (2) A full connection and a ReLU activation function are used to upgrade the compressed three-channel feature map to a size of 48×1×1, which increases the number of channels by 16 times.

[0041] (3) Then, a full connection is used to restore the 48 channels to 3 channels, and the three-channel weight coefficients, i.e., the three-channel attention weight coefficients, are generated through the sigmoid function.

[0042] (4) Multiply the three-channel attention weights obtained in the previous step by the original input feature map to obtain the enhanced RGB channel features.

[0043] (5) Use the sigmo id function to perform nonlinear enhancement on the enhanced RGB channel feature map.

[0044] (6) Perform batch normalization on the original RGB channel feature map of the image.

[0045] (7) Use a 1×1 convolution kernel to perform a convolution operation to convert the feature map of the previous step into eight channels, and then repeat steps (1) to (5).

[0046] Optimization 2:

[0047] The YOLO framework uses a large number of C2F modules to achieve feature fusion. The C2F module has less computational complexity but the effect is not optimal. In order to obtain better feature fusion effect and minimize the increase in computational complexity, the YOLOV8 neck C2F module is replaced with the VoVGSCSP module to achieve information fusion between the feature maps of the three stages of the backbone network.

[0048] The VoVGSCSP module is mainly composed of GSConv (Group Shuffle Convolution), which is obtained by mixing standard convolution SC and channel-separable convolution DWConv (Depth-wise separable Convolution).

[0049] GSConv can both lighten the model and maintain accuracy. The steps are as follows:

[0050] (1) Standard convolution operation: Perform a standard convolution operation on the input feature map to obtain a feature map with half the number of channels of the target feature map.

[0051] (2) Depthwise separable convolution operation: Perform a depthwise separable convolution operation on the result obtained in the previous step to obtain a feature map with half the number of channels of the target feature map.

[0052] (3) Concatenation operation: The above two feature maps are merged through the concat operation to obtain a concatenated feature map with the same number of channels as the target feature map.

[0053] (4) Channel shuffling operation: Finally, the target feature map is obtained through the channel shuffling operation.

[0054] The structure of the VoVGSCSP module is as follows Figure 4 As shown, the steps are as follows:

[0055] (1) Standard convolution operation: Perform a standard convolution operation on the input feature map to obtain a feature map with half the number of channels of the target feature map.

[0056] (2) GSConv operation: The GSConv operation is performed on the result obtained in the previous step, and the number of feature map channels remains unchanged.

[0057] (3) GSConv operation: Perform the GSConv operation again to obtain a feature map with half the number of channels of the target feature map.

[0058] (4) Concatenation operation: Concatenate the feature maps of the second and third steps together to obtain a feature map with the same number of channels as the target feature map.

[0059] (5) Standard convolution: Perform standard convolution without changing the number of channels to obtain the final target feature map.

[0060] For model training, the dataset is divided into training set, validation set and test set in the ratio of 8:1:1. The training rounds are set to 2000, the number of images in each batch is 10, the optimization method is SGD, and the other training parameters use the default values. The best model after training is the wood cross-section recognition model.

[0061] Use two cameras to capture cross-sectional images of both sides of the stacked wood; set the wood cross-sectional detection confidence level to 0.5, and obtain the segmented and annotated images, as shown in the figure below: Figure 6 shown.

[0062] The checkerboard method is used to calibrate the image to obtain the internal and external parameters of the camera. The segmented and labeled image is corrected according to the internal and external parameters of the camera to obtain the corrected image.

[0063] The corresponding relationship between the pixel area and the actual area is obtained according to the camera resolution; the pixel area of ​​the marked area is calculated and the actual area is calculated according to the calibration parameters.

[0064] After obtaining the two cross-sectional areas and length of the wood, calculate the volume using the cylinder calculation formula.

[0065] An embodiment of the present invention provides a system for measuring wood volume, comprising:

[0066] The data acquisition module is used to use a camera to capture a wood cross-section image and mark the cross-section contour; and obtain the internal and external parameters of the camera and the lens distortion coefficient.

[0067] A model optimization module is used to add two layers of channel attention to the YOLOv8 backbone network, replace the C2F module in the YOLOv8 neck with the VoVGSCSP module to build an optimized YOLOv8 model; train the optimized YOLOv8 model to obtain a recognition model for identifying wood cross sections.

[0068] The volume measurement module is used to take a wood cross-section image of the wood to be tested and input it into a recognition model to identify the wood cross-section area; correct the radial distortion and tangential distortion of the wood cross-section area according to the internal and external parameters of the camera and the lens distortion coefficient; obtain the actual area corresponding to the area of ​​each pixel according to the camera pixel resolution, count the number of pixels in the corrected wood cross-section area and obtain the actual area of ​​the wood cross-section area; and obtain the wood volume according to the actual area and the length of the wood.

[0069] An embodiment of the present invention provides a computer device, comprising: a memory and a processor; the memory stores a computer program, and the processor implements the steps of a method for measuring the volume of wood when executing the computer program.

[0070] An embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of a method for measuring the volume of wood are implemented.

[0071] A specific embodiment is as follows:

[0072] Step 1: Collect 100 wood cross-section images, use Labelme software to annotate the wood polygon contours, and add salt and pepper noise, Gaussian noise, upside down flip, left-right flip, and 90-degree rotation to the annotated images to enhance the data set.

[0073] Step 2: Optimize the YOLOV8 model.

[0074] Step 3: Model training. Divide the data set into training set, validation set and test set in a ratio of 8:1:1. Set the training rounds to 2000, the number of images per batch to 10, the optimization method to SGD, and the default values ​​for other training parameters. The best model after training is the wood cross-section recognition model.

[0075] Step 4: Use two cameras to capture cross-sectional images on both sides of the stacked wood, ensuring that the camera is facing the wood cross section; use the wood cross section recognition model obtained above to detect the wood cross section, set the wood cross section detection confidence to 0.5, obtain the target detection image, and mark the detected target with a special color.

[0076] Step 5: Use the checkerboard calibration image to obtain the camera's internal and external parameters and distortion parameters.

[0077] Step 6: Obtain the calibration relationship between the pixel area and the actual area based on the camera resolution; count the number of pixels in the target area of ​​a specific color in the annotated and calibrated image, which can be regarded as the area of ​​the target area, and then convert the pixel area into the actual area based on the calibration parameters.

[0078] Step 7: After obtaining the two cross-sectional areas and lengths of the wood, calculate the volume using the cylinder calculation formula.

[0079] The above-mentioned embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.

Claims

1. A method for measuring the volume of wood, characterized in that: The following steps are involved: Use a camera to capture a wood cross-section image and mark the cross-section profile; obtain the camera's internal and external parameters and lens distortion coefficient; Add two layers of channel attention to the YOLOv8 backbone network, replace the C2F module in the YOLOv8 neck with the VoVGSCSP module to build an optimized YOLOv8 model; train the optimized YOLOv8 model to obtain a recognition model for identifying wood cross sections; Taking a wood cross-section image of the wood to be tested and inputting it into a recognition model to identify the wood cross-section area; correcting the radial distortion and tangential distortion of the wood cross-section area according to the internal and external parameters of the camera and the lens distortion coefficient; The actual area corresponding to the area of ​​each pixel is obtained according to the camera pixel resolution, the number of pixels in the corrected wood cross-sectional area is counted and the actual area of ​​the wood cross-sectional area is obtained; the wood volume is obtained according to the actual area and the length of the wood.

2. A method for measuring the volume of wood according to claim 1, characterized in that: The two-layer channel attention is added to the YOLOv8 backbone network. The specific steps include: In YOLOv8, the first layer of channel attention assigns different weights to the three RGB channels so that the important channels in the RGB channel receive higher attention; The second layer of channel attention uses a 1×1 convolution kernel to convert the 3-channel feature map into an 8-channel feature map, which is then input into a fully connected network containing 48 hidden neurons to assign weights according to the importance of the features of the 8 channels.

3. The method for measuring the volume of wood according to claim 1, characterized in that: The steps of taking a wood cross-section image of the wood to be tested and inputting it into a recognition model to identify the wood cross-section area include: Taking a wood cross-section image of the wood to be tested; The image features of the wood cross-section image are extracted through a backbone network containing two layers of channel attention to obtain image features; The image features are fused through the neck containing the VoVGSCSP module; The result of feature fusion is predicted by the head to identify the wood cross-section area.

4. A method for measuring the volume of wood as claimed in claim 1, characterized in that: The specific steps of using a camera to capture a wood cross-section image and mark the cross-section profile include: A camera was used to take one hundred images of the wood cross section; The cross-sectional images were enhanced using Gaussian noise, salt and pepper noise, upside down flipping, left-right flipping, and 90° rotation. Mark the section contour on the enhanced section image.

5. The method for measuring the volume of wood according to claim 1, characterized in that: The obtaining of the internal and external parameters of the camera and the lens distortion coefficient specifically includes: The camera was calibrated using the chessboard method, and the chessboard was pasted on the wood section to obtain the lens distortion coefficient and camera resolution that caused image distortion in the camera.

6. A system for measuring the volume of wood, characterized in that: include: A data acquisition module, used for taking a cross-section image of the wood using a camera and marking the cross-section profile; Get the internal and external parameters of the camera and the lens distortion coefficient; A model optimization module is used to add two layers of channel attention to the YOLOv8 backbone network, replace the C2F module in the YOLOv8 neck with the VoVGSCSP module to build an optimized YOLOv8 model; train the optimized YOLOv8 model to obtain a recognition model for identifying wood cross sections; The volume measurement module is used to take a wood cross-section image of the wood to be tested and input it into a recognition model to identify the wood cross-section area; correct the radial distortion and tangential distortion of the wood cross-section area according to the internal and external parameters of the camera and the lens distortion coefficient; obtain the actual area corresponding to the area of ​​each pixel according to the camera pixel resolution, count the number of pixels in the corrected wood cross-section area and obtain the actual area of ​​the wood cross-section area; and obtain the wood volume according to the actual area and the length of the wood.

7. A computer device comprising: Memory and processor; The memory stores a computer program, wherein the processor implements a method for measuring the volume of wood according to any one of claims 1 to 5 when executing the computer program.

8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, a method for measuring the volume of wood according to any one of claims 1 to 5 is implemented.