A thermos cup surface scratch defect adaptive visual detection method and device
By combining an integral-differential coupled convolution operator and an adaptive adjustment unit, the problem of inefficient detection of scratches on the surface of thermos cups is solved, enabling accurate detection of irregularly shaped cup surfaces and improving detection efficiency and accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHEJIANG NORMAL UNIV
- Filing Date
- 2026-03-12
- Publication Date
- 2026-06-19
AI Technical Summary
In existing technologies, surface scratches on thermos cups are difficult to detect efficiently and accurately. Manual inspection is inefficient, labor-intensive, and easily affected by personal experience. Existing visual inspection algorithms are difficult to apply to irregularly shaped cups.
An integral-differential coupled convolution operator is used to process the image of the outer surface of the thermos cup. A gradient enhancement image is generated by combining a piecewise linear-nonlinear hybrid enhancement mapping. Scratch-type defects are identified by weighted judgment indexes, and the differences in cup body radius are compensated by an adaptive adjustment unit, so as to realize the detection of multiple models.
It enables accurate and efficient detection of surface scratches on thermos cups, improving the accuracy and reliability of detection. It is applicable to various models of thermos cups and reduces human interference and false detection rate.
Smart Images

Figure CN122243903A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of visual inspection technology, and in particular to an adaptive visual inspection method and device for surface scratches on thermos cups. Background Technology
[0002] During the production, processing, and handling of insulated cups, the surface is highly susceptible to scratches due to contact, friction, or improper process control. These defects typically exhibit elongated, discontinuous, and randomly oriented surface features, with varying shapes and depths, often accompanied by noticeable localized differences in brightness under specific lighting conditions. These defects not only affect the product's appearance and tactile feel but may also be amplified in subsequent powder coating and powder coating processes. Therefore, timely detection in the early stages is crucial to avoid rework and waste.
[0003] Currently, the industry generally relies on manual visual inspection to identify scratch-like defects. Workers need to spend long periods under lighting, constantly adjusting the angle of the thermos cup, observing changes in light reflection on the surface to detect any abnormalities. However, the visibility of scratch-like defects is highly dependent on the direction of illumination and the viewing angle. Manual inspection is not only inefficient and labor-intensive, but also easily influenced by personal experience and subjective judgment. The lack of standardized procedures among different inspectors leads to frequent missed and false positives. Furthermore, prolonged inspection of minute defects under strong light can damage the operator's eyesight. Although some visual inspection algorithms for scratches exist, these methods mostly rely on ideal imaging conditions and are primarily designed for flat products, making them unsuitable for irregularly shaped cup surfaces. Summary of the Invention
[0004] The purpose of this application is to provide an adaptive visual inspection method and device for surface scratches on thermos cups, which can achieve accurate and efficient detection of surface scratches on thermos cups.
[0005] To achieve the above objectives, this application provides the following solution: Firstly, this application provides an adaptive visual detection method for surface scratches and other defects on a thermos cup, including: Acquire an image of the outer surface of the thermos cup; Based on the integral-differential coupled convolution operator, convolution operation is performed on the image of the outer surface of the thermos cup, and the result is subjected to piecewise linear-nonlinear hybrid enhancement mapping to generate a gradient-enhanced image. Based on the gradient-enhanced image, the scratch-type defect response region is extracted, and the first maximum gray value of each candidate connected region in the scratch-type defect response region is calculated; the candidate connected region is the region where a morphological dilation operation is performed on the scratch-type defect response region so that spatially adjacent or discontinuous defect responses can be connected. If the first maximum gray value of the candidate connected region exceeds the first threshold, the scratch-type defect response region is determined to be a defect region; otherwise, a weighted judgment index is constructed based on the minimum circumscribed circle radius of the candidate connected region, the maximum gray value and the average gray value in the scratch-type defect response region. If the weighted judgment index exceeds the second threshold, the scratch-type defect response region is determined to be a defect region. For the defective area, determine the second maximum grayscale value of the defective area in the image of the outer surface of the thermos cup; By removing defect areas where the second maximum gray value is lower than the third threshold and defect areas where the size of the candidate connected region does not reach the preset size threshold, scratch-like defect areas on the outer surface of the thermos cup are obtained.
[0006] Optionally, an image of the outer surface of the thermos cup can be acquired, specifically including: An industrial line scan camera is used to image the outer surface of a rotating thermos cup, and a coaxial light source is used to illuminate it at a high angle with dark field illumination relative to the normal direction of the thermos cup body to obtain an image of the outer surface of the thermos cup.
[0007] Optionally, after acquiring the image of the outer surface of the thermos, the method further includes: The image of the outer surface of the thermos cup is subjected to median filtering and background subtraction processing, specifically including: According to the formula The image of the outer surface of the thermos cup is transformed to obtain the image after median filtering. Based on the image after median filtering and the image of the outer surface of the thermos, using the formula... This yields the image after background subtraction. in, Image showing the outer surface of a thermos; This represents the filtered image obtained after processing (1-2); This is a linear scaling factor used to enhance the difference; This is the offset, used to adjust the output grayscale range; the final result is... This is the image after background subtraction. S is a structuring element, where i and j are the horizontal and vertical coordinate offsets in the structuring element S, respectively, used to determine the positions of neighboring pixels involved in the calculation.
[0008] Optionally, the longitudinal geometric continuity integral factor in the integral-differential coupled convolution operator is used to enhance the continuity of the discontinuous defect signal; the transverse gradient response factor is used to suppress background texture and capture defect edges.
[0009] Optionally, the formula expression for the integral-differential coupled convolution operator is: ; in, It is the integral factor for longitudinal geometric continuity; This is the transverse gradient response factor.
[0010] Optionally, the formula for the longitudinal geometric continuity integral factor is: ; in, y is the scale of action of the vertical geometric continuity integral factor, and y is the vertical coordinate variable in the local coordinate system defined by the convolution kernel; The formula for the lateral gradient response factor is as follows: ; in, is the scale of the lateral gradient response factor, and x is the lateral coordinate variable in the local coordinate system defined by the convolution kernel.
[0011] Optionally, based on the integral-differential coupled convolution operator, a convolution operation is performed on the image of the outer surface of the thermos cup, and the result is subjected to a piecewise linear-nonlinear hybrid enhancement mapping to generate a gradient-enhanced image, specifically including: According to the formula Generate gradient response plot; According to the formula The generated gradient response map is subjected to piecewise linear-nonlinear hybrid enhancement mapping to generate a gradient enhancement image; in, The preset maximum grayscale value is t, where t is the normalized segmentation threshold of the piecewise function. For index, For parameters, Let G be the slope, and G be the gradient response plot of the input. The grayscale value of the current pixel.
[0012] Optionally, the formula for calculating the weighted judgment index is: ; in, Let be the minimum circumcircle radius of the candidate connected region. For the pre-defined shape weighting parameters, This refers to the maximum grayscale value obtained by statistically analyzing the pixel grayscale values within each candidate connected region. This is the average grayscale value obtained by statistically analyzing the grayscale values of pixels within each connected region.
[0013] Optionally, before acquiring the image of the outer surface of the thermos, the following steps are also included: A database of mapping relationships between the body radius of different models of thermos cups and the target position of the imaging system base displacement platform is established in advance; When the detection model changes, the corresponding parameters are retrieved from the database according to the current model, and the displacement platform is controlled to automatically move to the target position to compensate for the difference in cup radius.
[0014] Secondly, this application provides an adaptive visual inspection device for surface scratches and other defects on a thermos cup, comprising: The imaging unit includes an industrial line scan camera, a coaxial light source, a servo motor for driving the rotation of the thermos cup, a camera adjustment platform, and a light source adjustment platform; The adaptive adjustment unit includes a base displacement platform, a lead screw drive device that drives the platform, and a control system that stores position parameters corresponding to different cup shapes. The computational processing unit is used to execute the aforementioned adaptive visual detection method for surface scratches and other defects on a thermos cup.
[0015] According to the specific embodiments provided in this application, the following technical effects are disclosed: This application provides an adaptive visual detection method and apparatus for scratch-like defects on the surface of thermos cups. By processing the image of the thermos cup's outer surface using an integral-differential coupled convolution operator, the continuity of discontinuous defect signals is effectively enhanced, background textures are suppressed, and defect edges are captured. Combining piecewise linear-nonlinear hybrid enhancement mapping to generate gradient-enhanced images further highlights scratch-like defect features. Simultaneously, a weighted judgment index is used to determine the defect region, improving the accuracy and reliability of the detection. Before detection, a mapping database is established between the radius of the thermos cup body of different models and the target position of the imaging system's base displacement platform, enabling adaptive adjustment during the detection process. This compensates for differences in cup body radius, making the method and apparatus applicable to the detection of various thermos cup models. Compared with some existing visual detection algorithms, this application overcomes their limitations of relying on ideal imaging conditions and being only applicable to planar products, enabling accurate and efficient detection of scratch-like defects on the surface of irregularly shaped cups. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a flowchart illustrating an adaptive visual inspection method for surface scratches on a thermos cup, provided in one embodiment of this application. Figure 2This is a flowchart of a detection process provided in an embodiment of this application; Figure 3 A diagram of a scratch-type defect detection device provided in an embodiment of this application; Figure 4 Schematic diagrams of various adjustment platforms provided in one embodiment of this application; Figure 5 A boundary region extraction diagram a is provided for an embodiment of this application; Figure 6 Boundary region extraction map b provided in an embodiment of this application; Figure 7 Boundary region extraction map c provided in an embodiment of this application; Figure 8 A boundary region extraction map d provided in an embodiment of this application; Figure 9 A boundary region extraction map e provided in an embodiment of this application; Figure 10 A boundary region extraction map f is provided for an embodiment of this application. Detailed Implementation
[0018] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0019] During the production, processing, and transportation of insulated cups, the surface is easily damaged by friction, collisions, or unstable processes, resulting in minor defects such as scratches and abrasions. These defects typically appear as thin, elongated stripes with abrupt changes in brightness under specific lighting angles, significantly impacting the product's appearance and quality. Therefore, accurate identification during subsequent inspection is crucial.
[0020] This application, based on the characteristics of brightness abrupt changes and reflection differences of scratches under specific lighting conditions, constructs an automated visual inspection device that includes an imaging scheme and detection algorithm. This device can stably capture and quantify scratches and abrasions of varying depths. Furthermore, considering the diverse range of thermos cup models, the device integrates a radial displacement compensation module based on screw drive. By automatically adjusting the spatial position of the base displacement platform, it can accurately compensate for radius differences between different cup types. This ensures that after the initial lighting scheme is set, the surfaces of cups with different diameters can automatically align to the optimal imaging working distance, thereby achieving rapid compatibility and consistency inspection of products with multiple specifications. Moreover, the algorithm possesses good adaptability and robustness; when switching between different cup types or materials, stable and high-precision detection results can be maintained by adjusting specified parameters.
[0021] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0022] Example 1 like Figure 1 As shown, this embodiment provides an adaptive visual detection method for surface scratches and other defects on a thermos cup, including: Step 101: Obtain an image of the outer surface of the thermos cup; Step 102: Based on the integral-differential coupled convolution operator, perform convolution operation on the image of the outer surface of the thermos cup, and perform piecewise linear-nonlinear hybrid enhancement mapping on the operation result to generate a gradient-enhanced image; Step 103: Based on the gradient enhancement image, extract the scratch-type defect response region and calculate the first maximum gray value of each candidate connected region in the scratch-type defect response region; the candidate connected region is the region where a morphological dilation operation is performed on the scratch-type defect response region so that spatially adjacent or discontinuous defect responses can be connected. Step 104: If the first maximum gray value of the candidate connected region exceeds the first threshold, the scratch-type defect response region is determined to be a defect region; otherwise, a weighted judgment index is constructed based on the minimum circumscribed circle radius of the candidate connected region, the maximum gray value and the average gray value in the scratch-type defect response region. If the weighted judgment index exceeds the second threshold, the scratch-type defect response region is determined to be a defect region. Step 105: For the defective area, determine the second maximum grayscale value of the defective area in the image of the outer surface of the thermos cup; Step 106: Remove defect areas where the second maximum gray value is lower than the third threshold and defect areas where the outer size of the candidate connected region does not reach the preset size threshold to obtain scratch-like defect areas on the outer surface of the thermos cup.
[0023] In some embodiments, when performing step 101, the specific steps may be as follows: An industrial line scan camera is used to image the outer surface of a rotating thermos cup, and a coaxial light source is used to illuminate it at a high angle with dark field illumination relative to the normal direction of the thermos cup body to obtain an image of the outer surface of the thermos cup.
[0024] Specifically, such as Figure 3As shown, an automated acquisition device is used to acquire images of the outer surface of a thermos cup. This device includes an industrial line scan camera positioned along the rotation axis of the thermos cup and a servo motor for driving the cup. During the inspection process, the industrial line scan camera remains stationary while the thermos cup rotates at a set angular velocity. By synchronously setting the line frequency of the line scan camera and the rotation speed of the thermos cup, the acquired scan lines form a complete circumferential image of the cup. When the industrial line scan camera is working, a coaxial light source is used to provide forward illumination to the surface of the cup. Figure 3 The camera and light source adjustment platforms are configured such that the industrial line scan camera is slightly tilted relative to the normal of the cup body, and a high-angle dark-field lighting method is used to enhance the imaging contrast of surface scratch defects. Under this lighting condition, the reflective properties of the scratch area change due to local depression, exhibiting a clear contrast between light and dark, significantly improving the recognizability of scratch defects in the image. This solution ensures high-quality imaging, which is the foundation for the stability of subsequent inspections.
[0025] In some embodiments, after performing step 101, the method further includes: The image of the outer surface of the thermos cup is subjected to median filtering and background subtraction processing, specifically including: To improve the detection accuracy of scratch-like defects, the image of the outer surface of the thermos cup is preprocessed to suppress noise and enhance the contrast between the defect and the background, providing a reliable foundation for subsequent area localization and accurate detection. The specific steps are as follows: First, median filtering is applied to the image of the thermos's outer surface. While the overall grayscale of the thermos's surface is relatively uniform, slight surface noise can cause noticeable abrupt changes in grayscale after light refraction. If mean filtering is used, these local abrupt changes will affect the grayscale distribution of the entire area, thus reducing the accuracy of defect detection. In contrast, median filtering effectively suppresses single-point or small-area grayscale anomalies while preserving the edge features of genuine scratches and abrasions and ensuring stable grayscale values, thereby improving the stability and reliability of subsequent scratch defect extraction. Specifically, a parameter needs to be preset. The purpose of these parameters will be explained in detail later. After acquiring the image of the thermos cup, the following transformation is performed on each pixel: ; in This represents an image of the outer surface of a thermos, i.e., the input image; This represents the output image after the transformation. For structural elements, here we take a circular region with a radius of 2 as an example; This represents taking the median of the set. The circular structuring element... Definition: ; Among them, the filter parameters Control filter range of operation: The smaller the value, the more sensitive the filter is to local grayscale changes, and the more edges and details are preserved. A larger value enhances the filtering and smoothing effect, suppressing noise, but may blur the edges of small defects. Therefore, it should be adjusted according to the actual imaging effect. For different values.
[0026] In addition, the filter parameters Adjust the size sufficiently to ensure the filtering result covers a large defect area. The resulting filtered image can be used as the background grayscale image of the original image for subsequent background subtraction, thereby enhancing the grayscale contrast of the defects and facilitating accurate extraction of scratch-like defects. The resulting image is then modified as follows: ; in Image showing the outer surface of a thermos; This represents the output image after the transformation, i.e., the filtered image obtained after processing. This is a linear scaling factor used to enhance the difference; This is the offset, used to adjust the output grayscale range; the final result is... The image after background subtraction processing shows that the grayscale contrast between scratches and the background is significantly enhanced, which facilitates the accurate extraction and analysis of abnormal areas in the subsequent process.
[0027] In some embodiments, when performing step 102, the specific steps may be as follows: Construct an anisotropic integral-differential coupled convolution operator and perform convolution operations with piecewise linear-nonlinear hybrid enhancement mapping; After background subtraction preprocessing, although most of the background interference has been removed, some interference remains in the residual image. However, some interference factors still exist, and real scratches and abrasions often exhibit weak grayscale and spatially discontinuous and fragmented characteristics. Existing general edge detection operators (such as Sobel and Canny) are based on local pixel gradients and lack the ability to perceive the long-distance geometric features of dispersed defects, easily leading to missed detections of discontinuous and weak scratches and abrasions. Therefore, this embodiment constructs an integral-differential coupled convolution operator based on the geometric matching principle. This operator utilizes the geometric continuity of scratches and abrasions in the Y direction and enhances the weak and fragmented signals distributed along the Y direction through anisotropic integration. The operator construction defines the convolution kernel function. The tensor product of the longitudinal geometric continuity integral factor and the transverse gradient response factor is as follows: ; in It is the integral factor for longitudinal geometric continuity; This is the transverse gradient response factor. It constructs a long-scale smoothing function along the direction perpendicular to the texture distribution. For scratches and abrasions, even if they are broken or have extremely low grayscale in local pixels, long-distance Y-axis integration can connect them using the signals from their upper and lower neighbors, achieving signal accumulation and enhancement. Simultaneously, for residual random point noise, the integration operation disperses and dilutes its signal, thereby improving the signal-to-noise ratio. Its mathematical expression is as follows: ; in The first-order differential function is constructed along the direction of the texture distribution to represent the lateral gradient response factor. Since the lateral brushed texture has grayscale continuity in the X direction, while scratches and abrasions with random directions exhibit significant grayscale abrupt changes in the X direction, differentiating along the X direction can effectively suppress the brushed texture in the background and capture the edge signals of scratches and abrasions. Its mathematical expression is as follows: ; To achieve optimal matching of scratches and abrasions, the physical constraints of the parameter design impose asymmetric scale limitations on the two factors mentioned above, where the scale of action of the longitudinal geometric continuity integral factor is set. It should be larger than the action scale of the transverse gradient response factor. ,Right now , The value depends on the image quality. This asymmetric design makes the convolution operator spatially represent a slender elliptical response field. It effectively captures scratch and abrasion edge signals while simultaneously enhancing weak, fragmented signals through integration.
[0028] Then perform a convolution operation to generate the background residual image. Combined with the composite convolution operator constructed above Perform two-dimensional convolution operations to generate gradient response maps. The process is as follows: ; in This represents the convolution operation. This is represented as an image after background subtraction processing, which has removed most of the background illumination interference and preserved the abrupt change signal.
[0029] Gradient response plot A piecewise linear-nonlinear hybrid enhancement mapping is performed. To enhance the separability of scratched regions and normal texture regions in terms of grayscale response, further nonlinear enhancement is needed on the processed grayscale gradient map. Since the grayscale difference between weak textures and minor defects in the gradient map is still insufficient to form a significant numerical contrast, directly using it for thresholding or region segmentation will lead to missed detections or unstable segmentation. Therefore, this embodiment uses nonlinear image enhancement to dynamically redistribute the gradient map, which significantly amplifies the subtle gradient abrupt changes caused by small scratches, while the gentle gradient changes of the background texture remain unchanged or are further compressed, thereby effectively improving the contrast between the defective region and the background, providing a clearer and more stable feature response for subsequent region extraction and defect localization. The following transformation is performed on each pixel: ; in, The preset maximum grayscale value is the theoretical maximum value of the image's grayscale levels (0-255). The calculation formula is used to normalize grayscale values. `t` is the normalized segmentation threshold of the piecewise function, ranging from (0,1). It defines the boundary between linear enhancement areas (low grayscale) and nonlinear enhancement areas (high grayscale). `t` is adjusted according to the actual imaging conditions. When the input normalized grayscale value is within the threshold... When above, use with offset of Exponential transformation, this part performs nonlinear enhancement on the medium-to-high grayscale region, through exponential... The parameters determine the strength of the enhancement. Further adjust the starting point and shape of the curve to suit brightness distribution under different conditions; in the low grayscale region, i.e., when the input normalized grayscale is at the threshold... In the following cases, to avoid over-compression caused by power-law transformation, a linear gain is used, where the slope is... The formula automatically calculates the linear segment and the exponential segment. The curve is continuous and smooth. This ensures that there are no abrupt changes along the entire curve, which helps maintain the consistency and smoothness of image brightness. G is the input gradient response map. The grayscale value of the current pixel. Specifically, this refers to the formula input terminal, i.e. The formula calculates the pixel grayscale of the corresponding position in the gradient response map.
[0030] In some embodiments, when performing steps 103-105, the specific steps may be as follows: First, scratch-like defect response regions are extracted from the gradient-enhanced image and recorded as the original candidate regions. Since real-world detection scenarios may contain patches of low-contrast scratches or abrasions, these defects may appear locally broken in the original gradient image, leading to missed detections in subsequent segmentation stages. To avoid this problem, this embodiment performs a moderate morphological dilation operation on the original candidate regions, connecting spatially adjacent or discontinuous defect responses to facilitate subsequent overall identification. After dilation and segmentation, a set of regions containing potential defects is obtained.
[0031] Then, for each candidate connected component in the original candidate region, its maximum gray value is extracted, and the maximum gray value is determined according to a pre-set maximum gray value threshold. A preliminary assessment is needed. Scratches disrupt the original regular texture structure of the cup's surface, causing significant scattering or refraction of incident light at the defect, resulting in prominent local grayscale peaks in the gradient map, such as... Figure 5 As shown. When the maximum gray value of a certain connected component... Exceeding this threshold At that time, it can be directly identified as a defect area. Further visualization results are as follows: Figure 6 The actual extent and shape of the scratches are shown. This determination strategy based on the maximum gray value can effectively locate scratch-type defects with high contrast and obvious gradient changes.
[0032] However, the original candidate regions still contain non-defect responses such as background texture and illumination fluctuations. Therefore, further feature quantization and filtering of each connected region are required based on the imaging characteristics of the defects. By combining region morphology and local gradient characteristics, assigning corresponding weights, and pre-setting a maximum permissible weighted threshold p_set, the true scratch defects and interference regions can be effectively distinguished. The specific weighting determination method is as follows: ; in, This represents the minimum circumcircle radius of the connected domain. The ratio of the two pre-defined morphological weighting parameters is used to quantify the morphological features of the region; where... Defined as: after constructing a background image from the filtering results, the maximum grayscale value is obtained by statistically analyzing the pixel grayscale values within each candidate connected region. This is achieved by statistically analyzing the pixel grayscale values within each connected region after constructing the background image from the filtering results. The ratio of this ratio to the average grayscale value is used to evaluate the degree of grayscale gradient anomaly in the candidate connected region, thereby quantifying the change in its local grayscale gradient. When the weighted value calculated for a candidate connected region... Exceeding the preset threshold When this happens, it can be identified as a defective area.
[0033] like Figure 7 The image shows a scratched area. Although the scratched area exhibits a gentle gradient change and is not easily extracted directly, its regional scale and brightness anomalies are still significantly highlighted after weighted quantization, thus enabling effective identification of this type of gradually changing defect. Through comprehensive judgment of weighted indicators, non-defect interference areas can be effectively eliminated while the scratched defect area is fully preserved. Figure 8 The image visually illustrates the specific extent of the scratches and their actual distribution on the surface of the cup.
[0034] In some embodiments, when performing step 106, the specific steps may be as follows: Abnormal connected components and pseudo-defects within the tolerance range are removed based on morphological features and grayscale information. After the above processing steps, the system can effectively filter out scratch-like defect areas. However, in practical applications, when the overall grayscale level of the cup is low, even if the contrast of a local area reaches the threshold, the absolute grayscale may still remain within a low range. Furthermore, for some minor anomalies within the tolerance range, their shape and grayscale characteristics do not reach the threshold for being judged as valid defects. These areas are usually caused by large-area noise or lighting artifacts that have not been completely filtered out, easily leading to false positives or false negatives.
[0035] To avoid interference from such situations, additional judgment conditions are introduced based on the region features obtained in steps 104-104. The system presets a grayscale lower limit threshold. and as Figure 9 The figure shows the maximum grayscale value obtained by statistically analyzing the pixel grayscale values within each candidate connected region after constructing a background image based on the original image. 2. When the maximum gray value of a certain connected component... 2 is less than the lower limit threshold of grayscale When the candidate connected component does not possess the imaging characteristics of scratch-like defects, it is determined to be eliminated. Figure 10 As shown. Finally, the system further filters based on the dimensional characteristics of the candidate connected components, eliminating those whose dimensions do not meet a preset threshold. These candidate connected components typically manifest as residual noise, tiny light spots, or fragments generated by algorithm decomposition; their area, width, or length are insufficient to cause any actual impact on the cup's structure, and therefore do not need to be output as valid defects. The overall scratch detection algorithm flow is as follows: Figure 2 As shown, the above-mentioned multiple judgment mechanism can significantly improve the accuracy of region screening and reduce misjudgments caused by noise and non-critical structures.
[0036] Furthermore, in some embodiments, before acquiring an image of the outer surface of the thermos cup, the following steps are also included: A database of mapping relationships between the body radius of different models of thermos cups and the target position of the imaging system base displacement platform is established in advance; When the detection model changes, the corresponding parameters are retrieved from the database according to the current model, and the displacement platform is controlled to automatically move to the target position to compensate for the difference in cup radius.
[0037] Example 2 like Figure 3 As shown, this embodiment provides an adaptive visual inspection device for surface scratches and other defects on a thermos cup, including: The imaging unit includes an industrial line scan camera, a coaxial light source, a servo motor for driving the rotation of the thermos cup, a camera adjustment platform, and a light source adjustment platform; The adaptive adjustment unit includes a base displacement platform, a lead screw drive device that drives the platform, and a control system that stores position parameters corresponding to different cup shapes. The computational processing unit is used to execute the aforementioned adaptive visual detection method for surface scratches and other defects on a thermos cup.
[0038] The detection device in this embodiment not only has high-precision detection capabilities for a single-specification thermos cup, but also possesses excellent compatibility and flexible adaptability. While maintaining a constant industrial camera acquisition frequency and rotational mechanism speed, it can automatically adjust to adapt to different cup models. For example, in actual production, when the model of the thermos cup to be detected changes (e.g., the cup body size changes from diameter to diameter 2), the spatial position of the cup body surface changes. If the camera and light source positions remain unchanged, multiple variables such as the imaging focal length and illumination angle will occur, severely affecting image quality and consequently the algorithm accuracy. To solve this problem, without the need for manual recalibration of the camera or light source, this embodiment executes the following adaptive model change process: Firstly, during the equipment debugging phase, various models of insulated cups to be tested (such as models with different radii and tapers) were tested using... Figure 3 The adjustments to each platform were performed beforehand, and optical imaging tests were conducted. A compatible lighting scheme with high depth of field and high angular tolerance was designed (including specific camera tilt angles, coaxial light source tilt angles, and brightness). This scheme utilizes the versatility of the optical system to simultaneously adapt to both cylindrical and slightly tapered cup surfaces, eliminating imaging differences caused by inconsistencies between the upper and lower cylindrical surfaces. Based on this, for each cup type, the absolute position coordinates of the base displacement platform and the lead screw operating parameters required to achieve optimal image sharpness were measured, recorded, and stored in a database.
[0039] When switching between products for testing, operators do not need to perform complex mechanical adjustments; they only need to select the model of the thermos cup to be tested on the human-machine interface. After receiving the model change command, the system automatically retrieves the corresponding parameters from the database, and parses out the target radius parameters and the corresponding base target position coordinates.
[0040] Based on the retrieved parameters, the system controls the lead screw drive device under the base to perform radial displacement compensation. Relying on the physical correction of the working distance by the displacement platform and the angular compatibility of the preset lighting scheme, the system can automatically overcome the changes in the imaging optical path caused by the difference in cup radius and surface taper, ensuring that the surface texture and defect features of the new cup shape are clearly presented again within the camera's optimal depth of field.
[0041] This embodiment, while maintaining a fixed optical hardware structure (camera angle, camera height, and light source angle, etc.), constant rotation speed, and constant line frequency, achieves high-quality imaging compatibility for multiple models and irregularly shaped (including tapered) thermos cups through only single-dimensional automated displacement compensation, and greatly shortens the time for model changeover and setup.
[0042] In summary, this application has the following technical effects: This application proposes a dedicated mechanical structure suitable for such products, and simultaneously constructs a matching imaging scheme and supporting detection algorithm. The designed mechanical structure possesses high structural compatibility and product adaptability, and is not limited to a single cup type. For different product models, there is no need for manual recalibration of optical parameters (such as angle and focal length); preset parameters can be retrieved through a human-machine interface, enabling automated and rapid model changeover based on radial compensation. This significantly reduces debugging costs and improves the versatility and production efficiency of the production line. Furthermore, this algorithm system can achieve accurate identification and quantitative detection of surface scratch defects through high-precision imaging. This method is based on the changes in brightness gradient and reflection characteristics of scratches under specific lighting conditions, combined with specific lighting methods, to achieve stable detection of scratch defects. Normal surfaces exhibit a continuous and smooth brightness distribution due to uniform metal reflection; while scratched areas show obvious brightness abrupt changes and local abnormal texture features. The proposed method has good material adaptability and can be applied to surface scratch detection of various cup body materials, maintaining high detection stability and accuracy even under complex textures, reflective materials, or weak imaging conditions. After the rapid switch is completed, the supporting algorithm can still maintain stable and consistent detection performance, ensuring that the detection accuracy and reliability are not reduced due to changes in cup shape.
[0043] This application boasts stable and high-fidelity imaging: In the image acquisition stage, an industrial line scan camera is employed, combined with a coaxial high-angle dark-field illumination scheme tailored to the characteristics of metal cups, achieving high-contrast rendering of minute defects such as weak scratches and abrasions on the cup surface. This imaging structure effectively reduces artifacts caused by ambient light interference and cup reflections, ensuring that texture details are fully preserved and guaranteeing the stability and consistency of overall imaging quality, providing a high-quality data foundation for subsequent reliable testing.
[0044] This application possesses a robust scratch defect recognition capability: In the defect detection process, a robust detection strategy for scratch defects is constructed. Through multi-scale gradient feature extraction, texture perturbation analysis, and an adaptive threshold discrimination mechanism, it achieves accurate capture of scratches and abrasions of varying degrees. This method can effectively distinguish between genuine defects and pseudo-defects such as metal surface textures, stains, and light spots, significantly improving the accuracy and stability of detection and overcoming the limitations of traditional algorithms in recognizing low-contrast or weak-edge scratches.
[0045] This application features excellent flexibility and automated changeover: it constructs an intelligent changeover mechanism that combines a preset scheme with radial displacement compensation. Without the need for manual recalibration of optical parameters (such as angle and focal length), the system can correct working distance deviations caused by changes in the cup body's structural dimensions through single-axis automatic displacement compensation, enabling rapid changeover for multiple models of products with tapers, greatly improving the versatility and production efficiency of the production line.
[0046] This application demonstrates excellent adaptability and robustness, automatically capturing light and shadow anomalies corresponding to scratches without relying on manual angle adjustments. This enables high-precision, low-false-error automated detection, significantly improving detection efficiency, reducing human interference, and substantially enhancing product quality consistency. The application of this technology will provide strong technical support for enterprises to reduce labor costs, improve efficiency, strengthen quality management systems, and enhance brand competitiveness.
[0047] This application overcomes the technical bottlenecks of traditional scratch defect detection, such as high light sensitivity, insufficient adaptability, and high false detection rate, through the synergistic optimization of imaging scheme and detection method. It provides an efficient, stable, and highly intelligent solution for the detection of minute surface defects in complex scenarios.
[0048] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0049] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. An adaptive visual detection method for surface scratches on thermos cups, characterized in that, include: Acquire an image of the outer surface of the thermos cup; Based on the integral-differential coupled convolution operator, convolution operation is performed on the image of the outer surface of the thermos cup, and the result is subjected to piecewise linear-nonlinear hybrid enhancement mapping to generate a gradient-enhanced image. Based on the gradient-enhanced image, the scratch-type defect response region is extracted, and the first maximum gray value of each candidate connected region in the scratch-type defect response region is calculated; the candidate connected region is the region where a morphological dilation operation is performed on the scratch-type defect response region so that spatially adjacent or discontinuous defect responses can be connected. If the first maximum gray value of the candidate connected region exceeds the first threshold, the scratch-type defect response region is determined to be a defect region; otherwise, a weighted judgment index is constructed based on the minimum circumscribed circle radius of the candidate connected region, the maximum gray value and the average gray value in the scratch-type defect response region. If the weighted judgment index exceeds the second threshold, the scratch-type defect response region is determined to be a defect region. For the defective area, determine the second maximum grayscale value of the defective area in the image of the outer surface of the thermos cup; By removing defect areas where the second maximum gray value is lower than the third threshold and defect areas where the size of the candidate connected region does not reach the preset size threshold, scratch-like defect areas on the outer surface of the thermos cup are obtained.
2. The adaptive visual detection method for surface scratches on a thermos cup according to claim 1, characterized in that, Obtain an image of the outer surface of the thermos, specifically including: An industrial line scan camera is used to image the outer surface of a rotating thermos cup, and a coaxial light source is used to illuminate it at a high angle with dark field illumination relative to the normal direction of the thermos cup body to obtain an image of the outer surface of the thermos cup.
3. The adaptive visual detection method for surface scratches on a thermos cup according to claim 2, characterized in that, After acquiring the image of the outer surface of the thermos, the process also includes: The image of the outer surface of the thermos cup is subjected to median filtering and background subtraction processing, specifically including: According to the formula The image of the outer surface of the thermos cup is transformed to obtain the image after median filtering. Based on the image after median filtering and the image of the outer surface of the thermos, using the formula... This yields the image after background subtraction. in, Image showing the outer surface of a thermos; This represents the filtered image obtained after processing (1-2); This is a linear scaling factor used to enhance the difference; This is the offset, used to adjust the output grayscale range; the final result is... This is the image after background subtraction. S is a structuring element, where i and j are the horizontal and vertical coordinate offsets in the structuring element S, respectively, used to determine the positions of neighboring pixels involved in the calculation.
4. The adaptive visual detection method for surface scratches on a thermos cup according to claim 3, characterized in that, The longitudinal geometric continuity integral factor in the integral-differential coupled convolution operator is used to enhance the continuity of discontinuous defect signals; the transverse gradient response factor is used to suppress background texture and capture defect edges.
5. The adaptive visual detection method for surface scratches on a thermos cup according to claim 4, characterized in that, The formula expression for the integral-differential coupled convolution operator is as follows: ; in, It is the integral factor for longitudinal geometric continuity; This is the transverse gradient response factor.
6. The adaptive visual detection method for surface scratches on a thermos cup according to claim 5, characterized in that, The formula for the longitudinal geometric continuity integral factor is as follows: ; in, y is the scale of action of the vertical geometric continuity integral factor, and y is the vertical coordinate variable in the local coordinate system defined by the convolution kernel; The formula for the lateral gradient response factor is as follows: ; in, is the scale of the lateral gradient response factor, and x is the lateral coordinate variable in the local coordinate system defined by the convolution kernel.
7. The adaptive visual detection method for surface scratches on a thermos cup according to claim 6, characterized in that, Based on the integral-differential coupled convolution operator, a convolution operation is performed on the image of the outer surface of a thermos cup, and the result is subjected to piecewise linear-nonlinear hybrid enhancement mapping to generate a gradient-enhanced image, specifically including: According to the formula Generate gradient response plot; According to the formula The generated gradient response map is subjected to piecewise linear-nonlinear hybrid enhancement mapping to generate a gradient enhancement image; in, The preset maximum grayscale value is t, where t is the normalized segmentation threshold of the piecewise function. For index, For parameters, Let G be the slope, and G be the gradient response plot of the input. The grayscale value of the current pixel.
8. The adaptive visual detection method for surface scratches on a thermos cup according to claim 7, characterized in that, The formula for calculating the weighted judgment index is: ; in, Let be the minimum circumcircle radius of the candidate connected region. For the pre-defined shape weighting parameters, This refers to the maximum grayscale value obtained by statistically analyzing the pixel grayscale values within each candidate connected region. This is the average grayscale value obtained by statistically analyzing the grayscale values of pixels within each connected region.
9. The adaptive visual detection method for surface scratches on a thermos cup according to claim 8, characterized in that, Before acquiring an image of the outer surface of the thermos, the following steps are also included: A database of mapping relationships between the body radius of different models of thermos cups and the target position of the imaging system base displacement platform is established in advance; When the detection model changes, the corresponding parameters are retrieved from the database according to the current model, and the displacement platform is controlled to automatically move to the target position to compensate for the difference in cup radius.
10. An adaptive visual inspection device for surface scratches and other defects on a thermos cup, characterized in that, include: The imaging unit includes an industrial line scan camera, a coaxial light source, a servo motor for driving the rotation of the thermos cup, a camera adjustment platform, and a light source adjustment platform; The adaptive adjustment unit includes a base displacement platform, a lead screw drive device that drives the platform, and a control system that stores position parameters corresponding to different cup shapes. The computational processing unit is used to execute the adaptive visual detection method for surface scratches of thermos cups as described in any one of claims 1-9.