Automatic wood quality detection method and system based on image recognition

By using an image recognition-based automated inspection method, combined with compressed sensing and the sequence modeling framework Mamba, the limitations of traditional wood inspection speed and accuracy are solved, achieving efficient and accurate wood defect identification and classification, and adapting to the needs of industrial sites.

CN121027115APending Publication Date: 2025-11-28JIANGSU DONGSHENGHUI TECH DEV CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511255174.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-04
Publication Date
2025-11-28

AI Technical Summary

Technical Problem

Traditional timber quality testing methods rely on manual inspection, which limits speed and accuracy. Existing industrial testing systems are cumbersome and power-consuming, making it difficult to meet the needs of large-scale industrial production. Furthermore, the high cost of model calculation makes them difficult to deploy on edge devices.

Method used

An automated detection method based on image recognition is adopted, combined with compressed sensing and the sequence modeling framework Mamba. The feature extraction capability of the model is improved through sparse representation and feature reconstruction. An automatic supplementary lighting scheme and pipeline synchronous acquisition are designed. The ImprovedMobileMamba model is used for wood defect identification and classification.

Benefits of technology

It achieves high efficiency, accuracy, and stability in wood quality inspection, reduces computational complexity, improves inspection efficiency, adapts to various industrial site environments, and ensures rapid and accurate defect identification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121027115A_ABST
    Figure CN121027115A_ABST
Patent Text Reader

Abstract

The invention discloses an automatic wood quality detection method and system based on image recognition, and relates to the related field of the automatic detection technology of agricultural and forestry product quality and safety. The method detects the real-time position of wood on a production line, and when the wood reaches a preset shooting area, the brightness and angle of a light source are adjusted for automatic light supplement; a wood surface image is collected and preprocessed, and a wood surface detection area is highlighted; inputting the preprocessed wood surface image into a pre-trained wood defect detection model, and identifying and classifying wood surface defects; and according to a detection result output by the model, determining types and positions of wood surface defects, judging whether the wood is qualified or not, sending a control instruction, triggering and starting an eliminating device, and sorting out unqualified wood from a production line. The problems that an existing detection model is high in calculation cost and sensitive to a deployment environment are solved, the requirements for miniaturization integration and real-time response are met, and the precision and efficiency of quality detection are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of automatic detection technology for quality and safety of agricultural and forestry products, and particularly relates to an automatic wood quality detection method and system based on image recognition. BACKGROUND

[0002] Wood quality detection mainly refers to the process of evaluating and checking the physical, chemical and appearance characteristics of the wood surface, identifying and positioning the defects on the wood surface, and ensuring product quality. With the rapid development of modern technology, the wood processing industry has higher requirements for the automation and intelligence level of wood defect detection and grade classification, especially in application scenarios such as furniture manufacturing, floor laying and building assembly. Rapid identification and accurate classification of wood surface quality have become key links restricting production efficiency and product consistency.

[0003] Traditional wood quality detection methods rely on manual visual inspection and simple tool detection, and the detection speed and accuracy are limited by subjective factors of humans, which makes it difficult to quickly complete a large number of wood detection tasks and cannot meet the requirements of detection efficiency in large-scale industrial production. Existing industrial wood quality detection systems mainly use traditional visual detection methods combined with convolutional neural networks for image feature extraction and classification. Although this method has certain recognition ability, it generally has problems such as redundant equipment, high power consumption, high model calculation cost and sensitivity to deployment environment, which makes it difficult to meet the needs of edge device deployment, small-scale integration and real-time response in industrial sites. SUMMARY

[0004] In view of the problems of complex structure, data redundancy and response delay in the prior art, the present application provides an automatic wood quality detection method and system based on image recognition, which uses sparse representation and feature reconstruction in compressive sensing to compress wood images, reduce data dimension and redundant features. In addition, the sequence modeling framework Mamba is introduced, which improves the feature extraction capability of the model and improves the accuracy and stability of quality detection through an efficient linear dynamic mechanism.

[0005] The present application provides an automatic wood quality detection method based on image recognition, which comprises:

[0006] (1) detecting the real-time position of wood on the production line, adjusting the light source brightness and angle for automatic light compensation when the wood reaches the preset shooting area, and collecting the wood surface image;

[0007] (2) preprocessing the collected wood surface image, eliminating irrelevant background area, enhancing image contrast and highlighting the wood surface detection area;

[0008] (3) The pre-processed wood surface image is input into a pre-trained wood defect detection model based on ImprovedMobileMamba to identify and classify the wood surface defects;

[0009] (4) According to the detection results output by the model, the types and positions of the wood surface defects are determined, the area of the wood surface defects is measured, and whether the wood is qualified is determined according to a threshold value;

[0010] (5) The wood quality determination result is written into a database in real time, a control command is sent through an industrial communication interface, and a rejection device is triggered to start to sort out unqualified wood from the production line.

[0011] Further, in the wood surface image acquisition process, an automatic light supplementing scheme with high adaptability and configurability is designed, a combination of ring light and area light source is adopted, multi-spectral and infrared light sources are expanded, PWM dimming control and light intensity feedback algorithms are introduced, and the brightness and angle of the light source are dynamically adjusted to improve the overall brightness consistency of the image.

[0012] To ensure the accurate alignment of the image acquisition timing and the wood transmission position, avoid image blurring, target deviation and wood missing detection problems, a pipeline synchronous acquisition scheme is designed, photoelectric detection sensors, rotary encoders and programmable logic controllers are used to uniformly coordinate the camera acquisition, light source opening and closing and the running rhythm of the conveying line, and high automation is realized.

[0013] Further, the steps of pre-processing the collected wood surface image include image normalization, image cropping and image enhancement:

[0014] A linear normalization method is used to unify the image pixels to a fixed range, eliminate uneven lighting, sensor noise and dynamic range differences; an ROI-based image cropping method is used to remove the non-wood area in the wood surface image, reduce the calculation amount and focus on the defect detection area; a CLAHE (Contrast Limited Adaptive Histogram Equalization) method based on limited contrast is used to process the cropped wood surface image to enhance the details of the low-contrast defects on the wood surface and avoid the image overexposure problem caused by the global histogram equalization method.

[0015] Further, the wood defect detection model is based on the ImprovedMobileMamba framework, which solves the problems of low efficiency and excessive model parameter quantity of traditional lightweight visual models (convolutional neural networks and visual Transformers) in processing long-distance dependencies, uses the state space model in the Mamba structure to replace the attention mechanism, uses the linear complexity advantage to realize the lightweight design of the model, combines the characteristics of recursion, convolution and continuous time model, effectively simulates long-term dependencies, models infinite length context information, and improves the computing efficiency.

[0016] The state space model is a sequence modeling method based on state equation, which dynamically updates the hidden state of the input sequence, captures the cross-temporal and spatial dependency, and maps the input x(t) to the output y(t) through the hidden state h(t): h'(t) = Ah(t+1) + Bx(t), y(t) = Ch(t); where h'(t) is the updated hidden state, A represents the state transition matrix, which controls the evolution of the hidden state over time; B represents the input matrix, which maps the input to the state space and controls the influence of the input on the state; C represents the output matrix, which maps the current hidden state to the output, and determines how the state affects the final output;

[0017] Further, the state equation is discretized using the zero-order hold method for discrete systems, and the discretized state transition matrix and the input matrix are represented as:

[0018]

[0019] where Δ represents the discrete step size set in the zero-order holder, I is the identity matrix, and -1 represents the inverse matrix; the calculation process of the state space model in the discrete system is represented as:

[0020]

[0021] where x t , y t and h t represent the input, output and hidden state at time t in the discrete system; the process can be equivalent to convolution: l represents the sequence length of the state space model input, x and y represent the input and output of the model respectively, and * represents convolution.

[0022] ImprovedMobileMamba adopts a three-stage network, each stage containing a feature down-sampling layer and an ImprovedMobileMamba module, which reduces the feature resolution while extracting effective feature information for wood defect classification from the features. The multi-receptive field feature interaction module is the core part of the ImprovedMobileMamba module, which splits the input features and sends them into a three-branch structure to extract diversified information from the wood surface image features. The three-branch structure includes the following parts:

[0023] Compressed sensing enhanced bidirectional Mamba module (CS-Mamba): The compressed sensing method is introduced to enhance the extraction ability of high-frequency edge information while modeling the wood surface features globally through the state space model in Mamba.

[0024] High-efficiency multi-kernel deep separable convolution module (MK-DeConv): adopts deep separable convolution of multiple scales to extract local information of wood surface features in varying receptive fields, enhancing the model's perception of multi-scale receptive fields.

[0025] Redundancy elimination module: reduces feature redundancy in the high-dimensional space of wood surface features through identity mapping, thereby reducing the computational complexity of the model and improving processing speed.

[0026] The application also provides an automatic wood quality detection system based on image recognition, comprising:

[0027] Image acquisition module: used to detect the real-time position of wood on the production line, automatically adjust the brightness and angle of the light source for light compensation when the wood reaches the preset shooting area, and collect wood surface images;

[0028] Image preprocessing module: used to preprocess the collected wood surface images, eliminate irrelevant background areas, enhance image contrast, and highlight the wood surface detection area;

[0029] Surface defect recognition module: used to input the preprocessed wood surface images into the pre-trained wood defect detection model based on ImprovedMobileMamba, and recognize and classify wood surface defects;

[0030] Quality determination module: used to determine the type and location of wood surface defects based on the detection results output by the model, measure the area of wood surface defects, and determine whether the wood is qualified according to the threshold;

[0031] Unqualified product sorting module: used to write the wood quality determination results into the database in real time, send control instructions through the industrial communication interface, trigger the start of the rejection device, and sort out unqualified wood from the production line.

[0032] Further, to realize deep personalization of detection strategies and parameter linkage optimization, multiple intelligent parameter control modules are designed, including the following functions:

[0033] Introduce light perception algorithm to analyze wood surface color distribution, reflectance characteristics, defect visibility, and other indicators in real time, adjust the combination of camera exposure time, aperture value, and light compensation lamp brightness, and realize dynamic exposure and intelligent light source cooperative adjustment.

[0034] In cooperation with external sensing devices such as lasers, infrared photoelectric switches, encoders, and other external sensing devices of the pipeline synchronization system, intelligent sensor parameter adaptive control is realized. It supports intelligent adjustment of sensor sensitivity, trigger delay, signal threshold voltage, and other parameters to cope with different production speeds and changes in board size.

[0035] Through the fixed arrangement mode of multiple groups of cameras, multi-surface imaging is realized, and the top, side and bottom of the wood are fully covered for detection.

[0036] The built-in defect analysis module can accumulate image data in the continuous production cycle, analyze the defect type, frequency, regional heat map and time distribution trend, and automatically adjust the related parameters in reverse when the frequency of a certain type of defect abnormally rises, thereby improving the detection sensitivity and pertinence.

[0037] The intelligent spectrum module is enabled to realize joint detection of near-infrared and multispectral cameras, and to enhance the identification of defects such as mildew and insect damage based on specific waveband images in real time.

[0038] A graphical parameter configuration panel is provided to support the configuration of multiple sets of detection strategy files, realize one-key loading and quick switching, and enable the operator to flexibly adjust the detection parameters according to the product type and detection requirements.

[0039] The present application discloses the following technical effects:

[0040] The present application provides an automatic wood quality detection method and system based on image recognition, applies a wood defect detection model based on ImprovedMobileMama to analyze and process wood surface images, outputs the classification and recognition results of wood surface defects, realizes lightweight design of the detection model, reduces the computational complexity while improving the detection efficiency and accuracy. In the process of collecting wood surface images, automatic light compensation and pipeline synchronous acquisition methods are introduced to realize high-definition imaging of the wood surface and provide clear and stable data input for the detection model. At the same time, the synchronous acquisition method ensures that the image acquisition and wood position are strictly time-sequentially consistent, which provides a guarantee for the stable operation of the detection system in various industrial field environments. In addition, the wood defect detection model proposed by the present application fully exploits the advantages of the Mamba module in modeling long-distance dependencies to effectively improve the processing speed of the model with linear complexity, and uses compressed sensing to sparsely encode the features to reduce the feature dimension. The detection model has high-bandwidth data processing and high-concurrency reasoning capabilities, which can ensure the rapid and accurate detection of wood surface defects. The multi-receptive field feature interaction module is introduced into the model, multi-scale deep separable convolution is used to extract multi-scale local information of the wood surface features, and the global information extracted by Mamba is combined to comprehensively improve the feature extraction capability of the detection model, which helps to improve the accuracy of wood surface defect recognition. BRIEF DESCRIPTION OF DRAWINGS

[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings of the embodiments of the present application will be briefly introduced below, and the flowcharts are used to illustrate the operations performed by the system according to the embodiments of the present application in the present application. It should be understood that the foregoing or the following operations are not necessarily performed in sequence. On the contrary, various steps can be processed in reverse order or simultaneously according to needs. Meanwhile, other operations can be added to these processes, or one or more steps of operations can be removed from these processes.

[0042] Figure 1 A flowchart of an automatic wood quality detection method based on image recognition provided by the embodiments of the present application.

[0043] Figure 2 A structural diagram of a wood defect detection model based on ImprovedMobileMamba provided by the embodiments of the present application.

[0044] Figure 3 A structural diagram of a Mamba module in a wood defect detection model provided by the embodiments of the present application.

[0045] Figure 4 A structural diagram of an automatic wood quality detection system based on image recognition provided by the embodiments of the present application.

[0046] Figure 5 A hardware device layout diagram of an automatic wood quality detection system based on image recognition provided by the embodiments of the present application. DETAILED DESCRIPTION

[0047] The above description is only a summary of the technical solutions of the present application, in order to more clearly understand the technical means of the present application, the embodiments of the present application can be implemented according to the content of the description, and in order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the following specific embodiments of the present application are described.

[0048] In order to make the purposes, technical solutions and advantages of the present application more clear, the present application will be further described in detail below with reference to the drawings, and the described embodiments should not be regarded as limiting the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.

[0049] In the following description, the terms "comprise" and "have" and any variations thereof, are intended to cover a non-exclusive inclusion, for example, a process, method, system, product, or server including a series of steps or units does not have to be limited to those clearly listed steps or units, but can include other steps or modules not clearly listed or inherent to these processes, methods, products, or devices, unless otherwise defined. All technical and scientific terms used herein have the same meaning as understood by those skilled in the art to which the present application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application.

[0050] Embodiment one, the embodiments of the present application provide an automatic wood quality detection method based on image recognition, as shown in Figure 1 The method comprises the following steps:

[0051] Step S10, detecting the real-time position of the wood on the production line, when the wood reaches the preset shooting area, adjusting the light source brightness and angle for automatic light compensation, and collecting the wood surface image.

[0052] In this embodiment, a high-resolution industrial area array camera with 8 million to 20 million pixels is used to shoot the wood surface image at a rate of 30 fps under a resolution of 4096x3000; the camera is equipped with a global shutter technology, which exposes the entire production line image in the production line moving at a speed of 80 m / min, reducing the image trailing and distortion caused by the high-speed movement of the production line; the camera is equipped with a USB3.0 high-speed data transmission interface to transmit large-capacity image data to the back-end computing platform for real-time processing.

[0053] In the wood surface image collection process, the light compensation uses a combination of ring light and area light source, expands the multi-spectral and infrared light source, introduces the PWM dimming control and light intensity feedback algorithm, dynamically adjusts the light source brightness and angle, and improves the overall brightness consistency of the image:

[0054] In this embodiment, both the ring light source and the area light source use LED lights, the initial angle is set to 45°, and the power range is 10-30W; the optional multi-spectral light source and infrared light source are added to provide more spectral imaging information, and the specific performance of the wood surface defects in the image is observed under a specific waveband;

[0055] The light compensation system selects STM32 microprocessor as the core of PWM dimming control, designs PWM dimming circuit, connects the PWM output signal of the microcontroller with the light source driving circuit, inputs the dimming control program in the microcontroller, adjusts the brightness of the light source by controlling the duty cycle of the constant current driver, divides the brightness into levels, each level corresponds to a fixed duty cycle, and sends control instructions to adjust the brightness;

[0056] A light intensity sensor is installed at a position on the wood surface to convert the actual light intensity into an electrical signal. A PID controller receives the feedback data from the sensor and adjusts the duty cycle of the PWM signal by calculating the error between the current light intensity and the target light intensity, as well as the rate of change and accumulation of the error, thereby achieving dynamic adjustment of the light source brightness. Image processing techniques are used to analyze the texture and shape of the wood surface to achieve dynamic adjustment of the light source angle.

[0057] To ensure accurate alignment of the image acquisition timing with the wood transport position, avoid image blurring, target deviation, and wood detection problems, a photoelectric detection sensor, a rotary encoder, and a programmable logic controller are used to coordinate camera acquisition, light source activation and deactivation, and conveyor line operation, achieving high automation.

[0058] In this embodiment, a laser / infrared photoelectric switch and a high-precision rotary encoder are placed at the entrance of the shooting area. When the wood reaches the designated position, the sensor outputs a real-time signal, and the programmable logic controller receives the signal output control instruction to trigger the camera to collect images. The light supplement system is quickly activated, and the conveyor belt displacement is uploaded to ensure that the collected images are not repeated or missed.

[0059] To achieve integration and cooperation of wood defect detection and automatic control, a PLC communication interface is used to link key pipeline equipment such as the rejection device and the conveying system. The signal is sent to the PLC in real time through Ethernet and RS485 / RS232 serial ports to drive the pneumatic push rod to classify and reject unqualified boards, forming a stable and reliable control closed loop. The detection results are uploaded to the cloud platform through the HTTP protocol to achieve big data archiving, quality traceability, equipment health monitoring, and process optimization analysis.

[0060] Step S20: Preprocess the collected wood surface images, eliminate irrelevant background areas, and enhance image contrast to highlight the wood surface detection area.

[0061] In this embodiment, the preprocessing step for the collected wood surface images includes image normalization, image cropping, and image enhancement:

[0062] A linear normalization method is used to unify the image pixels within a fixed range, eliminating uneven lighting, sensor noise, and dynamic range differences:

[0063] The minimum pixel value I min and the maximum pixel value I max of each RGB channel in each wood surface image are obtained through an iterative algorithm. The pixel values in each channel are mapped to the range [0, 1] using the following formula:

[0064]

[0065] wherein I represents the original pixel value, I ′ represents the normalized pixel value.

[0066] An ROI-based image cropping method is used to remove non-wood areas in the wood surface image, reduce the amount of calculation, and focus on the defect detection area:

[0067] The Sobel operator is used to detect the edges of wood and background, and the morphological closing operation is used to first expand to fill the edge breaks (such as gaps caused by wood grain) and then erode to restore the edge thickness, ensuring that the edge contour is closed. The Suzuki algorithm is used to extract all closed edge contours, calculate the area of each edge contour, retain the largest contour (the main part of the wood surface), and eliminate noise points such as conveyor belt scratches and dust. The minimum area circumscribed rectangle of the largest contour is calculated as a rotation matrix to obtain the center point coordinates, length and width, and rotation angle of the largest contour. The image is cropped according to the rectangular boundary of the rotation matrix, and expanded outward by 5 pixels in the vertical and horizontal directions to avoid defects located at the edge being truncated.

[0068] An adaptive histogram equalization method based on limited contrast (CLAHE) is used to process the cropped wood surface image to enhance the details of low-contrast defects such as wood grain and cracks on the wood surface, and to avoid the overexposure problem caused by the global histogram equalization method:

[0069] The cropped wood surface image is converted to a grayscale image, and the grayscale image is divided into multiple small blocks, each with a size of 8x8 pixels. If the image size is not an integer multiple of the block size, the edge blocks are filled with zero values. The histogram of each grayscale image block is calculated, and the threshold is set to uniformly distribute the pixels exceeding the threshold to all grayscale levels, maintaining the total number of pixels. The cumulative distribution function is calculated for each grayscale image block after cropping, and a grayscale mapping table is generated. The threshold is set to limit the contrast amplification factor. According to the mapping table, the pixels in each grayscale image block are converted, and for the boundary area, bilinear interpolation is used with the mapping values of the adjacent four grayscale image blocks to complete the contrast enhancement. Finally, the enhanced grayscale image is converted back to an RGB image.

[0070] In step S30, the preprocessed wood surface image is input into the pre-trained wood defect detection model based on ImprovedMobileMamba to identify and classify the wood surface defects.

[0071] In this embodiment, the detailed steps of obtaining the pre-trained wood defect detection model include:

[0072] Various types of wood surface defect images are collected, including cracks, knots, discoloration, mold, and insect damage. A labeling tool is used to draw a bounding box to mark the defect area, and a positive integer is used to mark the defect category.

[0073] The labeled wood surface defect image is used as a data set for model training, and the data set is divided into a training set, a validation set and a test set according to a ratio of 8:1:1;

[0074] A wood defect detection model based on an ImprovedMobileMamba module is built, and the input and output dimensions, kernel size and number of layers of the convolution and linear layers of each module in the model are set;

[0075] The preprocessed wood surface defect image is used as the input of the model, the model outputs the prediction values of the bounding box and the defect type, the loss function between the real label and the model prediction value is calculated, the model is trained by using the stochastic gradient descent method, and the loss function is the weighted sum of the EIoU bounding box regression loss and the Focal classification loss:

[0076] The EIoU bounding box regression loss introduces a center distance and an aspect ratio penalty term to solve the positioning deviation problem of cracks and other extreme aspect ratio defects, and the expression of the loss function is as follows:

[0077]

[0078] Wherein, represents the EIoU bounding box regression loss, IoU represents the intersection over union of the predicted bounding box and the real bounding box, and ρ(·) represents the Euclidean distance, and b gt represent the center points of the predicted bounding box and the real bounding box respectively, and w gt represent the width of the predicted bounding box and the real bounding box respectively, and h gt are the height of the predicted bounding box and the real bounding box respectively, c w and c h are the width and height of the minimum bounding box respectively.

[0079] Focal classification loss is used to alleviate the imbalance problem of small sample categories such as mildew, and the expression of the loss function is as follows:

[0080]

[0081] Wherein, p t is the predicted probability value of the model for the correct class, the positive sample is p, and the negative sample is 1-p; α y is a balance factor, which adjusts the weight of positive and negative samples, and in the embodiment, α t =0.25; γ is a modulation factor, which controls the degree of weight reduction of easy-to-classify samples, and in the embodiment, γ =2.

[0082] Finally, the total loss function of the model is expressed by the following formula:

[0083]

[0084] wherein a and β are weight coefficients, both of which are set to 0.5 in this embodiment.

[0085] The model is trained using RTX 4060Ti, RTX 4080 and NVIDIA high-performance GPU dedicated to AI inference, the model optimizer is set to Adam optimizer, the initial learning rate is set to 3e -4 , the cosine quenching dynamic learning rate adjustment strategy is adopted, and the model parameters are updated by back propagation;

[0086] When the loss function converges, the model parameters at this time are retained as the pre-trained wood defect detection model, the model is quantized by INT8 using TensorRT, the volume is compressed to 35%, and the model is embedded in a multi-threaded pipeline industrial host computer for processing real-time collected wood surface image data.

[0087] In step S40, the wood surface defect type and position are determined according to the detection result output by the model, and the wood surface defect area is measured, and whether the wood is qualified is determined according to the threshold value.

[0088] In step S50, the wood quality determination result is written into the database in real time, and a control command is sent through an industrial communication interface to trigger the start of the rejection device to sort out the unqualified wood from the production line.

[0089] In embodiment two, the application provides a detailed process for processing wood surface images by the wood defect detection model based on ImprovedMobileMamba applied in the automatic wood quality detection method based on image recognition, and the model structure is as shown in Figure 2 (a) shown:

[0090] The preprocessed wood surface image is used as the input feature, the feature dimension is HxWx3, the channel dimension is 3 representing the R, G and B channels of the image, the feature size is HxW, and H and W represent the feature height and width respectively; the input feature is first sent to the block embedding layer, which gradually down-samples the input feature through four convolution layers with a step size of 2, while increasing the number of feature channels, and the detailed structure of the block embedding layer is as shown in Figure 2 (b), the first three layers are composed of convolution, batch normalization and ReLU activation function, and the last layer includes convolution and normalization operation; after four times of down-sampling, the size of the input feature becomes 1 / 16 of the original, the original image is divided into block regions, and the shallow layer features are extracted.

[0091] Secondly, the shallow features are fed into three consecutive ImprovedMobileMamba modules for deeper feature extraction. Downsampling layers are introduced between modules to reduce feature size and computational complexity. The detailed structure of the ImprovedMobileMamba module is as follows: Figure 2 As shown in (c), the segmented block image is fed into the module as a two-dimensional feature, and sequentially passes through a depthwise separable convolutional layer, a batch normalization layer, and a feedforward neural network layer. The global and local information of the features is extracted through a multi-receptive field feature interaction module. The detailed structure of this module is shown below. Figure 2 As shown in -(d):

[0092] Let the input feature of the module be x I The feature is of size h×w×c, where h, w, and c represent height, width, and number of channels, respectively. The feature is divided into three parts along the channel dimension. The first part is the feature... Global context dependencies are modeled using compressed sensing-enhanced Mamba modules to enhance high-frequency edge information. The feature dimension is h×w×ξc, where ξ is the global channel ratio, and its value ranges from [0,1]. Low-dimensional features are generated through compressed sensing, and the features are linearly projected using a structured random measurement matrix, introducing sparse coding constraints.

[0093] Features Flattened into a vector in The matrix N = h × w × ξc is represented by a structured random measurement matrix. By performing a linear mapping, we obtain low-dimensional measurements:

[0094]

[0095] in, These are the compressed features, and ∈ represents additive noise; assume x is in an overcomplete dictionary. It has a sparse representation: z represents the sparsity coefficients, and the final compressed feature is represented as:

[0096] Features of sparse representation The data is fed into a convolutional layer to facilitate information exchange within the features. Then, feature reconstruction is performed to enhance the representation of the edge information of the features. Feature reconstruction uses an iterative soft thresholding algorithm to solve the following optimization problem and reconstruct the sparse coefficients:

[0097]

[0098] where min denotes the sparse coefficient value that minimizes the expression, ||·||1 and ||·||2 denote the L1 norm and L2 norm respectively, and λ is a regularization parameter; z is iteratively updated by the following formula:

[0099]

[0100] where z t and z t+1 denote the current and updated sparse coefficients respectively, S λ / L is a soft threshold function, L is a Lipschitz constant, and the final reconstructed feature is represented as: T denotes the number of iterations, and the reconstructed feature dimension is restored to h x w x ξc by dimension conversion.

[0101] The bidirectional Mamba module learns the global information of the feature map through forward and backward scanning, and the detailed structure of Mamba is shown in Figure 3 , the process of learning global information from the feature is represented as:

[0102]

[0103] where and denote the output features of the two branches of Mamba, SSM, σ, Conv and Linear denote the state space model, Sigmoid activation function, convolution layer and linear layer respectively, and denote the first half and the second half of the feature , denotes element-wise multiplication; the feature containing global information is added to the reconstructed feature as the final output feature

[0104] The second part of the feature learns the multi-scale information in the feature through multi-kernel deep separable convolution, the feature size of is h x w x μc, μ≤1-ξ, the feature is divided into n parts along the channel dimension, and the feature of each part is operated by deep separable convolution with different kernel sizes, and finally the results of different convolution operations are spliced according to the channel dimension to obtain the output feature

[0105]

[0106] wherein DWConv represents a depth separable convolution, j represents a convolution layer index, k represents a convolution kernel size, Concat is a feature concatenation operation, dim = -1 represents concatenating part of the features according to the last dimension, and the channel dimension.

[0107] The third part of the features, i.e. the features of the remaining (1-ξ-μ)c channels, are mapped through an identity mapping to reduce feature redundancy in a high-dimensional space, minimize unnecessary computational complexity, and improve operation efficiency. The output features of the three parts are concatenated as the output features x of the multi-receptive field feature interaction module. O :

[0108]

[0109] wherein x I [(1-ξ-μ)c:]) represents the third part of the features cut from the input features of the module; the features x O The output features of the third ImprovedMobileMamba module are sent to the target detection head to output prediction values for the wood surface defect class and the bounding box, and participate in the calculation of the model loss function.

[0110] The output features of the third ImprovedMobileMamba module are sent to the target detection head to output prediction values for the wood surface defect class and the bounding box, and participate in the calculation of the model loss function.

[0111] During the model training process, the model performance is evaluated using mAP, precision, and recall:

[0112] mAP is a measure of the comprehensive detection ability of the model under loose matching conditions, and the higher the value, the stronger the accuracy of the model in target positioning and classification. The calculation formula is:

[0113]

[0114] wherein G represents the total number of wood defect classes, P i (R) represents the precision-recall curve of the i-th class, and R represents the recall rate.

[0115] The precision rate is the proportion of actual positive samples among the predicted positive samples, and is an important standard for reflecting the reliability of the model prediction results. The recall rate is the proportion of correctly predicted positive samples among the actual positive samples, and reflects the coverage ability of the model for positive samples. The calculation formulas of the recall rate R and the precision rate P are:

[0116]

[0117] wherein TP is the number of true positives, FP is the number of false positives, and FN is the number of false negatives.

[0118] The wood defect detection model has a large performance improvement compared with a traditional target detection model, and Table 1 shows comparison results of the model and other models.

[0119] Table 1 model performance comparison results

[0120] Model mAP@0.5 Precision Recall Fast R-CNN 88.3% 89.5% 85.2% YOLOv6 84.5% 87.6% 82.1% YOLOv8 89.8% 92.8% 88.5% CS-Mamba 92.7% 93.9% 92.8%

[0121] In the table, CS-Mamba represents the wood defect detection model, and mAP@0.5 represents the average precision when the IoU is greater than or equal to 0.5.

[0122] In the third embodiment, the automatic wood quality detection system based on image recognition provided by the embodiment of the application can execute the automatic wood quality detection method based on image recognition provided by any embodiment of the application, has the corresponding function modules and beneficial effects of the execution method, and the detailed structure of the system is as shown in Figure 4 The system includes the following modules:

[0123] The image acquisition module is used to detect the real-time position of the wood on the production line, automatically adjust the light source brightness and angle for light compensation when the wood reaches the preset shooting area, and collect the wood surface image;

[0124] The image preprocessing module is used to preprocess the collected wood surface image, eliminate irrelevant background areas, enhance the image contrast, and highlight the wood surface detection area;

[0125] The surface defect recognition module is used to input the preprocessed wood surface image into the pre-trained wood defect detection model based on ImprovedMobileMamba, and recognize and classify the wood surface defects;

[0126] The quality determination module is used to determine the wood surface defect type and position according to the detection result output by the model, measure the wood surface defect area, and determine whether the wood is qualified according to the threshold;

[0127] The unqualified product sorting module is used to write the wood quality determination result into the database in real time, send a control instruction through an industrial communication interface, trigger the start of the rejection device, and sort out the unqualified wood from the production line.

[0128] The hardware device layout for realizing the automatic wood quality detection based on the above modules is as shown in Figure 5

[0129] The laser / infrared photoelectric switch detects the real-time position of the wood conveyed from the collection box on the conveying line, adopts LED light to provide auxiliary lighting, and transmits the photoelectric sensor detection signal to the conveying line synchronization module in real time;

[0130] ​When the wood reaches the designated position, the PLC receives a signal and controls the light supplementing device to provide annular light / diffused light (optional multi-spectrum / infrared light source), triggers the industrial camera to take an image of the wood surface, and uploads the image data to the industrial computing platform of the industrial host computer through system integration and communication module. The wood surface image is processed in real time by the wood defect detection model embedded in the platform to obtain the judgment result of the wood quality, and a control command is generated to control the pneumatic push rod to send the unqualified wood into the rejection box.

[0131] Although the present application makes various references to certain modules in the system according to the embodiments of the present application, however, any number of different modules can be used and run on the user terminal and / or server, and the various units and modules are only divided according to the functional logic, but are not limited to the above division, as long as the corresponding functions can be realized; in addition, the specific names of the functional units are only for easy mutual differentiation, and do not limit the protection scope of the present application.

[0132] The above detailed description does not constitute a limitation on the protection scope of the present application. Those skilled in the art should understand that various modifications, combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present application shall be included in the protection scope of the present application. In some cases, the actions or steps described in the present application can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multi-task processing and parallel processing are possible or can be advantageous.

Claims

1. An image recognition-based automated wood quality detection method, characterized by, The method includes: (1) Detect the real-time position of the wood on the production line. When the wood reaches the preset shooting area, adjust the brightness and angle of the light source to automatically supplement the light and collect images of the wood surface. (2) Preprocess the collected wood surface images to remove irrelevant background areas, enhance image contrast, and highlight the wood surface detection area; (3) Input the preprocessed wood surface image into the pre-trained wood defect detection model based on ImprovedMobileMamba to identify and classify wood surface defects; (4) Based on the detection results output by the model, determine the types and locations of defects on the wood surface, measure the area of ​​defects on the wood surface, and determine whether the wood is qualified based on the threshold. (5) Write the timber quality judgment results into the database in real time, send control commands through the industrial communication interface to trigger the start of the rejection device, and sort out the unqualified timber from the production line.

2. The automated wood quality detection method based on image recognition as claimed in claim 1, characterized in that, In step (1), the supplementary lighting uses a combination of ring light and surface light source to expand the multispectral and infrared light sources. Based on PWM dimming control and light intensity feedback algorithm, the brightness and angle of the light source are dynamically adjusted to improve the overall brightness consistency of the image.

3. The automated wood quality inspection method based on image recognition as described in claim 1, characterized in that, In step (1), the camera acquisition, light source activation and deactivation and the operation of the conveyor line are coordinated through photoelectric detection sensors, rotary encoders and programmable logic controllers to achieve synchronization between the conveyor line and image acquisition.

4. The automated timber quality inspection method based on image recognition as described in claim 1, characterized in that, In step (2), the preprocessing steps include image normalization, image cropping, and image enhancement: A linear normalization method is used to unify image pixels to a fixed range, eliminating uneven illumination, sensor noise, and dynamic range differences. A ROI-based image cropping method is used to remove non-wood areas from the wood surface image, reducing computation and focusing on the defect detection area. An adaptive histogram equalization method based on limiting contrast is used to process the cropped wood surface image, enhancing the details of low-contrast defects on the wood surface.

5. The automated wood quality inspection method based on image recognition as described in claim 4, characterized in that, The steps for processing wood surface images using a ROI-based image cropping method include: The Sobel operator was used to detect the edges between the wood and the background, and morphological closing operations were used to first dilate and fill the edge breaks, and then erosion was used to restore the edge thickness to ensure that the edge contour was closed. The Suzuki algorithm is used to extract all closed edge contours, calculate the area of ​​each edge contour, retain the main part of the wood surface as the maximum contour, and remove noise. The minimum area bounding rectangle of the maximum contour is calculated as the rotation matrix to obtain the center point coordinates, length, width and rotation angle of the maximum contour; The image is cropped according to the rectangular boundary of the rotation matrix and extended outward by 5 pixels in both the vertical and horizontal directions to prevent defects from being truncated when they are located at the edge.

6. The automated wood quality inspection method based on image recognition as described in claim 4, characterized in that, The steps for processing the cropped wood surface image using an adaptive histogram equalization method based on limited contrast include: The cropped wood surface image is converted into a grayscale image, and the grayscale image is divided into multiple small blocks. When the image size is not an integer multiple of the block size, the edge blocks are filled with zero values. Calculate the histogram of each grayscale image patch, set a cropping threshold, and distribute pixels exceeding the threshold evenly across all grayscale levels while keeping the total number of pixels constant. Calculate the cumulative distribution function of the histogram after cropping each grayscale image patch, generate a grayscale mapping table, and set a threshold to limit the contrast magnification factor. The pixels in each grayscale image block are converted according to the mapping table. For the boundary region, bilinear interpolation is performed using the mapping values ​​of four adjacent grayscale image blocks to complete the contrast enhancement. Finally, the enhanced grayscale image is converted back to an RGB image.

7. The automated timber quality inspection method based on image recognition as described in claim 1, characterized in that, Step (3) involves obtaining the detailed steps for the pre-trained wood defect detection model, including: Images of various types of wood surface defects were collected, including cracks, knots, discoloration, mold, and insect infestation. Boundary boxes were drawn to mark the defect areas using annotation tools, and positive integers were used to label the defect categories. The labeled images of wood surface defects were used as the dataset for model training, and the dataset was divided into training set, validation set and test set. A wood defect detection model based on the ImprovedMobileMamba module was built, and the input and output dimensions, kernel size and number of layers of the convolution and linear layers of each module in the model were set. Calculate the loss function between the true labels and the model predictions. Train the model using stochastic gradient descent. The loss function is a weighted sum of the EIoU bounding box regression loss and the Focal classification loss. Set the model optimizer to Adam optimizer, set the initial learning rate, adopt the cosine tempering dynamic learning rate adjustment strategy, and update the model parameters through backpropagation. When the loss function converges, the model parameters at this point are retained as a pre-trained wood defect detection model.

8. The automated wood quality inspection method based on image recognition as described in claim 7, characterized in that, The wood defect detection model is built on the ImprovedMobileMamba framework. It uses the state-space model in the Mamba structure to replace the attention mechanism, and takes advantage of its linear complexity to achieve a lightweight design of the model. Combining the characteristics of recursion, convolution and continuous time models, it effectively simulates long-term dependencies and models infinitely long context information. The model introduces a multi-receptive field feature interaction module to segment the input features and feed them into a CS-Mamba module with compressed sensing enhancement, an efficient multi-kernel depthwise separable convolution module, and a redundancy elimination module, respectively, to extract diverse information from the features of the wood surface image. The compressed sensing layer in the module reduces the feature dimension to save model computation costs.

9. The automated wood quality inspection method based on image recognition as described in claim 7, characterized in that, The expression for the EIoU bounding box regression loss is as follows: in, This represents the EIoU bounding box regression loss, where IoU represents the intersection-union ratio between the predicted and ground truth bounding boxes, and ρ(·) represents the Euclidean distance. and b gt These represent the center points of the predicted bounding box and the ground truth bounding box, respectively. and w gt These represent the widths of the predicted bounding box and the ground truth bounding box, respectively. and h gt These are the heights of the predicted bounding box and the ground truth bounding box, respectively, c w and c h These are the width and height of the minimum bounding box, respectively; The Focal classification loss The expression is as follows: where p t is the predicted probability value of the model for the correct class, p for positive samples and 1-p for negative samples; a t is the balancing factor, adjusting the weight of positive and negative samples; g is the modulation factor, controlling the degree of weight reduction of easy-to-classify samples.

10. An automated timber quality inspection system based on image recognition, characterized in that, The system is used to implement the automated wood quality inspection method based on image recognition as described in any one of claims 1-9, the system comprising: Image acquisition module: used to detect the real-time position of wood on the production line. When the wood reaches the preset shooting area, the brightness and angle of the light source are adjusted to automatically supplement the light and acquire images of the wood surface. Image preprocessing module: used to preprocess the acquired wood surface images, remove irrelevant background areas, enhance image contrast, and highlight the wood surface detection area; Surface defect recognition module: This module is used to input the pre-processed wood surface image into a pre-trained wood defect detection model based on Improved MobileMamba to identify and classify wood surface defects. Quality assessment module: Based on the detection results output by the model, it determines the type and location of surface defects in the wood, measures the area of ​​surface defects, and determines whether the wood is qualified according to the threshold. Non-conforming product sorting module: It is used to write the wood quality judgment results into the database in real time, send control commands through the industrial communication interface to trigger the start of the rejection device, and sort out non-conforming wood from the production line.