Bamboo wood defect detection method based on computer vision
By combining multi-angle polarization imaging and bamboo grain orientation field construction with dual-flow state space detection technology, the problems of insufficient accuracy and environmental sensitivity in bamboo defect detection have been solved, achieving high-precision, low-false-judgment, and high-efficiency bamboo defect detection.
Patent Information
- Application Number
- CN202511886837.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-15
- Publication Date
- 2026-03-20
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing technologies for detecting defects in bamboo materials suffer from insufficient detection accuracy, poor adaptability to the unique structure of bamboo, and sensitivity to environmental changes, making it difficult to meet the requirements of real-time detection on production lines.
By employing multi-angle polarization imaging, bamboo grain direction field construction, and dual-flow state space detection technology, high-precision detection of bamboo defects is achieved through polarization-enhanced image acquisition, bamboo grain direction field generation, streamline superpixel segmentation, and rhythmic unit index verification.
It achieves high-precision, low-false-judgment, and high-real-time detection of bamboo defects, and can maintain stability under complex textures and lighting conditions, significantly improving detection capabilities.
Smart Images

Figure CN121707958A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer vision technology, and in particular to a method for detecting defects in bamboo based on computer vision. Background Technology
[0002] In the processing and utilization of bamboo, defects such as surface cracks, insect infestation, mold, and abnormal fiber structure significantly affect the strength, appearance, and service life of the finished products. Traditional bamboo defect detection mainly relies on manual visual inspection or ordinary imaging methods. These methods are not only inefficient but also highly dependent on the experience of the inspectors, leading to missed and false detections. With the development of computer vision technology, researchers have begun to explore automated inspection using industrial cameras combined with conventional image processing methods, such as edge detection, threshold segmentation, or texture analysis to identify bamboo surface defects. However, due to the complexity and periodicity of bamboo's natural texture, these methods easily misjudge natural fiber textures as cracks or spots, resulting in unstable detection results that are difficult to meet the requirements of real-time inspection on production lines.
[0003] Since the advent of deep learning methods, research has utilized convolutional neural networks or object detection models to train and identify defects in bamboo. While these methods perform well in common image classification or detection tasks, they still have several shortcomings in bamboo scenarios. First, most existing models are based on ordinary RGB images, lacking information on the optical properties of bamboo and making it difficult to identify shallow or subsurface defects. Second, conventional convolutional feature extraction lacks adaptability to the direction of bamboo fibers; when the direction of bamboo grain changes significantly, the model is prone to feature extraction bias. Third, bamboo nodes exhibit significant periodicity and unique geometric shapes, which existing methods often treat as interfering factors, failing to fully utilize their periodic priors, resulting in high false detection rates in rhythmic units. Finally, fluctuations in humidity, lighting, and other conditions in the production environment can significantly impact ordinary image detection methods, leading to inconsistent model performance under different conditions.
[0004] Existing technologies for detecting defects in bamboo generally suffer from insufficient detection accuracy, poor adaptability to the unique structure of bamboo, and sensitivity to environmental changes.
[0005] Therefore, how to provide a computer vision-based method for detecting defects in bamboo is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0006] One objective of this invention is to propose a computer vision-based method for detecting defects in bamboo. This invention fully utilizes multi-angle polarization imaging, bamboo grain direction field construction, and dual-flow state space detection technology. It details the detection process, which includes polarization-enhanced image acquisition, bamboo grain direction field generation, streamline superpixel segmentation, longitudinal and transverse dual-flow modeling, and rhythmic unit index verification. This method has the advantages of high detection accuracy, strong adaptability to complex bamboo textures, good robustness to environmental changes, and the ability to achieve real-time detection on the production line.
[0007] A method for detecting defects in bamboo based on computer vision according to an embodiment of the present invention includes the following steps:
[0008] S1. Obtain images of the bamboo surface using a multi-angle polarization imaging device to obtain polarization intensity image data;
[0009] S2. Process the polarization intensity image data to generate a polarization degree map, a polarization angle map, and a cross-polarization and parallel polarization difference map, thus forming a polarization enhancement image.
[0010] S3. Construct the orientation field for the polarization-enhanced image, extract the first orientation candidate based on the phase gradient of the polarization angle map, extract the second orientation candidate based on the anisotropy measure of the cross-polarization and parallel polarization difference maps, perform phase unwrapping and sign disambiguation on the first and second orientation candidates, solve the global π-symmetric orientation field in the graph optimization process constrained by the boundary curve and the node ring region, and output the bamboo pattern orientation field.
[0011] S4. Based on the bamboo grain guide field, streamline segmentation is performed on the bamboo surface, dividing the image into streamline superpixel regions along the fiber direction, and each streamline region is unfolded into one-dimensional sequence data;
[0012] S5. Input the one-dimensional sequence data into the dual-stream state space detection model, wherein the sequence along the fiber direction is processed by the longitudinal state space branch, and the transverse adjacent sequences are processed by the transverse attention branch to obtain the defect candidate results.
[0013] S6. Detect the nodes on the bamboo surface, determine the rhythmic units between adjacent bamboo nodes, expand and normalize each rhythmic unit, and calculate the directional continuity index, polarization angle continuity index, reflection component conservation index and periodic symmetry index along the fiber direction and transverse direction according to the preset grid. Check the consistency of each index according to the calibration threshold and generate an abnormal response map.
[0014] S7. The defect candidate results are fused with the anomaly response map to obtain the final defect detection result, including defect category, location and size parameters.
[0015] Optionally, the multi-angle polarization imaging device refers to an imaging device including an industrial camera, an adjustable polarizer assembly, and a multi-angle illumination source. The industrial camera is used to acquire images of the bamboo surface, the adjustable polarizer assembly is used to modulate the polarization of the incident light at different angles, and the multi-angle illumination source is used to provide stable illumination in different incident directions to acquire image data at multiple polarization angles.
[0016] Optionally, S2 specifically includes:
[0017] S21. Perform radiometric correction, geometric registration and polarization axis calibration on images with different polarization angles, unify exposure, gain and white balance parameters, and obtain a set of corrected images that correspond one-to-one in spatial location.
[0018] S22. Perform polarization-consistent resampling and time alignment on the corrected image set to generate the intensity vector of each pixel at each polarization angle, and generate the corresponding effective pixel mask and angle reliability weight.
[0019] S23. Under the condition of satisfying the polarization propagation and interface reflection constraints, the intensity vector is demixed by the reflection component to obtain the specular component map, the diffuse reflection component map and the subsurface scattering trend map. The specular component map is used to suppress the specular glare and the angle offset and intensity mismatch are corrected according to the angle reliability weight to form the polarization consistency correction result.
[0020] S24. Based on the polarization consistency correction result, calculate the total intensity component and two orthogonal differential components, generate a polarization degree map and a polarization angle map, and generate a cross-polarization and parallel polarization difference map according to the difference relationship between parallel polarization and cross-polarization, and output a polarization confidence map formed by the effective pixel mask and the angle reliability weight.
[0021] S25. Perform dynamic range normalization and noise suppression on the polarization degree map, the polarization angle map, and the cross-polarization and parallel polarization difference map, and concatenate them with the polarization confidence map in a fixed channel order to form a polarization enhancement image.
[0022] Optionally, S3 specifically includes:
[0023] S31. Using the polarization angle map, polarization degree map, and cross-polarization and parallel polarization difference map as input data, establish a direction estimation domain with pixels as nodes.
[0024] S32. In the direction estimation domain, a first direction candidate is generated based on the phase gradient and local principal direction analysis of the polarization angle diagram, and weights are assigned to the first direction candidate according to the degree of polarization and angular stability.
[0025] S33. In the direction estimation domain, a second direction candidate is generated based on the anisotropy measure of the cross-polarization and parallel polarization difference map. The second direction candidate is a direction along the anisotropic principal axis or an orthogonal direction. Weights are assigned to the second direction candidate according to the difference magnitude and gradient stability.
[0026] S34. Perform phase unwrapping and symbol disambiguation in the local neighborhood. Use the minimum flip principle and path consistency principle to check the consistency between the first direction candidate and the second direction candidate, eliminate the directional ambiguity caused by 180-degree equivalence, and obtain a continuous initial direction field.
[0027] S35. Using the tangential constraints of the outer contour of the bamboo and the tangential constraints of the node ring area as hard constraints, and the smoothing term of the directional difference between adjacent pixels as soft constraints, the initial orientation field is optimized globally, and topological defect correction is performed during the optimization process to obtain a global orientation field that satisfies the 180-degree periodic symmetry.
[0028] S36. Calculate the local curvature and direction confidence based on the global direction field, wherein the direction confidence is jointly determined by the consistency between the first direction candidate and the second direction candidate and the polarization confidence, and the local curvature is determined by the rate of change of the direction in the spatial neighborhood. Output a bamboo-patterned guide field that includes direction, local curvature and confidence.
[0029] Optionally, S4 specifically includes:
[0030] S41. Using the bamboo pattern guide field as input, select a set of seed points in the image domain based on the local maxima of the direction confidence, combined with the condition that the local curvature does not exceed the preset threshold and the mutual spacing is not less than the preset minimum spacing, and exclude candidate points located in invalid regions and boundary buffer zones.
[0031] S42. Starting from each seed point, perform streamline tracking in the direction indicated by the bamboo pattern guide field and in the opposite direction until the image boundary and direction confidence are lower than the termination threshold, to obtain a set of non-intersecting streamlines with unique identifiers, and remove trajectories that are too short or repeat the already generated streamlines.
[0032] S43. Perform anisotropic region assignment calculation with streamline as the center. For any pixel, determine the assignment cost by combining the path consistency along the bamboo grain direction and the deviation penalty from the bamboo grain direction. Assign the pixel to the streamline region with the minimum cost to obtain a set of streamline superpixels that cover the image domain and do not overlap. Then, crop or merge regions that exceed the maximum width or are lower than the minimum width.
[0033] S44. Establish a local coordinate system for each streamline superpixel, with the streamline as the vertical axis and the direction orthogonal to the streamline as the horizontal axis, map the pixel coordinates in the region to the vertical position and horizontal offset, and perform directional confidence weighted aggregation on each channel of the polarization enhancement image within a limited horizontal bandwidth to generate a one-dimensional feature sequence sorted along the vertical position.
[0034] S45. For each one-dimensional feature sequence, perform length normalization and equal-interval resampling according to the vertical position to obtain one-dimensional sequence data of fixed length. At the same time, record the corresponding region identifier, start and end position, average direction, direction curvature statistics and direction confidence statistics.
[0035] Optionally, S5 specifically includes:
[0036] S51. Receive one-dimensional sequence data and construct a dual-stream state space detection model. The dual-stream state space detection model includes a vertical state space branch, a horizontal sparse attention branch, and a multi-task detection head.
[0037] S52. Construct a vertical state space branch, perform forward and backward state recursion twice for each one-dimensional sequence in sequence order, determine the control parameters of the update gate by combining the direction confidence and direction curvature, and use the update gate to dynamically adjust the writing and forgetting process of state information. Use finer step size to update the state in the node ring and high curvature region to obtain the vertical feature sequence.
[0038] S53. Construct a lateral sparse attention branch. Based on streamline geometry and bamboo pattern guide field, select a limited number of adjacent streamlines and a limited range of longitudinal windows for each position to form a sparse adjacency set. Add geometric alignment bias and polarization confidence bias to the attention weight calculation and output the lateral aggregated feature sequence.
[0039] S54. Perform two-stream fusion on the longitudinal feature sequence and the transverse aggregated feature sequence, calculate the fusion coefficient according to the position, and the fusion coefficient is jointly determined by the direction confidence, direction curvature and polarization confidence. During the fusion process, apply fiber smoothing constraint and transverse consistency constraint, while retaining the residual path of the input key channel to obtain the fused feature sequence.
[0040] S55. The fused feature sequence is fed into the multi-task detection head, which outputs the defect category probability, the vertical and horizontal position in the original image, the horizontal width and fiber length of the defect, and the pixel-level mask confidence for each position. The sequence coordinates are then restored to the original image coordinates in real time using the reverse mapping relationship and region identifier.
[0041] S56. Filter candidates of the same type according to the confidence threshold, and perform non-maximum suppression and consistency merging on candidates that are vertically adjacent or horizontally adjacent and spatially overlapping to obtain defect candidate results containing category, location, size and mask information.
[0042] Optionally, S6 specifically includes:
[0043] S61. Detect the nodes on the bamboo surface, scan along the bamboo grain direction in the image domain, identify the node areas in the form of rings, and extract the node center line in each node area.
[0044] S62. Define the region between any two adjacent node centerlines as a rhythmic unit, establish a reversible coordinate mapping for each rhythmic unit with the bamboo grain direction as the vertical axis and the horizontal axis orthogonal to the bamboo grain direction as the horizontal axis, and normalize the scale of the rhythmic unit in both the vertical and horizontal directions.
[0045] S63. Construct a two-dimensional grid with a fixed resolution in the normalized coordinate system of each rhythm unit, and resample the orientation angle, polarization angle, cross polarization and parallel polarization difference, orientation confidence and polarization degree according to the grid position to generate a multi-channel data sequence and effective pixel mask that correspond one-to-one with the grid.
[0046] S64. Within each rhythmic unit, calculate the four types of indicators sequentially using the vertical position as the index:
[0047] The directional continuity index is defined as the weighted average of the directional angle changes between adjacent longitudinal positions in the horizontal direction.
[0048] The polarization angle continuity index is defined as the weighted average of the polarization angle changes between adjacent longitudinal positions in the transverse direction, and processed according to the half-cycle equivalence rule.
[0049] The reflection component conservation index is defined as the average amplitude of the difference between cross-polarization and parallel polarization in the transverse direction.
[0050] The periodic symmetry index is defined as the complementary measure of the lateral distribution similarity between the current rhythm unit and its adjacent rhythm units at the same vertical position.
[0051] S65. Map the four types of indicators to a unified dimension interval, calculate the comprehensive anomaly score according to the preset weight, and compare it with the calibrated direction continuity threshold, polarization angle continuity threshold, reflection component conservation threshold, periodic symmetry threshold and comprehensive anomaly threshold one by one to generate a longitudinal anomaly response sequence and the pass or fail mark of each indicator.
[0052] S66. Based on the longitudinal anomaly response sequence and the horizontal confidence level, the anomaly response is horizontally expanded to form an anomaly response map corresponding to the two-dimensional grid, and then restored to the original image coordinate system through the reversible coordinate mapping to output the anomaly response map.
[0053] Optionally, obtaining the final detection result of the defect refers to matching the defect candidate results with the abnormal response map in spatial location, weighting and fusing the category probability, geometric parameters and abnormal response scores of the same location, and merging the candidates that are spatially adjacent and of the same category after confidence reordering and low confidence elimination, and finally outputting the final detection result containing defect category, location coordinates, geometric size and shape contour.
[0054] The beneficial effects of this invention are:
[0055] This invention overcomes the limitations of traditional RGB image detection by introducing multi-angle polarization imaging and polarization enhancement processing, effectively distinguishing natural textures from actual defects on bamboo surfaces. The generation of polarization degree maps, polarization angle maps, and cross- and parallel polarization difference maps enhances the detection of defects with different optical properties, such as shallow cracks, insect holes, and mold spots, thus maintaining high detection accuracy and stability even under complex textures and varying lighting conditions.
[0056] The bamboo grain guide field construction method proposed in this invention combines orientation angle, confidence level, and curvature information to generate a continuous and globally consistent orientation field, providing a stable orientation reference for subsequent streamline superpixel segmentation and one-dimensional sequence unfolding. By unfolding the bamboo surface into sequence data along the fiber direction and combining it with a dual-flow state space detection model for joint longitudinal and transverse modeling, it can not only accurately identify cracks extending along the grain but also effectively capture transversely distributed mold spots and insect infestations, significantly improving the detection capability for multiple types of defects.
[0057] Furthermore, this invention introduces indicators such as directional continuity, polarization angle continuity, reflection component conservation, and periodic symmetry within the rhythmic unit for consistency verification, forming an anomaly response map, which is then fused with defect candidate results, further reducing false detections caused by natural textures and bamboo joint structures. By comprehensively applying the above methods, this invention achieves high-precision, low-false-judgment, and high-real-time detection of bamboo defects, possessing promising industrial application prospects and widespread value. Attached Figure Description
[0058] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:
[0059] Figure 1This is a flowchart of a computer vision-based bamboo defect detection method proposed in this invention;
[0060] Figure 2 This is a schematic diagram of the dual-flow state-space detection model structure of a computer vision-based bamboo defect detection method proposed in this invention. Detailed Implementation
[0061] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.
[0062] refer to Figure 1 and Figure 2 A computer vision-based method for detecting defects in bamboo includes the following steps:
[0063] S1. Obtain images of the bamboo surface using a multi-angle polarization imaging device to obtain polarization intensity image data;
[0064] S2. Process the polarization intensity image data to generate a polarization degree map, a polarization angle map, and a cross-polarization and parallel polarization difference map, thus forming a polarization enhancement image.
[0065] S3. Construct the orientation field for the polarization-enhanced image, extract the first orientation candidate based on the phase gradient of the polarization angle map, extract the second orientation candidate based on the anisotropy measure of the cross-polarization and parallel polarization difference maps, perform phase unwrapping and sign disambiguation on the first and second orientation candidates, solve the global π-symmetric orientation field in the graph optimization process constrained by the boundary curve and the node ring region, and output the bamboo pattern orientation field.
[0066] S4. Based on the bamboo grain guide field, streamline segmentation is performed on the bamboo surface, dividing the image into streamline superpixel regions along the fiber direction, and each streamline region is unfolded into one-dimensional sequence data;
[0067] S5. Input the one-dimensional sequence data into the dual-stream state space detection model, wherein the sequence along the fiber direction is processed by the longitudinal state space branch, and the transverse adjacent sequences are processed by the transverse attention branch to obtain the defect candidate results.
[0068] S6. Detect the nodes on the bamboo surface, determine the rhythmic units between adjacent bamboo nodes, expand and normalize each rhythmic unit, and calculate the directional continuity index, polarization angle continuity index, reflection component conservation index and periodic symmetry index along the fiber direction and transverse direction according to the preset grid. Check the consistency of each index according to the calibration threshold and generate an abnormal response map.
[0069] S7. The defect candidate results are fused with the anomaly response map to obtain the final defect detection result, including defect category, location and size parameters.
[0070] In this embodiment, the multi-angle polarization imaging device refers to an imaging device including an industrial camera, an adjustable polarizer assembly, and a multi-angle illumination source. The industrial camera is used to acquire images of the bamboo surface, the adjustable polarizer assembly is used to modulate the polarization of the incident light at different angles, and the multi-angle illumination source is used to provide stable illumination in different incident directions to acquire image data at multiple polarization angles.
[0071] In this embodiment, S2 specifically includes:
[0072] S21. Perform radiometric correction, geometric registration and polarization axis calibration on images with different polarization angles, unify exposure, gain and white balance parameters, and obtain a set of corrected images that correspond one-to-one in spatial location.
[0073] S22. Perform polarization-consistent resampling and time alignment on the corrected image set to generate the intensity vector of each pixel at each polarization angle, and generate the corresponding effective pixel mask and angle reliability weight.
[0074] S23. Under the condition of satisfying the polarization propagation and interface reflection constraints, the intensity vector is demixed by the reflection component to obtain the specular component map, the diffuse reflection component map and the subsurface scattering trend map. The specular component map is used to suppress the specular glare and the angle offset and intensity mismatch are corrected according to the angle reliability weight to form the polarization consistency correction result.
[0075] S24. Based on the polarization consistency correction result, calculate the total intensity component and two orthogonal differential components, generate a polarization degree map and a polarization angle map, and generate a cross-polarization and parallel polarization difference map according to the difference relationship between parallel polarization and cross-polarization, and output a polarization confidence map formed by the effective pixel mask and the angle reliability weight.
[0076] S25. Perform dynamic range normalization and noise suppression on the polarization degree map, the polarization angle map, and the cross-polarization and parallel polarization difference map, and concatenate them with the polarization confidence map in a fixed channel order to form a polarization enhancement image.
[0077] In this embodiment, S3 specifically includes:
[0078] S31. Using the polarization angle map, polarization degree map, and cross-polarization and parallel polarization difference map as input data, establish a direction estimation domain with pixels as nodes.
[0079] S32. In the direction estimation domain, a first direction candidate is generated based on the phase gradient and local principal direction analysis of the polarization angle diagram, and weights are assigned to the first direction candidate according to the degree of polarization and angular stability.
[0080] S33. In the direction estimation domain, a second direction candidate is generated based on the anisotropy measure of the cross-polarization and parallel polarization difference map. The second direction candidate is a direction along the anisotropic principal axis or an orthogonal direction. Weights are assigned to the second direction candidate according to the difference magnitude and gradient stability.
[0081] S34. Perform phase unwrapping and symbol disambiguation in the local neighborhood. Use the minimum flip principle and path consistency principle to check the consistency between the first direction candidate and the second direction candidate, eliminate the directional ambiguity caused by 180-degree equivalence, and obtain a continuous initial direction field.
[0082] S35. Using the tangential constraints of the outer contour of the bamboo and the tangential constraints of the node ring area as hard constraints, and the smoothing term of the directional difference between adjacent pixels as soft constraints, the initial orientation field is optimized globally, and topological defect correction is performed during the optimization process to obtain a global orientation field that satisfies the 180-degree periodic symmetry.
[0083] S36. Calculate the local curvature and direction confidence based on the global direction field, wherein the direction confidence is jointly determined by the consistency between the first direction candidate and the second direction candidate and the polarization confidence, and the local curvature is determined by the rate of change of the direction in the spatial neighborhood. Output a bamboo-patterned guide field that includes direction, local curvature and confidence.
[0084] In this embodiment, S4 specifically includes:
[0085] S41. Using the bamboo pattern guide field as input, select a set of seed points in the image domain based on the local maxima of the direction confidence, combined with the condition that the local curvature does not exceed the preset threshold and the mutual spacing is not less than the preset minimum spacing, and exclude candidate points located in invalid regions and boundary buffer zones.
[0086] S42. Starting from each seed point, perform streamline tracking in the direction indicated by the bamboo pattern guide field and in the opposite direction until the image boundary and direction confidence are lower than the termination threshold, to obtain a set of non-intersecting streamlines with unique identifiers, and remove trajectories that are too short or repeat the already generated streamlines.
[0087] S43. Perform anisotropic region assignment calculation with streamline as the center. For any pixel, determine the assignment cost by combining the path consistency along the bamboo grain direction and the deviation penalty from the bamboo grain direction. Assign the pixel to the streamline region with the minimum cost to obtain a set of streamline superpixels that cover the image domain and do not overlap. Then, crop or merge regions that exceed the maximum width or are lower than the minimum width.
[0088] S44. Establish a local coordinate system for each streamline superpixel, with the streamline as the vertical axis and the direction orthogonal to the streamline as the horizontal axis, map the pixel coordinates in the region to the vertical position and horizontal offset, and perform directional confidence weighted aggregation on each channel of the polarization enhancement image within a limited horizontal bandwidth to generate a one-dimensional feature sequence sorted along the vertical position.
[0089] S45. For each one-dimensional feature sequence, perform length normalization and equal-interval resampling according to the vertical position to obtain one-dimensional sequence data of fixed length. At the same time, record the corresponding region identifier, start and end position, average direction, direction curvature statistics and direction confidence statistics.
[0090] In this embodiment, S5 specifically includes:
[0091] S51. Receive one-dimensional sequence data and construct a dual-stream state space detection model. The dual-stream state space detection model includes a vertical state space branch, a horizontal sparse attention branch, and a multi-task detection head.
[0092] S52. Construct a vertical state space branch, perform forward and backward state recursion twice for each one-dimensional sequence in sequence order, determine the control parameters of the update gate by combining the direction confidence and direction curvature, and use the update gate to dynamically adjust the writing and forgetting process of state information. Use finer step size to update the state in the node ring and high curvature region to obtain the vertical feature sequence.
[0093] S53. Construct a lateral sparse attention branch. Based on streamline geometry and bamboo pattern guide field, select a limited number of adjacent streamlines and a limited range of longitudinal windows for each position to form a sparse adjacency set. Add geometric alignment bias and polarization confidence bias to the attention weight calculation and output the lateral aggregated feature sequence.
[0094] S54. Perform two-stream fusion on the longitudinal feature sequence and the transverse aggregated feature sequence, calculate the fusion coefficient according to the position, and the fusion coefficient is jointly determined by the direction confidence, direction curvature and polarization confidence. During the fusion process, apply fiber smoothing constraint and transverse consistency constraint, while retaining the residual path of the input key channel to obtain the fused feature sequence.
[0095] S55. The fused feature sequence is fed into the multi-task detection head, which outputs the defect category probability, the vertical and horizontal position in the original image, the horizontal width and fiber length of the defect, and the pixel-level mask confidence for each position. The sequence coordinates are then restored to the original image coordinates in real time using the reverse mapping relationship and region identifier.
[0096] S56. Filter candidates of the same type according to the confidence threshold, and perform non-maximum suppression and consistency merging on candidates that are vertically adjacent or horizontally adjacent and spatially overlapping to obtain defect candidate results containing category, location, size and mask information.
[0097] In this embodiment, S6 specifically includes:
[0098] S61. Detect the nodes on the bamboo surface, scan along the bamboo grain direction in the image domain, identify the node areas in the form of rings, and extract the node center line in each node area.
[0099] S62. Define the region between any two adjacent node centerlines as a rhythmic unit, establish a reversible coordinate mapping for each rhythmic unit with the bamboo grain direction as the vertical axis and the horizontal axis orthogonal to the bamboo grain direction as the horizontal axis, and normalize the scale of the rhythmic unit in both the vertical and horizontal directions.
[0100] S63. Construct a two-dimensional grid with a fixed resolution in the normalized coordinate system of each rhythm unit, and resample the orientation angle, polarization angle, cross polarization and parallel polarization difference, orientation confidence and polarization degree according to the grid position to generate a multi-channel data sequence and effective pixel mask that correspond one-to-one with the grid.
[0101] S64. Within each rhythmic unit, calculate the four types of indicators sequentially using the vertical position as the index:
[0102] The directional continuity index is defined as the weighted average of the directional angle changes between adjacent longitudinal positions in the horizontal direction.
[0103] The polarization angle continuity index is defined as the weighted average of the polarization angle changes between adjacent longitudinal positions in the transverse direction, and processed according to the half-cycle equivalence rule.
[0104] The reflection component conservation index is defined as the average amplitude of the difference between cross-polarization and parallel polarization in the transverse direction.
[0105] The periodic symmetry index is defined as the complementary measure of the lateral distribution similarity between the current rhythm unit and its adjacent rhythm units at the same vertical position.
[0106] S65. Map the four types of indicators to a unified dimension interval, calculate the comprehensive anomaly score according to the preset weight, and compare it with the calibrated direction continuity threshold, polarization angle continuity threshold, reflection component conservation threshold, periodic symmetry threshold and comprehensive anomaly threshold one by one to generate a longitudinal anomaly response sequence and the pass or fail mark of each indicator.
[0107] S66. Based on the longitudinal anomaly response sequence and the horizontal confidence level, the anomaly response is horizontally expanded to form an anomaly response map corresponding to the two-dimensional grid, and then restored to the original image coordinate system through the reversible coordinate mapping to output the anomaly response map.
[0108] In this embodiment, obtaining the final detection result of the defect refers to matching the defect candidate results with the abnormal response map in spatial location, weighting and fusing the category probability, geometric parameters and abnormal response scores of the same location, and merging the candidates that are spatially adjacent and of the same category after confidence reordering and low confidence elimination, and finally outputting the final detection result containing defect category, location coordinates, geometric size and shape contour.
[0109] Example 1:
[0110] To verify the feasibility of this invention in practice, it was applied to the quality inspection process of a bamboo production line, where bamboo strips need to pass through an inspection device sequentially on a conveyor belt. Traditional methods rely primarily on manual visual inspection, with operators judging the presence of cracks, insect damage, or mold by observing the surface of the bamboo strips. However, due to the complex natural texture of bamboo and the susceptibility to misjudgments caused by changes in humidity and lighting conditions, manual inspection suffers from low efficiency and poor stability. To address this issue, this invention proposes a computer vision-based bamboo defect detection method. This method utilizes polarization imaging, orientation field construction, streamline superpixel segmentation, dual-flow state space modeling, and rhythmic unit consistency verification to ultimately fuse the defect detection results.
[0111] In practical applications, bamboo strips pass through the conveyor line at a rate of approximately 15 strips per minute. Multi-angle polarization cameras installed on the production line capture multi-angle polarization images of the surface of each bamboo strip. After image preprocessing, the system generates polarization degree maps, polarization angle maps, and cross-parallel difference maps to form a polarization-enhanced image. Subsequently, the system constructs a bamboo grain guide field based on the phase gradient of the polarization angle and the anisotropy measure of the difference map, obtaining a continuous and globally consistent fiber orientation distribution. The bamboo strip image is segmented into several streamlined superpixel regions and unfolded into a one-dimensional sequence input dual-stream state-space detection model. The model's longitudinal branches can capture cracks distributed along the fiber direction, while the transverse branches can aggregate transverse features such as insect infestation and mold.
[0112] In the node ring region, the system further defines adjacent nodes as rhythmic units and calculates four types of indices within these units: directional continuity, polarization angle continuity, reflection component conservation, and periodic symmetry. When these indices do not meet preset thresholds, an anomaly response map is generated and fused with the defect candidate results. The final output includes not only the defect category but also information such as the defect's location, lateral width, vertical length, area, and mask confidence level in the original image. Through this invention, bamboo strip detection is automated and stabilized, reducing human error and missed detections.
[0113] To verify the performance of the method of this invention, data collection and comparative experiments were conducted on a production line that operated continuously for one week. During this period, a sample of bamboo strips was randomly selected daily for comparison between manual inspection and the inspection method of this invention. The detection results of three types of defects—cracks, insect infestation, and mold—were statistically analyzed. The experimental results show that the method of this invention is superior to manual inspection in terms of detection accuracy, false negative rate, and average inspection time, demonstrating good practicality and stability.
[0114] Table 1 Comparison of the method of the present invention and manual detection results
[0115] Detection object Sample size Accuracy rate of manual testing (%) The detection accuracy rate (%) of this invention Manual missed detection rate (%) The false negative rate (%) of this invention Average detection time (seconds / piece) crack 500 87.2 94.8 12.1 5.6 0.32 Insects 420 86.5 95.2 13.4 5.1 0.29 Mold 380 84.7 93.9 14.8 6.2 0.31 scars 300 83.9 92.6 15.7 7.3 0.30 Color difference 260 85.3 93.1 13.9 6.4 0.28 Overall Average 1860 85.6 94.1 13.9 6.1 0.30
[0116] As can be seen from the data in Table 1 above, the method of the present invention demonstrates significantly better performance than manual inspection in detecting various bamboo defects. Taking cracks as an example, in 500 samples, the accuracy rate of manual inspection was 87.2%, while the accuracy rate of the method of the present invention reached 94.8%, and the false negative rate was reduced from 12.1% to 5.6%. This indicates that in the identification of cracks with complex fiber orientations, the present invention can effectively suppress bamboo grain interference and significantly improve the reliability of detection.
[0117] Among the two types of defects, insect infestation and mold, the advantages of the method of this invention are more prominent. The accuracy of insect infestation detection improved by nearly 9 percentage points, and the false negative rate decreased from 13.4% to 5.1%; the accuracy of mold detection increased from 84.7% to 93.9%, and the false negative rate decreased from 14.8% to 6.2%. This indicates that by introducing polarization-enhanced imaging and rhythmic unit consistency indicators, this invention can better distinguish subtle lateral anomalies and surface changes affected by the environment. For complex surface defects such as scars and color differences, the method of this invention also improved the accuracy by about 8 to 9 percentage points and reduced the false negative rate by more than half, verifying its adaptability and robustness under different types of defects.
[0118] In summary, in a comparison of 1860 samples, the average accuracy rate of manual inspection was 85.6%, while the method of this invention reached 94.1%; the false negative rate of manual inspection was 13.9%, while that of this invention was only 6.1%. Furthermore, the average inspection time of this invention is only 0.30 seconds per piece, far faster than the time required for manual inspection, meeting the needs of real-time inspection on the production line. This invention not only improves inspection accuracy and reduces the false negative rate, but also combines high efficiency and stability, effectively solving the problems of low efficiency, high false positive rate, and poor environmental adaptability of manual inspection in the prior art.
[0119] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A method for detecting defects in bamboo based on computer vision, characterized in that, Includes the following steps: S1. Obtain images of the bamboo surface using a multi-angle polarization imaging device to obtain polarization intensity image data; S2. Process the polarization intensity image data to generate a polarization degree map, a polarization angle map, and a cross-polarization and parallel polarization difference map, thus forming a polarization enhancement image. S3. Construct the orientation field for the polarization-enhanced image, extract the first orientation candidate based on the phase gradient of the polarization angle map, extract the second orientation candidate based on the anisotropy measure of the cross-polarization and parallel polarization difference maps, perform phase unwrapping and sign disambiguation on the first and second orientation candidates, solve the global π-symmetric orientation field in the graph optimization process constrained by the boundary curve and the node ring region, and output the bamboo pattern orientation field. S4. Based on the bamboo grain guide field, streamline segmentation is performed on the bamboo surface, dividing the image into streamline superpixel regions along the fiber direction, and each streamline region is unfolded into one-dimensional sequence data; S5. Input the one-dimensional sequence data into the dual-stream state space detection model, wherein the sequence along the fiber direction is processed by the longitudinal state space branch, and the transverse adjacent sequences are processed by the transverse attention branch to obtain the defect candidate results. S6. Detect the nodes on the bamboo surface, determine the rhythmic units between adjacent bamboo nodes, expand and normalize each rhythmic unit, and calculate the directional continuity index, polarization angle continuity index, reflection component conservation index and periodic symmetry index along the fiber direction and transverse direction according to the preset grid. Check the consistency of each index according to the calibration threshold and generate an abnormal response map. S7. The defect candidate results are fused with the anomaly response map to obtain the final defect detection result, including defect category, location and size parameters.
2. The method for detecting bamboo defects based on computer vision according to claim 1, characterized in that, The multi-angle polarization imaging device refers to an imaging device including an industrial camera, an adjustable polarizer assembly, and a multi-angle illumination source. The industrial camera is used to acquire images of the bamboo surface, the adjustable polarizer assembly is used to modulate the polarization of the incident light at different angles, and the multi-angle illumination source is used to provide stable illumination in different incident directions to acquire image data at multiple polarization angles.
3. The method for detecting bamboo defects based on computer vision according to claim 1, characterized in that, S2 specifically includes: S21. Perform radiometric correction, geometric registration and polarization axis calibration on images with different polarization angles, unify exposure, gain and white balance parameters, and obtain a set of corrected images that correspond one-to-one in spatial location. S22. Perform polarization-consistent resampling and time alignment on the corrected image set to generate the intensity vector of each pixel at each polarization angle, and generate the corresponding effective pixel mask and angle reliability weight. S23. Under the condition of satisfying the polarization propagation and interface reflection constraints, the intensity vector is demixed by the reflection component to obtain the specular component map, the diffuse reflection component map and the subsurface scattering trend map. The specular component map is used to suppress the specular glare and the angle offset and intensity mismatch are corrected according to the angle reliability weight to form the polarization consistency correction result. S24. Based on the polarization consistency correction result, calculate the total intensity component and two orthogonal differential components, generate a polarization degree map and a polarization angle map, and generate a cross-polarization and parallel polarization difference map according to the difference relationship between parallel polarization and cross-polarization, and output a polarization confidence map formed by the effective pixel mask and the angle reliability weight. S25. Perform dynamic range normalization and noise suppression on the polarization degree map, the polarization angle map, and the cross-polarization and parallel polarization difference map, and concatenate them with the polarization confidence map in a fixed channel order to form a polarization enhancement image.
4. The method for detecting bamboo defects based on computer vision according to claim 1, characterized in that, S3 specifically includes: S31. Using the polarization angle map, polarization degree map, and cross-polarization and parallel polarization difference map as input data, establish a direction estimation domain with pixels as nodes. S32. In the direction estimation domain, a first direction candidate is generated based on the phase gradient and local principal direction analysis of the polarization angle diagram, and weights are assigned to the first direction candidate according to the degree of polarization and angular stability. S33. In the direction estimation domain, a second direction candidate is generated based on the anisotropy measure of the cross-polarization and parallel polarization difference map. The second direction candidate is a direction along the anisotropic principal axis or an orthogonal direction. Weights are assigned to the second direction candidate according to the difference magnitude and gradient stability. S34. Perform phase unwrapping and symbol disambiguation in the local neighborhood. Use the minimum flip principle and path consistency principle to check the consistency between the first direction candidate and the second direction candidate, eliminate the directional ambiguity caused by 180-degree equivalence, and obtain a continuous initial direction field. S35. Using the tangential constraints of the outer contour of the bamboo and the tangential constraints of the node ring area as hard constraints, and the smoothing term of the directional difference between adjacent pixels as soft constraints, the initial orientation field is optimized globally, and topological defect correction is performed during the optimization process to obtain a global orientation field that satisfies the 180-degree periodic symmetry. S36. Calculate the local curvature and direction confidence based on the global direction field, wherein the direction confidence is jointly determined by the consistency between the first direction candidate and the second direction candidate and the polarization confidence, and the local curvature is determined by the rate of change of the direction in the spatial neighborhood. Output a bamboo-patterned guide field that includes direction, local curvature and confidence.
5. The method for detecting bamboo defects based on computer vision according to claim 1, characterized in that, S4 specifically includes: S41. Using the bamboo pattern guide field as input, select a set of seed points in the image domain based on the local maxima of the direction confidence, combined with the condition that the local curvature does not exceed the preset threshold and the mutual spacing is not less than the preset minimum spacing, and exclude candidate points located in invalid regions and boundary buffer zones. S42. Starting from each seed point, perform streamline tracking in the direction indicated by the bamboo pattern guide field and in the opposite direction until the image boundary and direction confidence are lower than the termination threshold, to obtain a set of non-intersecting streamlines with unique identifiers, and remove trajectories that are too short or repeat the already generated streamlines. S43. Perform anisotropic region assignment calculation with streamline as the center. For any pixel, determine the assignment cost by combining the path consistency along the bamboo grain direction and the deviation penalty from the bamboo grain direction. Assign the pixel to the streamline region with the minimum cost to obtain a set of streamline superpixels that cover the image domain and do not overlap. Then, crop or merge regions that exceed the maximum width or are lower than the minimum width. S44. Establish a local coordinate system for each streamline superpixel, with the streamline as the vertical axis and the direction orthogonal to the streamline as the horizontal axis, map the pixel coordinates in the region to the vertical position and horizontal offset, and perform directional confidence weighted aggregation on each channel of the polarization enhancement image within a limited horizontal bandwidth to generate a one-dimensional feature sequence sorted along the vertical position. S45. For each one-dimensional feature sequence, perform length normalization and equal-interval resampling according to the vertical position to obtain one-dimensional sequence data of fixed length. At the same time, record the corresponding region identifier, start and end position, average direction, direction curvature statistics and direction confidence statistics.
6. The method for detecting bamboo defects based on computer vision according to claim 1, characterized in that, S5 specifically includes: S51. Receive one-dimensional sequence data and construct a dual-stream state space detection model. The dual-stream state space detection model includes a vertical state space branch, a horizontal sparse attention branch, and a multi-task detection head. S52. Construct a vertical state space branch, perform forward and backward state recursion twice for each one-dimensional sequence in sequence order, determine the control parameters of the update gate by combining the direction confidence and direction curvature, and use the update gate to dynamically adjust the writing and forgetting process of state information. Use finer step size to update the state in the node ring and high curvature region to obtain the vertical feature sequence. S53. Construct a lateral sparse attention branch. Based on streamline geometry and bamboo pattern guide field, select a limited number of adjacent streamlines and a limited range of longitudinal windows for each position to form a sparse adjacency set. Add geometric alignment bias and polarization confidence bias to the attention weight calculation and output the lateral aggregated feature sequence. S54. Perform two-stream fusion on the longitudinal feature sequence and the transverse aggregated feature sequence, calculate the fusion coefficient according to the position, and the fusion coefficient is jointly determined by the direction confidence, direction curvature and polarization confidence. During the fusion process, apply fiber smoothing constraint and transverse consistency constraint, while retaining the residual path of the input key channel to obtain the fused feature sequence. S55. The fused feature sequence is fed into the multi-task detection head, which outputs the defect category probability, the vertical and horizontal position in the original image, the horizontal width and fiber length of the defect, and the pixel-level mask confidence for each position. The sequence coordinates are then restored to the original image coordinates in real time using the reverse mapping relationship and region identifier. S56. Filter candidates of the same type according to the confidence threshold, and perform non-maximum suppression and consistency merging on candidates that are vertically adjacent or horizontally adjacent and spatially overlapping to obtain defect candidate results containing category, location, size and mask information.
7. The method for detecting bamboo defects based on computer vision according to claim 1, characterized in that, S6 specifically includes: S61. Detect the nodes on the bamboo surface, scan along the bamboo grain direction in the image domain, identify the node areas in the form of rings, and extract the node center line in each node area. S62. Define the region between any two adjacent node centerlines as a rhythmic unit, establish a reversible coordinate mapping for each rhythmic unit with the bamboo grain direction as the vertical axis and the horizontal axis orthogonal to the bamboo grain direction as the horizontal axis, and normalize the scale of the rhythmic unit in both the vertical and horizontal directions. S63. Construct a two-dimensional grid with a fixed resolution in the normalized coordinate system of each rhythm unit, and resample the orientation angle, polarization angle, cross polarization and parallel polarization difference, orientation confidence and polarization degree according to the grid position to generate a multi-channel data sequence and effective pixel mask that correspond one-to-one with the grid. S64. Within each rhythmic unit, calculate the four types of indicators sequentially using the vertical position as the index: The directional continuity index is defined as the weighted average of the directional angle changes between adjacent longitudinal positions in the horizontal direction. The polarization angle continuity index is defined as the weighted average of the polarization angle changes between adjacent longitudinal positions in the transverse direction, and processed according to the half-cycle equivalence rule. The reflection component conservation index is defined as the average amplitude of the difference between cross-polarization and parallel polarization in the transverse direction. The periodic symmetry index is defined as the complementary measure of the lateral distribution similarity between the current rhythm unit and its adjacent rhythm units at the same vertical position. S65. Map the four types of indicators to a unified dimension interval, calculate the comprehensive anomaly score according to the preset weight, and compare it with the calibrated direction continuity threshold, polarization angle continuity threshold, reflection component conservation threshold, periodic symmetry threshold and comprehensive anomaly threshold one by one to generate a longitudinal anomaly response sequence and the pass or fail mark of each indicator. S66. Based on the longitudinal anomaly response sequence and the horizontal confidence level, the anomaly response is horizontally expanded to form an anomaly response map corresponding to the two-dimensional grid, and then restored to the original image coordinate system through the reversible coordinate mapping to output the anomaly response map.
8. The method for detecting bamboo defects based on computer vision according to claim 1, characterized in that, The final detection result of the defect refers to the spatial correspondence between the defect candidate results and the abnormal response map, the weighted fusion of the category probability, geometric parameters and abnormal response scores of the same location, the confidence reordering and low confidence elimination, the merging of candidates that are spatially adjacent and of the same category, and finally outputting the final detection result containing defect category, location coordinates, geometric size and shape contour.
Citation Information
Cited By
A polarization-guided target detection method and system for complex optical scenarios
CN122313026A