A cherry defect detection system based on feature fusion attention mechanism
The cherry defect detection system, which utilizes a feature fusion attention mechanism, combines dual-angle feature capture and three-dimensional scanning to solve the problem of insufficient ability to identify insect holes on cherry surfaces, thus achieving efficient and accurate cherry defect detection.
Patent Information
- Application Number
- CN202411951018.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2044-12-27
AI Technical Summary
Current cherry defect detection methods, especially for identifying insect-eaten holes in recessed areas, are poor and struggle to accurately identify defects under complex lighting conditions and small-sized features.
A cherry defect detection system based on feature fusion attention mechanism is adopted. The system acquires first and second feature data through a dual-angle feature capture processing module. Combined with a depression area recognition module and a 3D scanner, the system uses a depression area scanning unit, a defect feature analysis unit, and a feature fusion detection unit to perform feature weighting calculation and threshold comparison, thereby achieving accurate identification of depression areas and insect holes on the cherry surface.
It improves the accuracy and robustness of cherry wormhole identification, reduces false positives and false negatives, adapts to the diverse characteristics of cherry samples, and improves detection efficiency.
Smart Images

Figure CN119845953B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cherry defect detection technology, and more specifically, to a cherry defect detection system based on a feature fusion attention mechanism. Background Technology
[0002] During the growth process, cherries are prone to deformed fruits such as irritated cherries and twin cherries due to the influence of genetics, environmental stress, improper use of plant growth regulators, and pest and disease attacks. Accurate identification of cherry defects is of great significance for improving the overall quality assessment, reducing economic losses, and optimizing automated harvesting systems. Traditional cherry defect detection and identification mainly rely on manual visual inspection. This method is time-consuming and labor-intensive, and is not suitable for large-scale inspection. Existing technologies use feature fusion attention mechanism to detect and identify cherry defects. For example, existing literature ([1] Dai Dongnan, Ma Rui, Liu Qi, et al. Research on cherry defect detection and identification based on feature fusion attention mechanism [J]. Shandong Agricultural Sciences, 2024, 56(03): 154-162. DO I: 10.14083 / ji ssn.1001-4942.2024.03.021.) uses feature fusion attention mechanism to identify defective cherries. This not only saves time and labor, but also effectively reduces the secondary damage to cherry fruits caused by manual sorting. Moreover, the lightweight network structure also improves its feasibility for deployment in mobile intelligent screening equipment. However, the ability to identify insect holes in the concave areas of cherry surface is still poor.
[0003] The main challenge in identifying wormholes on cherry surfaces lies in the complex light and shadow variations in the recessed areas. Due to changes in surface curvature, these areas are prone to deviations in the angle of light reflection, resulting in uneven lighting in the acquired images, forming shadows or bright spots. This phenomenon not only interferes with the texture contrast between the wormholes and the normal surface but may also obscure the edge features of the wormholes. Furthermore, wormholes are typically small, varied in shape, and lack obvious geometric features, making it difficult for traditional image processing methods (such as edge detection or texture analysis) to accurately identify them. To address these issues, a technical solution is proposed. Summary of the Invention
[0004] To overcome the aforementioned deficiencies of the prior art, the present invention provides a cherry defect detection system based on a feature fusion attention mechanism, which addresses the problem that the existing technology still has poor ability to identify insect holes in the concave areas of cherry surfaces, thereby solving the problems mentioned in the background art.
[0005] To achieve the above objectives, the present invention provides the following technical solution:
[0006] A cherry defect detection system based on a feature fusion attention mechanism includes a dual-angle feature capture and processing module, a recessed region identification module, and a wormhole detection module. The dual-angle feature capture and processing module acquires first and second feature data of the cherry sample. The recessed region identification module determines the recessed region of the cherry sample based on the first and second feature data. The wormhole detection module extracts defect features from the recessed regions of the cherry sample and determines whether wormholes exist based on these features. The wormhole detection module includes a recessed region scanning unit, a defect feature analysis unit, and a feature fusion detection unit. The recessed region scanning unit acquires the final recessed region R of the cherry sample using a 3D scanner. f A three-dimensional region mesh model is used; the defect feature analysis unit is used to analyze and obtain the defect features of the cherry sample based on the three-dimensional region mesh model; the defect features of the cherry sample include a first defect feature and a second defect feature; the feature fusion detection unit is used to fuse the defect features of the cherry sample and determine whether the cherry sample has wormholes: by extracting the first defect feature and the second defect feature, the first defect feature and the second defect feature are normalized to obtain the normalized first defect feature ΔZ. d ′ and the second defect feature α p Based on the attention mechanism, the defect fusion feature value is calculated using feature weighting.
[0007]
[0008] ω1+ω2=1;
[0009] In the formula: F fu For defect fusion eigenvalues, ΔZ d ' is the first defect feature after normalization of the d-th surface point, ΔZ d Let α be the first defect feature of the d-th surface point, where D is the number of surface points. p ′ represents the second defect feature after normalization of vertex p, α p Let P be the second defect feature of vertex p, where P is the number of vertices.
[0010] As a further embodiment of the present invention, the dual-angle feature capture processing module includes an image acquisition unit, an image processing module, and a feature data capture unit;
[0011] The image acquisition unit is used to acquire first-angle cherry images and second-angle cherry images of cherry samples using a high-definition camera. The dual-angle cherry images are obtained by acquiring the maximum diameter of the cherry sample with the concave surface, taking the midpoint of the maximum diameter as the vertical line as the central axis of the cherry, calculating the center distance between the outermost left and right sides of the cherry and the central axis, taking the center of the left and right center distances as the base point, and acquiring cherry images at the same height as the base point using a high-definition camera. The cherry image captured by the high-definition camera on the left is the first-angle cherry image, and the cherry image captured by the high-definition camera on the right is the second-angle cherry image.
[0012] The image processing module is used to perform histogram equalization and noise removal on the cherry images from the first angle and the cherry images from the second angle.
[0013] The feature data capture unit is used to extract the pixel values of the first-angle cherry image and the second-angle cherry image output by the image processing module to obtain the first feature data and the second feature data of the cherry sample; the first feature data is the pixel value of the first-angle cherry image; the second feature data is the pixel value of the second-angle cherry image.
[0014] As a further embodiment of the present invention, the depression region identification module includes a primary data acquisition unit, a depression region calculation unit, and a depression region positioning unit.
[0015] The primary data acquisition unit is used to acquire the first and second characteristic data of the cherry samples;
[0016] The concave region calculation unit is used to construct a concave region pixel coefficient calculation model based on the first feature data and the second feature data, and to preliminarily determine the concave region of each cherry sample.
[0017] The recessed region localization unit determines the location of the recessed region based on the pixel coefficients of the recessed region of the cherry sample.
[0018] As a further aspect of the present invention, the concave region calculation unit is used to construct a concave region pixel coefficient calculation model based on the first feature data and the second feature data, and to preliminarily determine the concave region of each cherry sample: the first feature data and the second feature data of each angle of a single cherry sample are imported into the concave region pixel coefficient calculation model to calculate the concave region pixel coefficient. The calculation formula of the concave region pixel coefficient calculation model is as follows:
[0019]
[0020]
[0021] Where: β p β represents the pixel coefficient for the concave region. aThe pixel coefficients for the first concave region are... Let be the first feature data located at (x1, y1) in the cherry image from the first angle. The mean of the first feature data in the cherry image from the first angle. The largest first feature data in the cherry image from the first angle. β is the smallest first feature data in the cherry image at the first angle. b The pixel coefficients for the second concave region are... This represents the second feature data located at (x2, y2) in the cherry image from the second angle. The mean of the second feature data in the cherry image from the second angle. The second feature data is the largest second feature data in the cherry image from the second angle. This represents the minimum second feature data in the cherry image from the second angle.
[0022] As a further aspect of the present invention, the recessed region localization unit determines the location of the recessed region based on the pixel coefficients of the recessed region of the cherry sample: extracting the pixel coefficients of the recessed region of a single cherry sample, as well as the first feature data and the second feature data, respectively; comparing the pixel coefficients of the recessed region with the first feature data; if the first feature data is greater than or equal to the pixel coefficients of the recessed region, then the location corresponding to the first feature data is not a recessed region; if the pixel coefficients of the recessed region are less than the first feature data, then the location corresponding to the first feature data is a recessed region; obtaining the coordinates of the determined recessed region location, and generating a first recessed region coordinate set R1 = {(x1, y1)};
[0023] Compare the pixel coefficients of the concave region with the second feature data. If the second feature data is greater than or equal to the pixel coefficients of the concave region, then the position of the corresponding second feature data is not a concave region; if the pixel coefficients of the concave region are less than the second feature data, then the position of the corresponding second feature data is a concave region; obtain the coordinates of the concave region and generate the coordinate set R2 = {(x2, y2)} of the second concave region.
[0024] Obtain the coordinate set r1 = {(x1, y1)} of the first concave region and the coordinate set r2 = {(x2, y2)} of the second concave region. Based on the intersection of the coordinate sets of the first and second concave regions, determine the final concave region R of the cherry sample. f =R1∩R2.
[0025] As a further aspect of the present invention, the defect feature analysis unit is used to analyze and obtain the defect features of cherry samples based on a three-dimensional regional mesh model;
[0026] The first defect feature is obtained by fitting a three-dimensional regional mesh model, calculating the average depth of the final recessed area, and taking the difference between each surface point and the average depth as the first defect feature.
[0027] ΔZ d =Z d -Z surface ;
[0028] In the formula: ΔZ d Z represents the first defect feature of the d-th surface point. d Z represents the depth value of the d-th surface point. surface This represents the average depth of the final concave region.
[0029] The second defect feature is calculated by determining the normal vector of each mesh vertex based on the 3D region mesh model, and then calculating the normal deviation angle of each mesh vertex as the second defect feature.
[0030]
[0031] In the formula: α p This is the second defect feature of vertex p. Let be the normal vector of vertex p. Let p be the normal vector of the neighboring points of vertex p, arccos is the inverse cosine function of the angle between the two normal vectors, and N is the number of neighboring vertices.
[0032] The technical effects and advantages of this invention, a cherry defect detection system based on feature fusion and attention mechanism, are as follows: This invention acquires first and second feature data of a cherry sample, determines the concave areas of the cherry sample based on these data, extracts defect features from the concave areas, fuses the defect features, and determines whether the cherry sample has wormholes. The first feature data effectively captures the depth information of the concave area, accurately describing the degree of concavity, while the second feature data captures the sharpness and variation trend of the concave area's edge, supplementing the shortcomings of depth features. Feature weights are dynamically allocated according to the detection scenario, enabling the system to flexibly adapt to diverse cherry sample characteristics, reducing misjudgments or missed detections that may be caused by a single feature, and improving the accuracy of identification. By calculating defect feature values through feature fusion and comparing them with a threshold, the location of wormholes is accurately marked, effectively distinguishing between natural concavities and wormhole areas. This invention, by fusing multiple features and introducing an attention mechanism, accurately identifies concave areas and wormholes on the cherry surface, effectively solving the problem of poor existing wormhole detection capabilities and improving the accuracy, robustness, and efficiency of cherry wormhole identification. Attached Figure Description
[0033] Figure 1A schematic diagram illustrating the configuration of the image acquisition unit provided by this invention for acquiring cherry images;
[0034] Figure 2 This is a schematic diagram of the structure of a cherry defect detection system based on a feature fusion attention mechanism provided by the present invention. Detailed Implementation
[0035] The technical solutions of this invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described technical solutions are only a part of this invention, and not all of it. All other technical solutions obtained by those skilled in the art based on the technical solutions of this invention without inventive effort are within the scope of protection of this invention.
[0036] A cherry defect detection system based on feature fusion attention mechanism includes a dual-angle feature capture and processing module, a concave region recognition module, and a wormhole detection module; the dual-angle feature capture and processing module is connected to the concave region recognition module, and the concave region recognition module is connected to the wormhole detection module.
[0037] The dual-angle feature capture and processing module is used to acquire the first feature data and the second feature data of the cherry sample;
[0038] The depression region identification module is used to determine the depression region of the cherry sample based on the first feature data and the second feature data;
[0039] The insect-hole detection module is used to extract defect features based on the concave areas of cherry samples and to determine whether there are insect holes in the cherry samples based on the defect features.
[0040] It should be noted that the cherry samples are cherries with wormholes in several surface depressions.
[0041] Specifically, the dual-angle feature capture and processing module includes an image acquisition unit, an image processing module, and a feature data capture unit; the image acquisition unit is connected to the image processing module, and the image processing module is connected to the feature data capture unit.
[0042] The image acquisition unit is used to acquire first-angle cherry images and second-angle cherry images of cherry samples using a high-definition camera. The dual-angle cherry images are obtained by acquiring the maximum diameter of the cherry sample with the concave surface, taking the midpoint of the maximum diameter as the vertical line as the central axis of the cherry, calculating the center distance between the outermost left and right sides of the cherry and the central axis, taking the center of the left and right center distances as the base point, and acquiring cherry images at the same height as the base point using a high-definition camera. The cherry image captured by the high-definition camera on the left is the first-angle cherry image, and the cherry image captured by the high-definition camera on the right is the second-angle cherry image.
[0043] like Figure 1 The diagram shows the configuration of the image acquisition unit for cherry image acquisition. It includes a high-definition camera 1, a filter 2, a cherry sample 3, a matte black background 4, a liquid light guide 5, a halogen light source 6, a monochromator 7, and a computer 8. The halogen light source 6 provides illumination. After the light is filtered to a specific wavelength by the monochromator 7, it is transmitted to the cherry sample through the liquid light guide 5. The sample image is acquired by the high-definition camera 1 and optimized with the filter 2. Finally, the image is transmitted to the computer 8 for processing and analysis. The matte black background is used to reduce interference and make the characteristics of the cherry sample more prominent.
[0044] The image processing module is used to perform histogram equalization and noise removal on the cherry images from the first angle and the cherry images from the second angle.
[0045] The feature data capture unit is used to extract the pixel values of the first-angle cherry image and the second-angle cherry image output by the image processing module to obtain the first feature data and the second feature data of the cherry sample; the first feature data is the pixel value of the first-angle cherry image; the second feature data is the pixel value of the second-angle cherry image.
[0046] Imaging cherry samples from two angles covers different directions and surface features of the concave area, reducing information that might be missed in single-angle images. Acquisition methods based on the maximum diameter and central axis allow for accurate targeting of the concave area, improving the efficiency of feature capture. Combining the two-angle images provides spatial information about the surface's unevenness, aiding in more precise identification of the concave features of the cherry sample. Feature data from images at different angles can be used to analyze the changes in the concave area under varying viewing angles, improving the robustness of defect detection algorithms. Increased image contrast makes detailed features clearer, especially under complex lighting conditions or when the sample surface is reflective. This also eliminates noise interference in the acquired images, enhancing image quality and ensuring the accuracy and reliability of extracted feature data. Directly extracting feature data based on pixel values avoids complex intermediate calculations and transformations, ensuring data integrity and accuracy. Providing pixel feature data from two directions facilitates subsequent differential analysis or fusion algorithms, enhancing the identification capability of concave areas.
[0047] The depression region identification module includes a primary data acquisition unit, a depression region calculation unit, and a depression region positioning unit. The primary data acquisition unit is connected to the depression region calculation unit, and the depression region calculation unit is connected to the depression region positioning unit.
[0048] The primary data acquisition unit is used to acquire the first and second characteristic data of the cherry samples;
[0049] The concave region calculation unit is used to construct a concave region pixel coefficient calculation model based on the first feature data and the second feature data, and to preliminarily determine the concave region of each cherry sample.
[0050] The recessed region localization unit determines the location of the recessed region based on the pixel coefficients of the recessed region of the cherry sample.
[0051] The concave region calculation unit is used to construct a concave region pixel coefficient calculation model based on the first feature data and the second feature data, and to initially determine the concave region of each cherry sample: the first feature data and the second feature data of each angle of a single cherry sample are imported into the concave region pixel coefficient calculation model to calculate the pixel coefficient of the concave region. The calculation formula of the concave region pixel coefficient calculation model is as follows:
[0052]
[0053] Where: β p β represents the pixel coefficient for the concave region. a The pixel coefficients for the first concave region are... Let be the first feature data located at (x1, y1) in the cherry image from the first angle. The mean of the first feature data in the cherry image from the first angle. The largest first feature data in the cherry image from the first angle. β is the smallest first feature data in the cherry image at the first angle. b The pixel coefficients for the second concave region are... This represents the second feature data located at (x2, y2) in the cherry image from the second angle. The mean of the second feature data in the cherry image from the second angle. The second feature data is the largest second feature data in the cherry image from the second angle. This represents the minimum second feature data in the cherry image from the second angle.
[0054] By utilizing feature data from the first and second angles, pixel coefficients for the concave region are constructed, avoiding missed detections caused by single-angle images. The fusion of dual-angle data provides more comprehensive sample surface information, especially the characteristics of complex concave regions. Using feature data from different angles, the mean, maximum, and minimum values are calculated and normalized to reduce the influence of interference factors such as background illumination or reflection. By calculating the average value of the pixel coefficients in the concave region, the overall degree of concavity on the sample surface is judged, reducing errors caused by local outliers. The concave region localization unit can accurately locate the position of the concave region by analyzing the pixel coefficients, improving the accuracy of concavity detection. Concavity detection is divided into three modules: primary data acquisition, concave region calculation, and concave region localization. Each module has a clear division of labor, reducing redundant calculations. Calculations are performed only on pixels in the concave region, rather than performing complex processing on the entire image, significantly improving computational efficiency. The calculation of the mean and normalization of pixel data can smooth noise in the image, while noise has a relatively small impact on the overall pixel coefficients of the concave region.
[0055] Specifically, the recessed region localization unit determines the location of the recessed region based on the pixel coefficients of the recessed region of the cherry sample: extracting the pixel coefficients of the recessed region of a single cherry sample, as well as the first feature data and the second feature data, respectively; comparing the pixel coefficients of the recessed region with the first feature data; if the first feature data is greater than or equal to the pixel coefficients of the recessed region, then the location corresponding to the first feature data is not a recessed region; if the pixel coefficients of the recessed region are less than the first feature data, then the location corresponding to the first feature data is a recessed region; obtaining the coordinates of the determined recessed region location, and generating the first recessed region coordinate set R1 = {(x1, y1)};
[0056] Compare the pixel coefficients of the concave region with the second feature data. If the second feature data is greater than or equal to the pixel coefficients of the concave region, then the position of the corresponding second feature data is not a concave region; if the pixel coefficients of the concave region are less than the second feature data, then the position of the corresponding second feature data is a concave region; obtain the coordinates of the concave region and generate the coordinate set R2 = {(x2, y2)} of the second concave region.
[0057] Obtain the coordinate set R1 = {(x1, y1)} of the first concave region and the coordinate set R2 = {(x2, y2)} of the second concave region. Based on the intersection of the coordinate sets of the first and second concave regions, determine the final concave region R of the cherry sample. f =R1∩R2.
[0058] The first and second feature data are compared with the pixel coefficients of the concave region to generate two independent sets of concave region coordinates. Through intersection operations, errors that might be caused by single-angle features are eliminated, improving the reliability and accuracy of the positioning results. By comparing the pixel coefficients of the concave region with the feature data, the pixel positions of the concave region can be accurately identified, avoiding the mislabeling of non-concave regions as concave. Single-angle feature data may be affected by local reflections, acquisition angles, etc. By combining the feature data from two angles and taking their intersection, deviations caused by anomalies in single-angle data are effectively eliminated. Concave regions can be quickly identified by comparing pixel values with the pixel coefficients of the concave region. It has low computational cost and can efficiently process large batches of samples; it is not limited to the current feature data definition and can be extended to other features (such as curvature, normal deviation, etc.). By adjusting the calculation method of pixel coefficients in concave areas, it can adapt to more detection scenarios. At present, it combines feature data from two angles, and in the future, it can be extended to multi-angle feature fusion (such as adding top or bottom views) to further improve the comprehensiveness of concave area detection; the independent comparison results of the first feature data and the second feature data can be analyzed separately to help judge the quality of specific angle data and the source of potential errors. By eliminating inconsistent areas through intersection, it further reduces false alarms caused by single-angle acquisition and improves the reliability of the results.
[0059] Specifically, the insect eye detection module includes a recessed area scanning unit, a defect feature analysis unit, and a feature fusion detection unit; the recessed area scanning unit is connected to the defect feature analysis unit, and the defect feature analysis unit is connected to the feature fusion detection unit.
[0060] The recessed area scanning unit is used to acquire the final recessed area R of the cherry sample using a 3D scanner. f A three-dimensional region mesh model;
[0061] The defect feature analysis unit is used to analyze and obtain the defect features of cherry samples based on the three-dimensional region mesh model; the defect features of cherry samples include first defect features and second defect features;
[0062] The feature fusion detection unit is used to fuse the defect features of cherry samples and determine whether there are wormholes in the cherry samples.
[0063] Specifically, the defect feature analysis unit is used to analyze and obtain the defect features of cherry samples based on the three-dimensional region mesh model;
[0064] The first defect feature is obtained by fitting a three-dimensional regional mesh model, calculating the average depth of the final recessed area, and taking the difference between each surface point and the average depth as the first defect feature.
[0065] ΔZ d =Z d -Z surface ;
[0066] In the formula: ΔZ d Z represents the first defect feature of the d-th surface point. d Z represents the depth value of the d-th surface point. surface This represents the average depth of the final concave region.
[0067] The second defect feature is calculated by determining the normal vector of each mesh vertex based on the 3D region mesh model, and then calculating the normal deviation angle of each mesh vertex as the second defect feature.
[0068]
[0069] In the formula: α p This is the second defect feature of vertex p. Let be the normal vector of vertex p. Let p be the normal vector of the neighboring points of vertex p, arccos is the inverse cosine function of the angle between the two normal vectors, and N is the number of neighboring vertices.
[0070] Using a 3D scanner to obtain a 3D mesh model of the final concave area of a cherry sample can capture the complete 3D morphology of the concave area, including its depth, shape, and edge characteristics, which is more accurate than 2D images. For complex-shaped wormholes or irregular concave areas (such as sharp, protruding wormhole edges), the 3D mesh model can comprehensively reflect its characteristics, avoiding the omission of information from single-angle or 2D data. The mesh model provided by 3D scanning includes vertex coordinates and normal information, providing rich data for subsequent depth and normal feature calculations. By calculating the difference between each point and the mean depth of the area, the depth variation characteristics inside the concave area can be directly reflected. In particular, the depth of wormhole areas is deeper and has greater internal variation, making them easier to distinguish from natural concave areas. It can provide quantitative characteristics for both shallow concave areas (such as natural surface concave areas) and deep concave areas (such as wormholes), and is suitable for defect analysis of different degrees. The edges of wormholes are usually sharp, and the normal deviation angle is large. By calculating the difference between each point and the mean depth of the area, the depth variation characteristics inside the concave area can be directly reflected. The deviation angle between the normal of a vertex and the normal of its neighboring region can effectively identify local abrupt changes in the concave region. Compared with depth features, normal features can better reflect the boundary morphology of the concave region, making the outline of the wormhole region clearer. Even when the depth difference is not significant, the normal deviation angle is still sensitive to local shape changes (such as sharp wormhole regions) and can be used as a supplementary feature to improve the accuracy of discrimination. The first defect feature (depth) reflects the overall change of the concave region, while the second defect feature (normal) captures local sharp changes. The combination of the two can more comprehensively describe the characteristics of the wormhole. The depth feature is sensitive to the severity of the concavity, while the normal feature is sensitive to the edge sharpness. By fusing discrimination, the possibility of misjudgment by a single feature is reduced, significantly reducing the false negative rate and false positive rate, making the wormhole discrimination results more reliable. The feature fusion detection unit comprehensively analyzes the first and second defect features, which can intelligently determine whether there is a wormhole in the cherry sample and realize automated classification and output.
[0071] Specifically, the feature fusion detection unit is used to fuse the defect features of cherry samples and determine whether the cherry samples have wormholes: by extracting the first defect feature and the second defect feature, the first defect feature and the second defect feature are normalized to obtain the normalized first defect feature ΔZ. d ′ and the second defect feature α p The normalization formula is:
[0072]
[0073] In the formula: ΔZ d ' is the first defect feature after normalization of the d-th surface point, ΔZ d Let ΔZ be the first defect feature of the d-th surface point. min The minimum value among the first defect features, ΔZ max α is the maximum value among the first defect features. p′ represents the second defect feature after normalization of vertex p, α p For the second defect feature of vertex p, α min α is the minimum value among the second defect characteristics. max This is the maximum value among the second defect features;
[0074] Defect fusion feature value calculated using a weighted feature-based attention mechanism:
[0075]
[0076] ω1+ω2=1;
[0077] In the formula: F fu For defect fusion eigenvalues, ΔZ d ' is the first defect feature after normalization of the d-th surface point, ΔZ d Let α be the first defect feature of the d-th surface point, where D is the number of surface points. p ′ represents the second defect feature after normalization of vertex p, α p Let p be the second defect feature of vertex p, where P is the number of vertices;
[0078] Obtain the defect fusion feature value, compare the defect fusion feature value with the preset defect fusion feature threshold. If the defect fusion feature value is greater than or equal to the preset defect fusion feature threshold, then mark the cherry sample as having wormholes; if the defect fusion feature value is less than the preset defect fusion feature threshold, then there is no need to mark the cherry sample as having wormholes.
[0079] By introducing normalization processing, attention mechanism weighted calculation, and feature fusion threshold determination, accurate detection and labeling of insect-eye defects are achieved. The dimensions and value ranges of the first defect feature (depth difference) and the second defect feature (normal deviation angle) may differ. Normalizing the two features to the same range (0 to 1) eliminates the influence of feature dimensions and ranges, making subsequent fusion calculations more reasonable. Different cherry samples may have different indentation characteristics (e.g., some samples have deeper indentations, while others have sharper edges). Through a weight adjustment mechanism, the system can adapt to the discrimination requirements of different types of insect-eye defects. After weighting and fusing the first and second defect features according to their respective weight ratios, the resulting defect fusion feature is... The value can more comprehensively describe the overall characteristics of insect eyes, including both depth information and surface morphology. The threshold determination process has low computational load, making it suitable for automated testing of large batches of cherry samples, thus improving detection efficiency. The defect fusion feature threshold can be flexibly adjusted according to different detection scenarios and sample characteristics. For example, the threshold can be lowered in more stringent scenarios to reduce missed detections, while the threshold can be raised in ordinary scenarios to reduce false detections. The first defect feature (depth information) describes the degree of indentation of the insect eye, and the second defect feature (normal deviation angle) describes the edge sharpness. The combination of the two more comprehensively reflects the characteristics of the insect eye, significantly improving the detection accuracy. The weight adjustment mechanism enables the system to adapt to different samples and detection conditions, improving the overall adaptability and reliability of the detection.
[0080] This invention acquires first and second feature data of a cherry sample, determines the concave area of the cherry sample based on the first and second feature data, extracts defect features from the concave area, fuses the defect features of the cherry sample, and determines whether the cherry sample has wormholes. The first feature data can effectively capture the depth information of the concave area and accurately describe the degree of concavity, while the second feature data can capture the sharpness and variation trend of the edge of the concave area, supplementing the insufficiency of depth features. Feature weights are dynamically allocated according to the detection scenario, enabling the system to flexibly adapt to the diverse characteristics of cherry samples, reduce misjudgments or missed detections that may be caused by a single feature, and improve the accuracy of recognition. By calculating the defect feature value through feature fusion and comparing it with a threshold, the location of wormholes is accurately marked, which can effectively distinguish between natural concavities and wormhole areas. This invention, by fusing multiple features and introducing an attention mechanism, accurately identifies concave areas and wormholes on the cherry surface, effectively solving the problem of poor existing wormhole detection capabilities and improving the accuracy, robustness, and efficiency of cherry wormhole recognition.
[0081] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0082] Finally: The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A cherry defect detection system based on a feature fusion attention mechanism, comprising a dual-angle feature capture and processing module, a recessed region identification module, and an insect-eye discrimination module; characterized in that, The dual-angle feature capture and processing module is used to acquire the first feature data and the second feature data of the cherry sample; The depression region identification module is used to determine the depression region of the cherry sample based on the first feature data and the second feature data; The insect-hole detection module is used to extract defect features from the recessed areas of cherry samples and determine whether insect holes exist in the cherry samples based on these defect features. The insect-hole detection module includes a recessed area scanning unit, a defect feature analysis unit, and a feature fusion detection unit. The recessed area scanning unit is used to obtain the final recessed areas of the cherry samples using a 3D scanner. A three-dimensional region mesh model; The defect feature analysis unit is used to analyze and obtain the defect features of cherry samples based on the three-dimensional region mesh model; The defect characteristics of the cherry samples include a first defect characteristic and a second defect characteristic; feature The fusion detection unit is used to fuse the defect features of cherry samples and determine whether the cherry samples have wormholes: by extracting the first defect feature and the second defect feature, the first defect feature and the second defect feature are normalized to obtain the normalized first defect feature. and the second defect feature Defect fusion feature values are calculated using a feature weighting method based on an attention mechanism. ; ; In the formula: For defect fusion feature values, The first defect feature after normalization of the d-th surface point. The first defect feature of the d-th surface point, The number of surface points, The second defect feature after normalization of vertex p. This is the second defect feature of vertex p. The number of vertices; The first defect feature is obtained by fitting a three-dimensional regional mesh model, calculating the mean depth of the final recessed area, and obtaining the difference between each surface point and the mean depth. The first defect feature is obtained by fitting a three-dimensional regional mesh model, calculating the mean depth of the final recessed area, and obtaining the difference between each surface point and the mean depth.
2. The cherry defect detection system based on feature fusion attention mechanism according to claim 1, characterized in that, The dual-angle feature capture and processing module includes an image acquisition unit, an image processing module, and a feature data capture unit; The image acquisition unit is used to acquire first-angle cherry images and second-angle cherry images of cherry samples using a high-definition camera. The dual-angle cherry images are obtained by acquiring the maximum diameter of the cherry sample with the concave surface, taking the midpoint of the maximum diameter as the vertical line as the central axis of the cherry, calculating the center distance between the outermost left and right sides of the cherry and the central axis, taking the center of the left and right center distances as the base point, and acquiring cherry images at the same height as the base point using a high-definition camera. The cherry image captured by the high-definition camera on the left is the first-angle cherry image, and the cherry image captured by the high-definition camera on the right is the second-angle cherry image. The image processing module is used to perform histogram equalization and noise removal on the cherry images from the first angle and the cherry images from the second angle. The feature data capture unit is used to extract the pixel values of the first-angle cherry image and the second-angle cherry image output by the image processing module to obtain the first feature data and the second feature data of the cherry sample. The first feature data is the pixel value of the cherry image at the first angle; The second feature data is the pixel value of the cherry image from the second angle.
3. The cherry defect detection system based on feature fusion attention mechanism according to claim 1, characterized in that, The depression region identification module includes a primary data acquisition unit, a depression region calculation unit, and a depression region positioning unit; The primary data acquisition unit is used to acquire the first and second characteristic data of the cherry samples; The concave region calculation unit is used to construct a concave region pixel coefficient calculation model based on the first feature data and the second feature data, and to preliminarily determine the concave region of each cherry sample. The recessed region localization unit determines the location of the recessed region based on the pixel coefficients of the recessed region of the cherry sample.
4. The cherry defect detection system based on feature fusion attention mechanism according to claim 3, characterized in that, The concave region calculation unit is used to construct a concave region pixel coefficient calculation model based on the first feature data and the second feature data, and to initially determine the concave region of each cherry sample: the first feature data and the second feature data of each angle of a single cherry sample are imported into the concave region pixel coefficient calculation model to calculate the pixel coefficient of the concave region. The calculation formula of the concave region pixel coefficient calculation model is as follows: ; ; ; In the formula: The pixel coefficients for the concave region are... The pixel coefficients for the first concave region are... The cherry image located at the first angle The first feature data at the location, The mean of the first feature data in the cherry image from the first angle. The largest first feature data in the cherry image from the first angle. The smallest first feature data in the cherry image from the first angle. The pixel coefficients for the second concave region are... For the cherry image at the second angle, located in The second feature data at the location, The mean of the second feature data in the cherry image from the second angle. The second feature data is the largest second feature data in the cherry image from the second angle. This represents the minimum second feature data in the cherry image from the second angle.
5. The cherry defect detection system based on feature fusion attention mechanism according to claim 3, characterized in that, The recessed region localization unit determines the location of the recessed region based on the pixel coefficients of the recessed region of the cherry sample: It extracts the pixel coefficients of the recessed region, along with first and second feature data, from a single cherry sample. The pixel coefficients of the recessed region are compared with the first feature data. If the first feature data is greater than or equal to the pixel coefficient of the recessed region, the location corresponding to the first feature data is not a recessed region; if the first feature data is less than the pixel coefficient of the recessed region, the location corresponding to the first feature data is a recessed region. The coordinates of the determined recessed region location are then obtained, generating a first recessed region coordinate set. ; Compare the pixel coefficient of the concave region with the second feature data. If the second feature data is greater than or equal to the pixel coefficient of the concave region, then the position corresponding to the second feature data is not a concave region. If the second feature data is less than the pixel coefficient of the concave region, then the position of the corresponding second feature data is the concave region; obtain the coordinates of the concave region to determine the position, and generate a set of coordinates for the second concave region. ; Obtain the coordinate set of the first concave region and the coordinate set of the second depression region Based on the intersection of the coordinate sets of the first and second concave regions, the final concave regions of the cherry sample are determined. .
6. The cherry defect detection system based on feature fusion attention mechanism according to claim 1, characterized in that, The defect feature analysis unit is used to analyze and obtain the defect features of cherry samples based on the three-dimensional region mesh model; The first defect feature is obtained by fitting a three-dimensional regional mesh model, calculating the average depth of the final recessed area, and taking the difference between each surface point and the average depth as the first defect feature. ; In the formula: The first defect feature of the d-th surface point, Let d be the depth value of the d-th surface point. This represents the average depth of the final concave region. The second defect feature is calculated by determining the normal vector of each mesh vertex based on the 3D region mesh model, and then calculating the normal deviation angle of each mesh vertex as the second defect feature. ; In the formula: This is the second defect feature of vertex p. Let be the normal vector of vertex p. Let p be the normal vector of the neighboring points of vertex p. Let be the inverse cosine function of the angle between the two normal vectors. The number of neighboring vertices.
Citation Information
Patent Citations
Video target detection algorithm based on improved Center Net backbone network
CN114639042A
Detection method and system for detecting defects of packaging box
CN117274689A