Method and system for detecting defects on bottle finish based on ai and machine vision
By combining multi-angle image fusion and regionalized convolutional neural network detection with an inference calculation model, the problem of insufficient three-dimensional spatial feature acquisition in bottle mouth defect detection is solved, achieving accurate positioning and type identification of bottle mouth defects, and improving the accuracy and reliability of detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANDONG MINGJIA TECH
- Filing Date
- 2026-05-11
- Publication Date
- 2026-07-21
AI Technical Summary
Existing bottle mouth defect detection technologies cannot acquire the three-dimensional spatial features of the bottle mouth, leading to defect location errors, inability to integrate cross-regional defect clues, easy omission and misjudgment of small three-dimensional defects, and limited accuracy of defect type inference.
Multi-angle images are acquired using high-resolution industrial cameras to generate a fused image of the bottle mouth with three-dimensional spatial information. The thread, end face, and inner wall regions are separated to construct independent feature maps. Potential defects are detected using a regionalized convolutional neural network. Multi-scale spatial attention analysis and cross-regional fusion are performed. Combined with an inference computing model, the defect evolution process is simulated to quantify the defect type and hazard level.
It enables precise location and type identification of bottle mouth defects, improves the integrity and correlation of defect features, ensures the complete presentation and accurate identification of three-dimensional minute defects, and improves the accuracy and reliability of detection.
Smart Images

Figure CN122434906A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial machine vision AI inspection technology, and in particular to a method and system for detecting bottle mouth defects based on AI and machine vision. Background Technology
[0002] Current methods for detecting bottle mouth defects primarily rely on high-resolution industrial cameras to acquire single-view, two-dimensional raw images. Defect detection is based on the overall image without segmenting the bottle mouth into regions such as threads, end faces, and inner walls. Using a unified convolutional neural network to identify defects in the overall image results in defect locations corresponding only to a single region. Multi-scale spatial attention analysis is not applied to the defect heatmap, and the detection results for each region are independent and lack spatial correlation. This type of detection method depends on planar image information and cannot acquire the three-dimensional spatial features of the bottle mouth. Differences in texture and geometric features between different regions are not specifically adapted, leading to errors in defect localization. Defect clues extending across regions cannot be integrated, and small three-dimensional defects and defects at regional boundaries are prone to missed detection and misjudgment. The accuracy of defect type inference is limited by the dimensionality of image information and the overall nature of the detection method.
[0003] A multi-angle image fusion method is needed to generate a fused image of the bottle neck with three-dimensional spatial information, replacing a single two-dimensional image as the basis for detection. The bottle neck thread, end face, and inner wall regions need to be separated and independent feature maps constructed. A preliminary defect location heatmap is generated using a regionalized convolutional neural network. Multi-scale spatial attention analysis is performed on the heatmap, and the detection results of the three regions are spatially correlated and fused to form a comprehensive defect map containing cross-regional defect clues, thereby enabling accurate inference of the bottle neck defect type. Summary of the Invention
[0004] The purpose of this invention is to address the shortcomings of existing technologies by proposing a bottle mouth defect detection method and system based on AI and machine vision.
[0005] To achieve the above objectives, the present invention adopts the following technical solution: a bottle mouth defect detection method based on AI and machine vision, comprising: A high-resolution industrial camera is used to acquire the original image sequence of the bottle opening to be inspected, and the original image sequence is fused from multiple angles to generate a fused image of the bottle opening with three-dimensional spatial information. The bottle mouth fusion image is subjected to illumination equalization and noise suppression processing, and the texture and geometric features of the bottle mouth region are extracted to obtain a preprocessed standard bottle mouth image. The bottle mouth thread region, bottle mouth end face region, and bottle mouth inner wall region are separated from the standard bottle mouth image, and independent feature maps are constructed for the bottle mouth thread region, the bottle mouth end face region, and the bottle mouth inner wall region respectively. Based on the independent feature maps, a trained regionalized convolutional neural network is used to detect the potential defect locations in the bottle mouth thread region, the bottle mouth end face region, and the bottle mouth inner wall region, and to generate a preliminary defect location heatmap. Multi-scale spatial attention analysis is performed on the preliminary defect location heatmap, and the detection results of the bottle mouth thread area, the bottle mouth end face area and the bottle mouth inner wall area are spatially correlated and fused to obtain a comprehensive defect map containing cross-regional defect clues. Perform inference calculations on the comprehensive defect map to obtain the defect type of the bottle mouth.
[0006] As a further aspect of the present invention, multi-angle image fusion is performed on the original image sequence to generate a bottle mouth fused image with three-dimensional spatial information, including: The high-resolution industrial camera is controlled to rotate around the axis of the bottle opening, and surface images of the bottle opening are simultaneously acquired from multiple preset angles. The surface images acquired from multiple preset angles are stereo-calibrated, and the coordinates of each pixel in three-dimensional space are calculated. Multiple surface images at preset angles are projected onto a unified 3D model of the bottle opening, and the images are stitched together using a texture mapping algorithm. The stitched image is then fused at the pixel level to eliminate shadows and seams caused by angle differences, generating a seamless and continuous fused image of the bottle mouth.
[0007] As a further aspect of the present invention, the bottle opening fused image is subjected to illumination equalization and noise suppression processing to extract the texture and geometric features of the bottle opening region, including: An adaptive histogram equalization algorithm is used to perform illumination compensation on the bottle mouth fusion image to eliminate local overly bright or dark areas caused by uneven illumination. The nonlocal mean filtering algorithm is applied to smooth the noise in the illumination-compensated image, which suppresses random noise while preserving the bottle mouth edge and texture details. The contour edge of the bottle opening is extracted using the Canny edge detection operator, and the main axis and key feature points of the bottle opening are located based on the contour edge. The texture features of the bottle mouth surface are extracted at multiple scales and directions using Gabor filter banks, and the geometric curvature features of key areas are calculated by combining the coordinates of the three-dimensional model of the bottle mouth, which together constitute the texture and geometric features.
[0008] As a further aspect of the present invention, the step of using a trained regionalized convolutional neural network to detect the potential defect locations of the bottle neck thread region, the bottle neck end face region, and the bottle neck inner wall region includes: The independent feature maps of the bottle mouth thread region, the bottle mouth end face region, and the bottle mouth inner wall region are respectively input into the corresponding regionalized convolutional neural network; Each regional convolutional neural network adopts an encoder-decoder structure. The encoder part extracts deep semantic features through multiple convolutional layers, and the decoder part recovers spatial details through upsampling and skip connections. At the output of the decoder network, defect probability prediction is performed for each pixel to generate a defect probability map with the same size as the input feature map. An adaptive threshold segmentation is applied to the defect probability map, marking regions with probability values higher than the threshold as potential defect locations, generating corresponding rectangular candidate boxes and masks, and finally outputting the preliminary defect location heatmap.
[0009] As a further aspect of the present invention, multi-scale spatial attention analysis is performed on the preliminary defect location heatmap, including: A spatial pyramid structure is constructed, and pooling operations are performed on the preliminary defect location heatmap at different scales to obtain multi-scale defect feature representations. Calculate the feature correlations at different spatial locations at different scales to generate attention weight maps; The attention weight map is used to reweight the features of the preliminary defect location heatmap, so that the network pays more attention to defect features and locations with strong cross-regional correlation. The heat maps of defect locations in the bottle mouth thread area, bottle mouth end face area, and bottle mouth inner wall area, which have undergone multi-scale attention enhancement, are stitched together and fused to generate the comprehensive defect map.
[0010] As a further aspect of the present invention, inference calculations are performed on the comprehensive defect map to obtain the defect type of the bottle opening, including: Based on the comprehensive defect map, an inference calculation model is used to simulate the evolution process of different defect types under the stress state at the bottle mouth, and to deduce the complete path of the defect from its inception to the current detection state. By using the state inversion algorithm, combined with the simulated evolution process and the comprehensive defect map, the historical defect state sequence that led to the current defect morphology can be calculated in reverse. The historical defect status sequence is matched with the standard defect database to determine the current defect type of the bottle opening, and its size, depth and hazard level are quantified. The simulation of the evolution of different defect types under the stress state at the bottle neck using a reasoning calculation model specifically includes: In the inference and calculation model, a physical and mechanical property model of the bottle mouth material and a three-dimensional finite element mesh model of the standard bottle mouth are established. From the standard defect database, load the three-dimensional geometric parameters and stress concentration factors of various defect types such as cracks, scratches, defects, and deformations; The defect location and morphology information extracted from the comprehensive defect map are mapped to the initial boundary conditions in the three-dimensional finite element mesh model. In the inference calculation model, simulated filling pressure, capping torque and transportation vibration and other load conditions are applied to calculate the stress distribution and strain evolution of the defect area under load. Iterative calculations were performed to determine the expansion direction, expansion rate, and morphological changes of defects under stress and strain, simulating the complete evolution path of the defects.
[0011] As a further aspect of the present invention, the step of using a state inversion algorithm, combining the simulated evolution process with the comprehensive defect map, to reverse-calculate the historical defect state sequence leading to the current defect morphology includes: The final defect form generated by the simulation evolution process using the aforementioned reasoning and computation model is taken as the target state; A state transition cost function is defined to measure the evolution between any two historical defect states. The state transition cost function comprehensively considers geometric differences, stress changes and material damage accumulation. Using a dynamic programming algorithm, a path from the initial healthy state to the target state is found in the graph formed by all evolution paths simulated by the inference and computation model, such that the sum of the state transition costs on the path is minimized. All intermediate defect states along the path are arranged in reverse chronological order to form the historical defect state sequence.
[0012] As a further aspect of the present invention, the historical defect state sequence is matched with a standard defect database to determine the defect type of the current bottle opening, including: Extract the geometric feature vector and evolution pattern vector of each state in the historical defect state sequence; Calculate the Euclidean distance between the geometric feature vector, the evolution pattern vector, and the feature vectors of various defect templates pre-stored in the standard defect database; A K-nearest neighbor classifier is used to find several defect templates that are closest to the historical defect state sequence based on the calculated Euclidean distance. Based on the labels of the defect template, the defect type to which the historical defect state sequence belongs is determined by weighted voting.
[0013] As a further aspect of the present invention, the quantification of its size, depth, and hazard level includes: In the standard bottle mouth image, the actual physical size of the defect is calculated based on the correspondence between the defect pixel coordinates and the coordinates of the three-dimensional model. By analyzing the degree of depression or protrusion of the defect area on the surface of the 3D model, and combining the principle of stereo vision, the depth of the defect is calculated. Based on the defect type, the actual physical size, and the depth, a preset defect risk comparison table is queried. The defect risk comparison table defines the hazard level score corresponding to different types and different size ranges of defects. Based on the combined hazard level scores, a final hazard level label is assigned to the current defect.
[0014] As a further aspect of the present invention, the present invention also includes a bottle mouth defect detection system based on AI and machine vision, the system including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein when the processor executes the computer program, it implements the steps of the bottle mouth defect detection method based on AI and machine vision described above.
[0015] Compared with the prior art, the advantages and positive effects of the present invention are as follows: After acquiring the original image sequence of the bottle mouth to be inspected by a high-resolution industrial camera, multi-angle image fusion is performed to directly generate a fused image of the bottle mouth with three-dimensional spatial information. This can completely preserve the three-dimensional structural features and spatial dimension information of the bottle mouth, making up for the limitation that a single two-dimensional image can only present planar features. The extraction dimension of bottle mouth texture and geometric features is expanded. The standard bottle mouth image after illumination equalization and noise suppression processing can completely present the details of the bottle mouth in three-dimensional space. Small defects in three-dimensional form can be fully presented, and the integrity and authenticity of defect features are guaranteed.
[0016] The thread, end face, and inner wall regions are separated from standard bottle mouth images and independent feature maps are constructed for each region. A trained regionalized convolutional neural network is used to detect potential defect locations for each independent feature map and generate preliminary defect location heatmaps. Multi-scale spatial attention analysis is performed on the preliminary defect location heatmaps, and the detection results of the three regions are spatially correlated and fused to form a comprehensive defect map containing cross-regional defect clues. Features of each region can be specifically adapted for identification, the targeting of defect localization is enhanced, cross-regional defect clues are effectively integrated, fragmented defect location information forms a coherent defect representation, and the comprehensive defect map can directly support the reasoning calculation of defect types. The correlation and completeness of defect clues are improved. Attached Figure Description
[0017] Figure 1 This is a flowchart of the bottle mouth defect detection method based on AI and machine vision described in this invention; Figure 2 The flowchart is for illumination equalization, noise suppression, and feature extraction. Figure 3A comprehensive defect map for cross-regional integration; Figure 4 The curve showing the relationship between crack propagation rate and stress intensity factor; Figure 5 Box plot showing the physical size-depth distribution and risk level of defects. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0019] In the description of this invention, it should be understood that the terms "length," "width," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientation or positional relationships, are based on the orientation or positional relationships shown in the accompanying drawings and are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Furthermore, in the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0020] See Figure 1 This invention provides a method for detecting bottle mouth defects based on AI and machine vision. The method includes: acquiring a sequence of original images of the bottle mouth to be inspected using a high-resolution industrial camera; performing multi-angle image fusion on the original image sequence to generate a fused bottle mouth image with three-dimensional spatial information; performing illumination equalization and noise suppression processing on the fused bottle mouth image; extracting texture and geometric features of the bottle mouth region to obtain a preprocessed standard bottle mouth image; separating the bottle mouth thread region, the bottle mouth end face region, and the bottle mouth inner wall region from the standard bottle mouth image; and performing specific processing on the bottle mouth thread region, the bottle mouth end face region, and the... An independent feature map is constructed for the inner wall region of the bottle mouth. Based on the independent feature map, a trained regionalized convolutional neural network is used to detect the potential defect locations of the bottle mouth thread region, the bottle mouth end face region, and the bottle mouth inner wall region, respectively, and a preliminary defect location heatmap is generated. Multi-scale spatial attention analysis is performed on the preliminary defect location heatmap, and the detection results of the bottle mouth thread region, the bottle mouth end face region, and the bottle mouth inner wall region are spatially correlated and fused to obtain a comprehensive defect map containing cross-regional defect clues. Inference calculation is performed on the comprehensive defect map to obtain the defect type of the bottle mouth.
[0021] In one embodiment of the present invention, the high-resolution industrial camera is controlled to rotate around the axis of the bottle mouth, and surface images of the bottle mouth are simultaneously acquired from multiple preset angles. The acquired surface images from multiple preset angles are stereo-calibrated, and the coordinates of each pixel in three-dimensional space are calculated. The surface images from multiple preset angles are projected onto the surface of a unified three-dimensional model of the bottle mouth. The images are stitched together using a texture mapping algorithm, and the stitched images are fused at the pixel level to eliminate shadows and seams caused by angle differences, thereby generating a seamless and continuous fused image of the bottle mouth.
[0022] In specific implementation, a high-resolution industrial camera is controlled to rotate around the axis of the bottle opening, simultaneously acquiring surface images of the bottle opening from multiple preset angles. In some embodiments, the preset angles include 0 degrees, 45 degrees, 90 degrees, 135 degrees, 180 degrees, 225 degrees, 270 degrees, and 315 degrees. The high-resolution industrial camera acquires one surface image at each preset angle position, forming an original image sequence consisting of eight images. Optionally, during the acquisition process, the bottle opening is fixed at the detection station, and the high-resolution industrial camera moves stepwise around the axis of the bottle opening through a precision rotating mechanism, stopping at each preset angle and triggering the shooting. It can be understood that multiple preset angles ensure that the entire circumferential surface of the bottle opening is completely covered without any blind spots. Data comparison shows that a single-angle image can only present a local surface of the bottle opening, while a multi-angle image sequence together covers the entire outer surface of the bottle opening. In practice, stereo calibration is performed on surface images acquired from multiple preset angles. The coordinates of each pixel in three-dimensional space are calculated. Stereo calibration uses a two-dimensional calibration plate with a known pattern. The mapping relationship between the image coordinate system and the three-dimensional world coordinate system is established by solving the camera parameters. For each pixel in a surface image, its corresponding three-dimensional spatial coordinates are calculated using the following formula: Where: pixel coordinates It refers to the two-dimensional pixel position and three-dimensional spatial coordinates in the surface image. It is the spatial position of a pixel in a unified world coordinate system, and the rotation matrix is used for this purpose. Describes the rotation and translation vectors of the camera coordinate system relative to the world coordinate system. Describes the translation and rotation matrices of the camera coordinate system relative to the world coordinate system. Translation vector Optimized through a multi-view stereo calibration algorithm, in some embodiments, for eight surface images, the 3D coordinates of all pixels in each image are calculated to generate a corresponding 3D point cloud dataset. This means that calculating the coordinates of each pixel in 3D space establishes a connection between image data and 3D geometry. In a specific implementation, multiple surface images at preset angles are projected onto a unified 3D model of the bottle neck. Image stitching is performed using a texture mapping algorithm. The unified 3D model of the bottle neck is a pre-constructed standard triangular mesh model of the bottle neck. The texture mapping algorithm maps the color information of each surface image to the corresponding mesh surface of the 3D model of the bottle neck based on the 3D coordinates of the pixels. For overlapping projection areas generated by multiple surface images on the surface of the 3D model of the bottle neck, the texture mapping algorithm uses a hybrid method based on viewpoint weights for transition processing to reduce abrupt seams between images. Optionally, the viewpoint weights are determined by the camera's line of sight corresponding to each pixel. The angle between the vector and the normal vector of the grid surface determines the weight; the smaller the angle, the higher the weight. In practice, pixel-level fusion is performed on the stitched image to eliminate shadows and seams caused by angle differences, generating a seamless and continuous bottle neck fusion image. The pixel-level fusion uses the Laplacian pyramid fusion algorithm, which performs weighted averaging on the overlapping image areas at each layer of the multi-resolution pyramid and reconstructs the image after fusion. Data comparison shows that the stitched image without fusion has obvious brightness differences and geometric misalignment at the stitching point, while the bottle neck fusion image after pixel-level fusion presents a uniform tone and continuous texture with no visible stitching marks.
[0023] In one embodiment of the present invention, see [reference] Figure 2 An adaptive histogram equalization algorithm is used to compensate for the illumination of the fused image of the bottle opening, eliminating local overly bright or dark areas caused by uneven illumination. A nonlocal mean filtering algorithm is applied to smooth the noise of the illumination-compensated image, suppressing random noise while preserving the bottle opening edge and texture details. The Canny edge detection operator is used to extract the contour edge of the bottle opening, and the principal axis and key feature points of the bottle opening are located based on the contour edge. The texture features of the bottle opening surface are extracted at multiple scales and directions using a Gabor filter bank, and the geometric curvature features of the key areas are calculated by combining the coordinates of the three-dimensional model of the bottle opening, which together constitute the texture and geometric features.
[0024] In practice, an adaptive histogram equalization algorithm is used to compensate for the illumination of the bottle neck fusion image, eliminating overly bright or dark areas caused by uneven illumination. The adaptive histogram equalization algorithm divides the bottle neck fusion image into multiple non-overlapping local regions, independently calculates the gray-level histogram in each local region, and performs equalization mapping. The mapping function transforms the gray-level distribution of the original local region into an approximately uniform distribution within a specified range. It can be understood that global histogram equalization will amplify the already good contrast areas in the entire image and may introduce noise, while the adaptive histogram equalization algorithm can independently adjust different local regions with significant illumination differences in the bottle neck fusion image. Data comparison shows that before processing, the gray-level values of the local regions of the bottle neck fusion image are concentrated in the lower and higher ranges. After processing by the adaptive histogram equalization algorithm, the gray-level value distribution range of the local region is expanded and covers a wider range (such as 0-255), and the overall image contrast is improved. In some embodiments, after equalizing each local region, bilinear interpolation is used to smooth the gray values at the boundaries of adjacent regions to avoid blocky artifacts in the final output image. In a specific implementation, a nonlocal mean filtering algorithm is applied to smooth noise in the illumination-compensated image, preserving the bottle opening edges and texture details while suppressing random noise. The nonlocal mean filtering algorithm calculates the similarity weights between the neighborhood window of each pixel and the neighborhood windows of all other pixels in the image. The filtered pixel value is obtained by a weighted average of these weights. Optionally, the pixel... Filtered output value Calculated using the following formula: in: pixels in an image The original grayscale value, It is measured in pixels. The center of the neighborhood window and the pixels The weights of similarity between the center's neighborhood windows The weight is determined by the Gaussian-weighted Euclidean distance between the pixel grayscale value vectors within two neighboring windows; the smaller the distance, the greater the weight. It is a normalization constant, representing all weights. The data comparison shows that after applying the nonlocal mean filtering algorithm, the gray-level abrupt changes of pixels representing random noise in the image are significantly reduced, while the gradient change region representing the edge of the bottle neck thread is preserved. In specific implementation, the Canny edge detection operator is used to extract the contour edge of the bottle neck. Based on the contour edge, the main axis and key feature points of the bottle neck are located. The Canny edge detection operator first performs Gaussian smoothing on the image processed by the nonlocal mean filtering algorithm, then calculates the gradient magnitude and direction of the image, then applies nonmaximum suppression to refine the edges in the gradient magnitude image, and finally outputs the final binary edge image through dual threshold detection and connection. From the binary edge image, the Hough transform is used to detect straight lines and arc segments in the bottle neck contour, and the main axis of the bottle neck is fitted to obtain the main axis of the bottle neck. Key feature points include the intersection of the upper end face and the side wall of the bottle neck, and the start and end points of the thread. In some embodiments, the standard deviation of the Gaussian kernel used by the Canny edge detection operator is 1.5, and the ratio of high threshold to low threshold is 2:1 to 3:1. In practical implementation, texture features of the bottle mouth surface are extracted at multiple scales and directions using a Gabor filter bank. These features are then combined with the coordinates of the 3D model of the bottle mouth to calculate the geometric curvature features of key areas, thus forming the texture and geometric features. The Gabor filter bank consists of multiple Gabor filters with different center frequencies and directions. Optionally, the Gabor filter bank includes filters at 4 different scales and 6 different directions. Each Gabor filter is convolved with the image to obtain the texture response map at the corresponding scale and direction. For each grid vertex on the surface of the 3D model of the bottle mouth, its geometric curvature features are calculated by analyzing the quadratic surface fitted to the surrounding local surfaces. Principal curvature and Gaussian curvature are used as feature quantities to describe the local geometric morphology. The texture and geometric features form a multidimensional vector, whose elements include multiple texture response values from the Gabor filter bank and curvature values from the coordinates of the 3D model of the bottle mouth. It can be understood that the Gabor filter bank response can capture local texture changes on the bottle mouth surface caused by defects such as scratches and wear, while the geometric curvature features can reflect local shape changes caused by defects such as impacts and deformation of the bottle mouth.
[0025] In one embodiment of the present invention, the independent feature maps of the bottle neck thread region, the bottle neck end face region, and the bottle neck inner wall region are respectively input into the corresponding regionalized convolutional neural networks. Each regionalized convolutional neural network adopts an encoder-decoder structure. The encoder part extracts deep semantic features through multiple convolutional layers, and the decoder part recovers spatial details through upsampling and skip connections. At the output of the decoder network, defect probability prediction is performed for each pixel to generate a defect probability map with the same size as the input feature map. Adaptive threshold segmentation is applied to the defect probability map, and regions with probability values higher than the threshold are marked as potential defect locations. Corresponding rectangular candidate boxes and masks are generated, and finally, the preliminary defect location heatmap is output. A spatial pyramid structure is constructed, and pooling operations are performed on the preliminary defect location heatmap at different scales to obtain multi-scale defect feature representations. Feature correlations of different spatial locations are calculated at different scales to generate an attention weight map. The preliminary defect location heatmap is then reweighted using the attention weight map, making the network pay more attention to defect features and locations with strong cross-regional correlations. The defect location heatmaps of the bottle mouth thread region, bottle mouth end face region, and bottle mouth inner wall region after multi-scale attention enhancement are spliced and fused to generate the comprehensive defect map.
[0026] In specific implementations, the independent feature maps of the bottle neck thread region, the bottle neck end face region, and the bottle neck inner wall region are input into the corresponding regionalized convolutional neural networks. Each regionalized convolutional neural network is a dedicated network that is independently trained and deployed to process the feature patterns of its corresponding bottle neck region. In some embodiments, the regionalized convolutional neural networks for the bottle neck thread region, the bottle neck end face region, and the bottle neck inner wall region have the same backbone network structure but do not share parameters with each other. Data comparison shows that when using a unified convolutional neural network to process the feature maps of all regions, the detection recall rate of microcracks in the bottle neck thread region is 85.7%, while after using independent regionalized convolutional neural networks, the detection recall rate of microcracks in the bottle neck thread region is improved to 94.2%. In practical implementation, each regional convolutional neural network adopts an encoder-decoder structure. The encoder extracts deep semantic features through multiple convolutional layers, while the decoder recovers spatial details through upsampling and skip connections. The encoder typically contains four downsampling stages, each consisting of two consecutive convolutional layers and a max-pooling layer. The convolutional layers use 3x3 convolutional kernels with the ReLU activation function. The decoder contains four upsampling stages, each upsampling through transposed convolutions and fusing the feature maps with the corresponding encoder stages through skip connections to recover the spatial details lost during encoding. In essence, the encoder-decoder structure allows the network to utilize both high-level semantic information and low-level positional information simultaneously. In practice, at the output of the decoder network, defect probability prediction is performed for each pixel, generating a defect probability map with the same size as the input feature map. The last convolutional layer of the decoder uses a 1x1 convolutional kernel to compress the number of channels to 1 and uses a sigmoid activation function to map the output value to between 0 and 1. This value represents the probability of a defect at the corresponding pixel location. The output defect probability map is spatially identical to the input independent feature map. In practical implementation, adaptive threshold segmentation is applied to the defect probability map. Regions with probability values higher than the threshold are marked as potential defect locations, and corresponding rectangular candidate boxes and masks are generated. Finally, a preliminary defect location heatmap is output. The threshold for adaptive threshold segmentation is... It is not a fixed value, but is dynamically calculated based on the overall probability distribution of the defect probability map. It is an optional adaptive threshold. The global mean of the defect probability map and standard deviation The decision is made using the following formula: Where: parameters It is an adjustable coefficient used to control the sensitivity of segmentation, for defects with probability values in the probability map greater than an adaptive threshold. Connected regions are labeled, and the minimum bounding rectangle of each connected region is calculated as a candidate bounding box. Simultaneously, a binary mask with the same shape as the connected region is generated. The initial defect location heatmap is a color image of the same size as the input image, where the candidate bounding boxes and mask regions are highlighted to identify defect locations, while the background region is dark. Refer to Table 1, which shows the encoder component structural parameter configurations for three types of regionalized convolutional neural networks.
[0027] Table 1: Structural Parameters of Regionalized Convolutional Neural Network Encoder In specific implementation, a spatial pyramid structure is constructed, and pooling operations are performed on the initial defect location heatmap at different scales to obtain a multi-scale defect feature representation. The spatial pyramid structure contains three scales, downsampling the input initial defect location heatmap by 1x, 2x, and 4x respectively. Global average pooling is applied to each downsampled heatmap to obtain a fixed-dimensional feature vector. The feature vectors from the three scales are concatenated to form a multi-scale defect feature representation. It can be understood that the multi-scale defect feature representation simultaneously contains both local fine-grained information and global contextual information of the defect. In specific implementation, the feature correlation of different spatial locations is calculated at different scales to generate an attention weight map. For each scale feature map, their correlation is measured by calculating the dot product between any two feature vectors in the feature map, forming a spatial correlation matrix. The spatial correlation matrix is then subjected to Softmax normalization row by row to obtain the attention weight map, which describes the feature contribution weight of each location in the image to all other locations at a specific scale. In some embodiments, the calculation process can be formally represented as: for scale Feature map below Reshape it into ,in Then attention weight map Through formula The calculation yielded the superscript. This represents the transpose operation. In practice, the initial defect location heatmap is reweighted using an attention weight map, making the network focus more on defect features and locations with strong cross-regional correlations. The features of the initial defect location heatmap are multiplied by the corresponding scale attention weight map to achieve feature reweighting. Specifically: in: This is a reweighted feature map. This operation ensures that the new feature value at each location in the feature map is obtained by weighting and summing all locations according to their relevance weights, thereby enhancing the feature response of locations strongly correlated with the defect region. In specific implementation, the defect location heatmaps of the bottle neck thread region, bottle neck end face region, and bottle neck inner wall region after multi-scale attention enhancement are stitched and fused to generate a comprehensive defect map. First, the feature maps corresponding to the three regions after multi-scale attention enhancement are upsampled to the size of the original input image. Then, these three feature maps are stitched together in the channel dimension. Finally, a 1x1 convolutional layer is used to fuse the stitched multi-channel feature maps into a single-channel comprehensive defect map. Optionally, this 1x1 convolutional layer plays a role in feature selection and dimensionality reduction, integrating cross-regional feature cues into a unified map.
[0028] See Figure 3 This study presents the confidence distribution of bottle neck defects after fusion based on multi-region attention enhancement and spatial correlation. From the map structure, the overall defect confidence in the background region remains in the range of 0.1–0.3, representing a healthy region with no defects or extremely low risk. Three high-confidence defect clusters are present in the map: the upper left region, with confidence concentrated in the range of 0.7–0.9, is a high-risk defect region, corresponding to significant defect clues in the thread or end face region; the lower right region, with confidence distributed in the range of 0.6–0.8, is a medium-to-high-risk defect region, reflecting defects related to the inner wall or across regions; and the lower left region, with confidence distributed in the range of 0.5–0.7, is a medium-risk defect region, representing local minor defects or weakly correlated defects across regions. The map generation logic is as follows: first, independent regionalized convolutional neural networks are used to extract defect probability maps for the bottle neck thread, end face, and inner wall regions respectively; then, multi-scale spatial attention analysis is performed to reweight and spatially correlate the defect features of different regions; finally, the detection results of the three types of regions are fused into a single-channel map. The color gradient (from dark blue to orange-red) directly maps the overall defect confidence level. The higher the value, the stronger the probability of a defect at that location and the stronger the cross-regional risk correlation, providing an intuitive visual basis for subsequent defect type reasoning and hazard level quantification.
[0029] In one embodiment of the present invention, based on the comprehensive defect map, an inference calculation model is used to simulate the evolution process of different defect types under the stress state of the bottle neck, and to deduce the complete path of the defect from its inception to the current detection state. Through a state inversion algorithm, combining the simulated evolution process with the comprehensive defect map, the historical defect state sequence leading to the current defect morphology is calculated in reverse. In the inference calculation model, a physical and mechanical property model of the bottle neck material and a three-dimensional finite element mesh model of a standard bottle neck are established. From the standard defect database, three-dimensional geometric parameters and stress concentration coefficients of various defect types, including cracks, scratches, defects, and deformation, are loaded. The defect location and morphological information extracted from the comprehensive defect map are mapped to the initial boundary conditions in the three-dimensional finite element mesh model. Simulated filling pressure, capping torque, and transportation vibration are applied to the inference calculation model. The stress distribution and strain evolution of the defect area under load are calculated, and the expansion direction, expansion rate, and morphological changes of the defect under stress and strain are iteratively calculated to simulate the complete evolution path of the defect. The final defect form generated by the simulation of the evolution process by the inference and computation model is taken as the target state. A state transition cost function is defined to measure the evolution between any two historical defect states. The state transition cost function comprehensively considers the differences in geometric shape, stress changes and material damage accumulation. A dynamic programming algorithm is used to find a path from the initial healthy state to the target state in the graph composed of all evolution paths simulated by the inference and computation model, such that the sum of all state transition costs on the path is minimized. All intermediate defect states passed through on the path are arranged in reverse chronological order to form the sequence of historical defect states.
[0030] In practical implementation, based on a comprehensive defect map, an inference calculation model is used to simulate the evolution process of different defect types under the stress state of the bottle neck, deduce the complete path of the defect from its inception to the current detection state. In the inference calculation model, a physical and mechanical property model of the bottle neck material and a three-dimensional finite element mesh model of a standard bottle neck are established. The physical and mechanical property model of the bottle neck material defines the elastic modulus, Poisson's ratio, density, yield strength, and fracture toughness parameters of the glass or plastic material. The three-dimensional finite element mesh model of the standard bottle neck is generated by meshing based on the standard bottle neck three-dimensional model, containing hundreds of thousands of tetrahedral or hexahedral elements. Each mesh element node stores coordinate information, and the element stores material properties. In practical implementation, three-dimensional geometric parameters and stress concentration factors for various defect types such as cracks, scratches, defects, and deformations are loaded from the standard defect database. The standard defect database is a pre-generated structured database, in which each type of defect is associated with a set of characteristic parameters. For example, for crack defects, its three-dimensional geometric parameters include initial crack length, crack depth, crack opening angle, and crack surface direction. The stress concentration factor describes the stress amplification factor at the crack tip under a unit load. In practice, the defect location and morphology information extracted from the comprehensive defect map is mapped to the initial boundary conditions in the three-dimensional finite element mesh model. The mapping process includes locating mesh nodes or elements on the surface of the three-dimensional finite element mesh model that correspond to the defect regions in the comprehensive defect map, and calculating the equivalent geometric representation of the defect on the three-dimensional model based on the two-dimensional morphology of the defect. For example, an elliptical bright spot may be mapped to an elliptical region with specific major and minor axis dimensions on the surface of the three-dimensional model, and the constraint conditions of all nodes in the region are modified to simulate the discontinuity or geometric distortion of the material. In practice, various load conditions, such as filling pressure, capping torque, and transportation vibration, are simulated in the inference calculation model. The stress distribution and strain evolution of the defect area under these loads are calculated. The inference calculation model calls a finite element solver and gradually applies loads representing different production and usage stages to a three-dimensional finite element mesh model that defines material properties and initial defect boundary conditions. The filling pressure acts as a uniformly distributed pressure on the inner wall of the bottle neck, the capping torque acts as a pair of equal and opposite couples on both sides of the bottle neck thread, and the transportation vibration acts as a periodically changing acceleration field on the entire model. The solver calculates the stress tensor and strain tensor of each mesh element within the model under each or a combination of load conditions. Refer to Table 2, which shows the parameters of typical applied load conditions.
[0031] Table 2: Typical Load Condition Parameters of the Inference Calculation Model In practice, the propagation direction, propagation rate, and morphological changes of defects under stress and strain are calculated iteratively to simulate the complete evolution path of the defects. For crack-type defects, the Paris formula based on linear elastic fracture mechanics or the J integral criterion based on elastoplastic fracture mechanics is used to predict their propagation. Each iteration calculates whether the crack propagates based on the crack tip stress intensity factor or J integral value under the current load step and the material fracture toughness parameters, and calculates the propagation increment and direction. For scratch, defect, and deformation-type defects, their morphological changes are simulated by judging whether the material element reaches the yield criterion or damage threshold. After each iteration, the geometry and boundary conditions of the defects in the three-dimensional finite element mesh model are updated and used as the initial state for the next iteration. This process is repeated until the simulation reaches the preset number of cycles or the defect size reaches the critical value, thus obtaining a continuous evolution path from the initial small defect to the final detected morphology. It can be understood that this iterative process simulates the dynamic development of defects in the service environment. In practical implementation, the final defect form generated by the inference calculation model simulating the evolution process is taken as the target state. A state transition cost function is defined to measure the evolution between any two historical defect states. The state transition cost function comprehensively considers geometric differences, stress changes, and material damage accumulation. The state transition cost between two historical defect states i and j is... Defined by the following formula: in: and These represent historical defect state i and historical defect state j, respectively. It is a measure of the difference in the three-dimensional geometric shape of the defect between state i and state j, and its dimension is [length]. It is the change in the maximum principal stress in the defect region between state i and state j, and its dimension is [pressure]. It is the increment of the cumulative damage variable of the material elements surrounding the defect during the evolution from state i to state j, and is a dimensionless quantity. It is a characteristic length, such as the pitch of a bottle neck thread. It is the yield strength of the bottle neck material. It is the damage threshold of the material, a dimensionless reference constant. , , These are dimensionless weighting coefficients used to balance the geometric, mechanical, and damage costs. Through ratio operations in the formula, the three summation terms are all transformed into dimensionless values, thus reducing the state transition cost. The final result is a dimensionless comprehensive evaluation value. In some embodiments, these weight coefficients are optimized and determined by analyzing a large amount of defect sample data from known evolution paths. In specific implementations, a dynamic programming algorithm is used to find a path from the initial healthy state to the target state in the graph composed of all evolution paths simulated by the inference computation model, such that the sum of all state transition costs on the path is minimized. All intermediate defect states generated by the inference computation model simulation are abstracted as nodes in the graph. If state j can be evolved from state i in one iteration, a directed edge is established between node i and node j, and the weight of the edge is obtained from the state transition cost function. The dynamic programming algorithm starts from the target state node and recursively calculates the minimum cumulative cost to reach each state node and its corresponding predecessor state. Finally, it backtracks to find the path from the initial healthy state node to the target state node with the minimum sum of state transition costs. In practice, all intermediate defect states along the path are arranged in reverse chronological order to form a historical defect state sequence. This reverse chronological order means arranging the defects from early to late stages of development. The first state in the list is the earliest defect form closest to the initial healthy state, and the last state is the late defect form closest to the target state. This sequence depicts the entire process of a detected defect from its inception and development to its eventual observation. In essence, the historical defect state sequence provides temporal information about defect evolution.
[0032] See Figure 4In crack propagation analysis based on linear elastic fracture mechanics, the relationship between crack propagation rate and stress intensity factor follows the Paris formula, intuitively presenting the three-stage evolution of cracks from initiation to critical instability. The curve in the figure represents the crack propagation rate (da / dN, unit: mm / cycle), which increases exponentially with the stress intensity factor (ΔK, unit: MPa・m^0.5), completely covering the three stages of crack propagation: Stage I (ΔK<ΔK_th): The stress intensity factor is below the propagation threshold (dashed line), the crack propagation rate approaches 0, the crack is dormant or initiating very slowly, and only weak stress concentration exists at microscopic defects in the material. Stage II (ΔK_th<ΔK<ΔK_c): The crack enters the stable propagation zone, the propagation rate is proportional to the power of the stress intensity factor, and the curve shows a clear monotonically increasing trend. This is the main stage of fatigue crack propagation in engineering structures. During this stage, the crack size gradually increases with cyclic loading, which is the core focus area for remaining life assessment. Stage III (ΔK>ΔK_c): The stress intensity factor approaches the critical threshold (dashed line), the crack propagation rate increases sharply, the slope of the curve increases significantly, and the crack enters the unstable propagation stage, eventually leading to instantaneous structural fracture. The two vertical dashed lines in the figure mark the propagation threshold ΔK_th and the critical threshold ΔK_c, clearly defining the boundaries of the three stages of crack propagation: ΔK_th is the threshold value for the crack to begin stable propagation; below this value, the crack basically does not propagate; ΔK_c is the critical stress intensity factor corresponding to the material's fracture toughness; exceeding this value, the crack will undergo unstable fracture. The pink-filled area visually demonstrates the cumulative effect of the crack propagation rate within the stable propagation stage, providing core mechanical basis for simulating the evolution of crack-like defects in the bottle mouth defect reasoning calculation model. It can be used to iteratively calculate the propagation increment and morphological changes of cracks under loading conditions such as filling pressure and capping torque, thereby constructing a complete defect evolution path.
[0033] In one embodiment of the present invention, the geometric feature vector and evolution pattern vector of each state in the historical defect state sequence are extracted. The Euclidean distance between the geometric feature vector, the evolution pattern vector and the feature vector of various defect templates pre-stored in the standard defect database is calculated. A K-nearest neighbor classifier is used to find several defect templates that are closest to the historical defect state sequence based on the calculated Euclidean distance. Based on the label of the defect template, the defect type of the historical defect state sequence is determined by weighted voting. In the standard bottle mouth image, the actual physical size of the defect is calculated based on the correspondence between the defect pixel coordinates and the coordinates of the three-dimensional model. By analyzing the degree of concavity or convexity of the defect area on the surface of the three-dimensional model and combining the principle of stereo vision, the depth of the defect is calculated. Based on the defect type, the actual physical size and the depth, a preset defect risk comparison table is queried. The defect risk comparison table defines the danger level scores corresponding to different types and different size ranges of defects. Based on the combined danger level scores, a final danger level label is assigned to the current defect.
[0034] In practice, the geometric feature vector and evolution pattern vector of each state in the historical defect state sequence are extracted. The geometric feature vector includes the defect's equivalent diameter, aspect ratio, roundness, surface area, and volume characteristics. The evolution pattern vector describes the trend of the defect's changes over time in the historical defect state sequence, including size growth rate, shape change rate, and spatial migration rate characteristics. These characteristics have different physical dimensions; for example, the dimension of the equivalent diameter is [length], and the dimension of the surface area is [length]. 2 The size growth rate is a dimensionless ratio. For a historical defect state sequence containing N states, each state generates an original feature vector containing M feature values. In practice, before calculating the distance, the geometric feature vector and the evolution pattern vector are standardized to eliminate the influence of dimensions. The standardization process uses the Z-score standardization method, calculating the mean of each feature dimension of the original feature vector across all training samples. and standard deviation Then, the feature vector of the historical defect state sequence and template feature vectors in the standard defect database Transform each dimension: in: It is the standardized m-th eigenvalue. These are the original feature values. After this processing, all feature dimensions are transformed into dimensionless values with a mean of 0 and a standard deviation of 1. In specific implementation, the Euclidean distance between the standardized geometric feature vector and the evolution pattern vector and the standardized feature vectors of various defect templates pre-stored in the standard defect database is calculated. In the standard defect database, multiple representative feature templates are pre-stored for each type of defect. Each template is a feature vector of length M that has undergone the same standardization process. The standardized feature vectors of historical defect state sequences are then used to calculate the distance between these templates. The feature vector of a standardized defect template in the standard defect database. Euclidean distance between Calculated using the following formula: in: It is the standardized historical defect state sequence feature vector at the th eigenvalues of dimension It is the standardized first The defect template feature vector at the th defect template feature vector in the th ... The eigenvalues of the dimension are represented by dimensionless distance scalars on both sides of the formula. The calculation will be performed on all defect templates in the standard defect database to generate a set of dimensionless distance values.
[0035] In specific implementation, a K-nearest neighbor classifier is used to find several defect templates that are closest to the historical defect state sequence based on the calculated Euclidean distance. The input of the K-nearest neighbor classifier is the set of Euclidean distances calculated between all row vectors in the standardized feature matrix of the historical defect state sequence and all standardized defect templates. The K-nearest neighbor classifier independently finds the K nearest neighbor templates with the smallest Euclidean distance among all templates in the standard defect database for each state vector in the historical defect state sequence. In some embodiments, the value of K is set to 5. It can be understood that the K-nearest neighbor classifier makes decisions based on local similarity. In practice, based on the labels of the defect templates, the defect type of the historical defect state sequence is determined by weighted voting. In the weighted voting, the voting weight of each nearest neighbor template is proportional to the reciprocal of its Euclidean distance; the smaller the distance, the greater the weight. For each state vector in the historical defect state sequence, the voting results of its K nearest neighbor templates are summed according to their weights. Ultimately, the defect type of the entire historical defect state sequence is determined by the sum of the weighted voting results of all state vectors. The defect type with the highest total number of votes is determined as the defect type of the current bottleneck. Optionally, the weights of the weighted voting... The calculation formula is: in: Is it up to the Euclidean distance between nearest neighbor templates This is a very small constant used to prevent division by zero errors. In practice, in the standard bottle neck image, the actual physical size of the defect is calculated based on the correspondence between the defect pixel coordinates and the coordinates of the 3D model. The defect pixel coordinates are the set of pixel positions of the defect region contour extracted from the comprehensive defect map. Through the mapping relationship established during 3D reconstruction using camera calibration parameters, each contour pixel is back-projected onto the surface of the bottle neck 3D model to obtain the corresponding 3D spatial point set. The actual physical size is calculated based on these 3D spatial point sets. For example, the length of the defect is obtained by calculating the 3D Euclidean distance between the two farthest points in the point set, with the dimension [length]. The area of the defect is obtained by calculating the sum of the areas of the triangular faces spanned by the point set on the 3D model surface, with the dimension [length]. 2 In practice, the depth of the defect is calculated by analyzing the degree of concavity or convexity of the defect area on the surface of the 3D model and combining the principle of stereo vision. For concave defects, a point is selected within the defect area, and the distance from that point along its normal direction to the normal bottle mouth surface outside the defect area is calculated as the depth of that point. The depth value of the defect is the maximum or average value of the depths of all sampling points within the area, and its dimension is [length]. For convex defects, the depth calculation method is similar but the sign is reversed. This calculation relies on accurate 3D model coordinates, which are provided by multi-angle image fusion and 3D reconstruction.
[0036] In some embodiments, depth calculation can be expressed as: for a three-dimensional point within a defect region... Find the point on the 3D model of the bottle opening that is closest to the given point and falls within a preset normal area. The defect is in the point Local depth at For vectors At point The projected length along the normal vector direction has the dimension of [length]. In specific implementation, based on the defect type, actual physical size, and depth, a pre-defined defect risk comparison table is consulted. This table defines the hazard level scores corresponding to different types and size ranges of defects. The defect risk comparison table is a predefined lookup table where the row index is the defect type and the column index is the range of the defect size and depth. Each cell stores a hazard level score, which is typically a dimensionless value between 0 and 10; a higher value indicates a greater risk. During the query, based on the determined defect type and the calculated range falling into which the actual physical size and depth fall, the corresponding cell in the table is located, and its stored hazard level score is retrieved. In practice, a final hazard level label is assigned to the current defect based on the comprehensive hazard level score. The comprehensive process may involve calculating multiple scores obtained from the defect risk comparison table, such as taking the maximum value, average value, or weighted sum. The calculation result is mapped to several preset discrete hazard level labels. Optionally, the hazard level labels are divided into five levels: "urgent," "high," "medium," "low," and "acceptable." The corresponding label is assigned according to the threshold range of the calculated comprehensive score. For example, a comprehensive score in the range [0,2) corresponds to "acceptable," [2,4) corresponds to "low," [4,6) corresponds to "medium," [6,8) corresponds to "high," and [8,10] corresponds to "urgent." It can be understood that the hazard level label provides users with an intuitive indication of the severity of the defect.
[0037] See Figure 5 In the defect physical size-depth distribution and risk level assessment system, the distribution characteristics of the equivalent diameter of defects show a significant positive correlation with the hazard level. Specifically, the box plots of the equivalent diameter of defects for different hazard levels clearly show the size gradient: the equivalent diameter of "acceptable" level defects is concentrated in the range of 0.3~1.5mm, with a median of approximately 0.9mm; the equivalent diameter of "low" level defects ranges from 1.2~2.8mm, with a median of approximately 2.0mm; the equivalent diameter of "medium" level defects ranges from 1.5~4.5mm, with a median of approximately 3.2mm; the equivalent diameter of "high" level defects ranges from 2.6~6.8mm, with a median of approximately 5.1mm; and the equivalent diameter of "urgent" level defects ranges from 4.4~8.0mm, with a median of approximately 6.2mm. The distribution pattern intuitively reflects the quantitative logic of defect risk level in this invention: based on physical parameters such as equivalent diameter and depth of defects, combined with defect type, the score calculation and level mapping are completed through a preset defect risk comparison table. The box plot's box width and whisker range further reveal the dimensional dispersion within each level. The "urgent" and "high" level defects exhibit even greater dimensional dispersion, indicating stronger heterogeneity in their physical morphology and requiring close attention.
[0038] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments that can be applied to other fields. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.
Claims
1. A bottle opening defect detection method based on AI and machine vision, characterized in that, include: A high-resolution industrial camera is used to acquire the original image sequence of the bottle opening to be inspected, and the original image sequence is fused from multiple angles to generate a fused image of the bottle opening with three-dimensional spatial information. The bottle mouth fusion image is subjected to illumination equalization and noise suppression processing, and the texture and geometric features of the bottle mouth region are extracted to obtain a preprocessed standard bottle mouth image. The bottle mouth thread region, bottle mouth end face region, and bottle mouth inner wall region are separated from the standard bottle mouth image, and independent feature maps are constructed for the bottle mouth thread region, the bottle mouth end face region, and the bottle mouth inner wall region respectively. Based on the independent feature maps, a trained regionalized convolutional neural network is used to detect the potential defect locations in the bottle mouth thread region, the bottle mouth end face region, and the bottle mouth inner wall region, and to generate a preliminary defect location heatmap. Multi-scale spatial attention analysis is performed on the preliminary defect location heatmap, and the detection results of the bottle mouth thread area, the bottle mouth end face area and the bottle mouth inner wall area are spatially correlated and fused to obtain a comprehensive defect map containing cross-regional defect clues. Perform inference calculations on the comprehensive defect map to obtain the defect type of the bottle mouth.
2. The bottle mouth defect detection method based on AI and machine vision as described in claim 1, characterized in that, Multi-angle image fusion is performed on the original image sequence to generate a fused image of the bottle opening with three-dimensional spatial information, including: The high-resolution industrial camera is controlled to rotate around the axis of the bottle opening, and surface images of the bottle opening are simultaneously acquired from multiple preset angles. The surface images acquired from multiple preset angles are stereo-calibrated, and the coordinates of each pixel in three-dimensional space are calculated. Multiple surface images at preset angles are projected onto a unified 3D model of the bottle opening, and the images are stitched together using a texture mapping algorithm. The stitched image is then fused at the pixel level to eliminate shadows and seams caused by angle differences, generating a seamless and continuous fused image of the bottle mouth.
3. The bottle mouth defect detection method based on AI and machine vision as described in claim 1, characterized in that, The fused image of the bottle opening is subjected to illumination equalization and noise suppression processing to extract the texture and geometric features of the bottle opening region, including: An adaptive histogram equalization algorithm is used to perform illumination compensation on the bottle mouth fusion image to eliminate local overly bright or dark areas caused by uneven illumination. The nonlocal mean filtering algorithm is applied to smooth the noise in the illumination-compensated image, which suppresses random noise while preserving the bottle mouth edge and texture details. The contour edge of the bottle opening is extracted using the Canny edge detection operator, and the main axis and key feature points of the bottle opening are located based on the contour edge. The texture features of the bottle mouth surface are extracted at multiple scales and directions using Gabor filter banks, and the geometric curvature features of key areas are calculated by combining the coordinates of the three-dimensional model of the bottle mouth, which together constitute the texture and geometric features.
4. The bottle mouth defect detection method based on AI and machine vision as described in claim 1, characterized in that, The step of using a trained regionalized convolutional neural network to detect the potential defect locations in the bottle neck thread region, the bottle neck end face region, and the bottle neck inner wall region includes: The independent feature maps of the bottle mouth thread region, the bottle mouth end face region, and the bottle mouth inner wall region are respectively input into the corresponding regionalized convolutional neural network; Each regional convolutional neural network adopts an encoder-decoder structure. The encoder part extracts deep semantic features through multiple convolutional layers, and the decoder part recovers spatial details through upsampling and skip connections. At the output of the decoder network, defect probability prediction is performed for each pixel to generate a defect probability map with the same size as the input feature map. An adaptive threshold segmentation is applied to the defect probability map, marking regions with probability values higher than the threshold as potential defect locations, generating corresponding rectangular candidate boxes and masks, and finally outputting the preliminary defect location heatmap.
5. The bottle mouth defect detection method based on AI and machine vision as described in claim 1, characterized in that, Multi-scale spatial attention analysis is performed on the preliminary defect location heatmap, including: A spatial pyramid structure is constructed, and pooling operations are performed on the preliminary defect location heatmap at different scales to obtain multi-scale defect feature representations. Calculate the feature correlations at different spatial locations at different scales to generate attention weight maps; The attention weight map is used to reweight the features of the preliminary defect location heatmap, so that the network pays more attention to defect features and locations with strong cross-regional correlation. The heat maps of defect locations in the bottle mouth thread area, bottle mouth end face area, and bottle mouth inner wall area, which have undergone multi-scale attention enhancement, are stitched together and fused to generate the comprehensive defect map.
6. The bottle mouth defect detection method based on AI and machine vision as described in claim 1, characterized in that, Perform inference calculations on the comprehensive defect map to obtain the defect types at the bottle opening, including: Based on the comprehensive defect map, an inference calculation model is used to simulate the evolution process of different defect types under the stress state at the bottle mouth, and to deduce the complete path of the defect from its inception to the current detection state. By using the state inversion algorithm, combined with the simulated evolution process and the comprehensive defect map, the historical defect state sequence that led to the current defect morphology can be calculated in reverse. The historical defect status sequence is matched with the standard defect database to determine the current defect type of the bottle opening, and its size, depth and hazard level are quantified. The simulation of the evolution of different defect types under the stress state at the bottle neck using a reasoning calculation model specifically includes: In the inference and calculation model, a physical and mechanical property model of the bottle mouth material and a three-dimensional finite element mesh model of the standard bottle mouth are established. From the standard defect database, load the three-dimensional geometric parameters and stress concentration factors of various defect types such as cracks, scratches, defects, and deformations; The defect location and morphology information extracted from the comprehensive defect map are mapped to the initial boundary conditions in the three-dimensional finite element mesh model. In the inference calculation model, simulated filling pressure, capping torque and transportation vibration and other load conditions are applied to calculate the stress distribution and strain evolution of the defect area under load. Iterative calculations were performed to determine the expansion direction, expansion rate, and morphological changes of defects under stress and strain, simulating the complete evolution path of the defects.
7. The bottle mouth defect detection method based on AI and machine vision as described in claim 6, characterized in that, The process involves using a state inversion algorithm, combining the simulated evolution process with the comprehensive defect map, to reverse-calculate the historical defect state sequence leading to the current defect morphology, including: The final defect form generated by the simulation evolution process using the aforementioned reasoning and computation model is taken as the target state; A state transition cost function is defined to measure the evolution between any two historical defect states. The state transition cost function comprehensively considers geometric differences, stress changes and material damage accumulation. Using a dynamic programming algorithm, a path from the initial healthy state to the target state is found in the graph formed by all evolution paths simulated by the inference and computation model, such that the sum of the state transition costs on the path is minimized. All intermediate defect states along the path are arranged in reverse chronological order to form the historical defect state sequence.
8. The bottle mouth defect detection method based on AI and machine vision as described in claim 6, characterized in that, The historical defect state sequence is matched with a standard defect database to determine the current defect type of the bottle opening, including: Extract the geometric feature vector and evolution pattern vector of each state in the historical defect state sequence; Calculate the Euclidean distance between the geometric feature vector, the evolution pattern vector, and the feature vectors of various defect templates pre-stored in the standard defect database; A K-nearest neighbor classifier is used to find several defect templates that are closest to the historical defect state sequence based on the calculated Euclidean distance. Based on the labels of the defect template, the defect type to which the historical defect state sequence belongs is determined by weighted voting.
9. The bottle mouth defect detection method based on AI and machine vision as described in claim 6, characterized in that, The quantification of its size, depth, and hazard level includes: In the standard bottle mouth image, the actual physical size of the defect is calculated based on the correspondence between the defect pixel coordinates and the coordinates of the three-dimensional model. By analyzing the degree of depression or protrusion of the defect area on the surface of the 3D model, and combining the principle of stereo vision, the depth of the defect is calculated. Based on the defect type, the actual physical size, and the depth, a preset defect risk comparison table is queried. The defect risk comparison table defines the hazard level score corresponding to different types and different size ranges of defects. Based on the combined hazard level scores, a final hazard level label is assigned to the current defect.
10. A bottle mouth defect detection system based on AI and machine vision, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the bottle mouth defect detection method based on AI and machine vision as described in any one of claims 1 to 9.