A visual inspection device and a method for inspecting the appearance of plastic products

By using visual inspection equipment and methods, industrial cameras and multi-angle light sources are used to automatically transport plastic products. Combined with autocorrelation matrix filters and smoothing filters, the problem of high false detection rate in traditional inspection technology is solved, and efficient and accurate appearance inspection of plastic products is achieved.

CN122306814APending Publication Date: 2026-06-30SHENZHEN CHANGCHI PRECISION TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN CHANGCHI PRECISION TECH CO LTD
Filing Date
2026-04-28
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

Traditional plastic product appearance inspection technology cannot intelligently distinguish between the inherent structure of the product and actual defects, which easily leads to false detections and lacks an effective defect morphology merging mechanism.

Method used

Visual inspection equipment and methods are employed, utilizing industrial cameras and multi-angle line scan light sources to automatically transport plastic products. By extracting geometric features and locating inherent structures using first-order differential operators, an autocorrelation matrix filter is constructed to optimize defect identification. Combined with a smoothing filter, the defect response is enhanced, thereby achieving accurate division and merging of defect regions.

Benefits of technology

It has improved the automation level and defect identification capability of plastic product appearance inspection, reduced the false detection rate, and enhanced the reliability and consistency of inspection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122306814A_ABST
    Figure CN122306814A_ABST
Patent Text Reader

Abstract

This invention relates to the field of image inspection technology, specifically a visual inspection device and a method for inspecting the appearance of plastic products. The method includes: transferring a fixed plastic product to a position directly below an industrial camera via a slide rail on a plastic product inspection platform, obtaining the plastic product to be inspected; capturing an image of the plastic product to be inspected using the industrial camera, obtaining an image of the plastic product to be inspected; dividing the image of the plastic product to be inspected into inspection regions, obtaining a target plastic image; constructing a target filter; using the target filter to enhance defects in the target plastic image, obtaining a defect response image; and dividing the defect response image into defect regions, obtaining a defect response dataset. This invention can improve the automation level of plastic product appearance inspection and the ability to identify complex defects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image inspection technology, and in particular to a visual inspection device and a method for inspecting the appearance of plastic products. Background Technology

[0002] Appearance inspection of plastic products is a crucial link in quality control in the manufacturing industry. Its inspection results directly affect the final performance, reliability, and aesthetics of the product. With the increasingly stringent requirements for the appearance quality of plastic parts from industries such as consumer electronics and automotive parts, achieving efficient, accurate, and stable automated appearance inspection is of significant technical value for ensuring production consistency, improving product yield, and meeting the needs of high-end manufacturing. Therefore, developing advanced visual inspection methods that can adapt to complex surface characteristics and intelligently distinguish between the inherent structure of a product and actual defects has become an important direction for the continuous evolution of this field.

[0003] Traditional plastic product appearance inspection technology usually relies on manual visual inspection or image processing algorithms with fixed parameters to identify defects. This method has obvious drawbacks: it cannot intelligently distinguish between the inherent structure of the product, such as logos and holes, and real defects, which easily leads to a high false detection rate; for continuous defects that may be broken in the imaging, there is a lack of an effective merging mechanism, which leads to misjudgment of defect morphology. Summary of the Invention

[0004] This invention provides a visual inspection device, a method for inspecting the appearance of plastic products, and a computer-readable storage medium. Its main purpose is to improve the automation level of the appearance inspection of plastic products and the ability to identify complex defects.

[0005] To achieve the above objectives, the present invention provides a visual inspection device, which includes an industrial camera 203, a multi-angle line scan light source 202, and a plastic product inspection table 206. The plastic product inspection table 206 has a template recessed area 205 in the center and a slide rail 201 at the bottom. The multi-angle line scan light source 202 is distributed around the template recessed area 205.

[0006] To achieve the above objectives, the present invention provides a method for inspecting the appearance of plastic products, comprising:

[0007] Obtain the original plastic product and fix it to the recessed area of ​​the template in the plastic product testing table to obtain the fixed plastic product;

[0008] The slide rail of the plastic product inspection station is used to transfer the fixed plastic product to the area directly below the industrial camera to obtain the plastic product to be inspected.

[0009] An industrial camera is used to capture images of the plastic product to be inspected, and the multi-angle line scan light source is turned on simultaneously during image capture.

[0010] The detection region is divided into the plastic image to be detected to obtain the target plastic image;

[0011] The target filter is constructed based on a preset offline sample image set, which includes: an offline defect sample image set and an offline non-defect sample image set;

[0012] Defect enhancement is performed on the target plastic image using a target filter and a pre-constructed smoothing filter to obtain a defect response image;

[0013] Defect regions are segmented based on defect response images to obtain a defect response dataset, which includes multiple defect response data.

[0014] Optionally, the step of dividing the plastic image to be detected into a detection region to obtain the target plastic image includes:

[0015] Geometric features are extracted from the plastic product to be tested to obtain a set of geometric elements to be tested, which includes multiple geometric elements to be tested.

[0016] ROI regions are created based on the set of geometric elements to be detected, resulting in a set of regions of interest to be detected. The set of regions of interest to be detected includes multiple regions of interest to be detected, and each region of interest to be detected corresponds one-to-one with a geometric element to be detected.

[0017] Construct a first-order differential operator, which includes a 0-degree direction template, a 45-degree direction template, a 90-degree direction template, and a 135-degree direction template;

[0018] Edge extraction is performed on the region of interest set to be detected using a first-order differential operator to obtain the non-detection region set;

[0019] The target plastic image is obtained by covering the non-detection region of the non-detection region set with the non-detection region of the plastic image to be detected.

[0020] Optionally, constructing the target filter based on a preset set of offline sample images includes:

[0021] For each offline defect sample image in the offline defect sample image set, perform the following operation:

[0022] Determine the set of defective pixels in the offline defect sample image, wherein the set of defective pixels includes multiple defective pixels;

[0023] Construct a defect autocorrelation matrix based on the defect pixel set;

[0024] The defect autocorrelation matrix corresponding to each offline defect sample image is summarized to obtain the defect autocorrelation matrix set;

[0025] Construct a set of defect-free autocorrelation matrices based on the offline set of defect-free sample images;

[0026] The defective autocorrelation matrix set and the defect-free autocorrelation matrix set are combined to obtain an autocorrelation matrix set, wherein the autocorrelation matrix set includes multiple autocorrelation matrix sets, and each autocorrelation matrix set includes a defective autocorrelation matrix and a defect-free autocorrelation matrix.

[0027] The optimal filter parameters are obtained by using the autocorrelation matrix set.

[0028] Set the target filter based on the optimal filter parameters.

[0029] Optionally, constructing the defect autocorrelation matrix based on the defect pixel set includes:

[0030] Defect pixels are extracted sequentially from the defect pixel set, and a neighborhood pixel set is extracted from the offline defect sample image based on the extracted defect pixels.

[0031] Obtain the set of neighboring pixel values ​​corresponding to the set of neighboring pixel points, and construct the defective pixel value vector based on the set of neighboring pixel values;

[0032] The transposed pixel value vector is obtained from the defect pixel value vector, and the defect pixel value matrix is ​​obtained by performing a vector product operation on the defect pixel value vector and the transposed pixel value vector.

[0033] Summarize the defect pixel value matrix corresponding to each defective pixel to obtain the defect pixel value matrix set;

[0034] The defect pixel value matrix is ​​averaged to obtain the defect autocorrelation matrix.

[0035] Optionally, the step of enhancing the target plastic image using a target filter and a pre-constructed smoothing filter to obtain a defect response image includes:

[0036] The target plastic image is convolved using a target filter to obtain a preliminary filtered response image, which includes multiple preliminary response pixels.

[0037] Energy is calculated for each preliminary response pixel in the preliminary filtered response image to obtain multiple pixel energy values;

[0038] The target plastic image is updated by updating the pixel values ​​based on multiple pixel energy values ​​to obtain an energy response image;

[0039] The energy response image is smoothed using a smoothing filter to obtain the defect response image.

[0040] Optionally, the step of dividing the defect region based on the defect response image to obtain the defect response dataset includes:

[0041] The defect response image is binarized to obtain a binary plastic image. Based on the binary plastic image, connected component analysis is performed to obtain multiple plastic connected components.

[0042] Feature extraction is performed on each of the multiple plastic connected domains to obtain multiple connected domain feature data. Each connected domain feature data includes: the center coordinates of the connected domain, the area of ​​the connected domain, the bounding rectangle region of the connected domain, and the bounding rotation angle.

[0043] By merging defects in multiple plastic connected components using multiple connected component feature data, multiple defect connected components are obtained;

[0044] Defect connected components are extracted sequentially from multiple defect connected components. Information is extracted from the extracted defect connected components to obtain defect response data. The defect response data is then summarized to obtain a defect response dataset.

[0045] Optionally, the step of merging defects in multiple plastic connected components using multiple connected component feature data to obtain multiple defect connected components includes:

[0046] Extract plastic connected components sequentially from multiple plastic connected components, and record the extracted plastic connected components as candidate connected components;

[0047] Candidate connected components are eliminated from multiple plastic connected components, resulting in multiple connected components to be matched;

[0048] Identify the candidate bounding rectangle region corresponding to the candidate connected component from multiple connected component feature data;

[0049] Based on the candidate bounding rectangle region, multiple connected components to be matched and candidate connected components are merged according to the same defect to obtain the merged connected components and merged feature data.

[0050] Multiple plastic connected components and multiple connected component feature data are updated by merging connected components and merging feature data respectively, resulting in multiple updated connected components and multiple updated connected component feature data;

[0051] The multiple updated connected components and the multiple updated connected component feature data are respectively used as multiple plastic connected components and multiple connected component feature data, and the step of sequentially extracting plastic connected components in the multiple plastic connected components is returned until no merged connected components can be obtained.

[0052] Multiple updated connected components that cannot be obtained when merging connected components are denoted as multiple defective connected components.

[0053] Optionally, the step of merging multiple connected components to be matched and candidate connected components based on the candidate bounding rectangle region to obtain merged connected components and merged feature data includes:

[0054] The candidate bounding rectangle region is proportionally enlarged based on a preset pixel enlargement ratio to obtain an enlarged bounding rectangle region.

[0055] The connected components to be matched are extracted sequentially from multiple connected components to be matched, and the bounding rectangle region corresponding to the extracted connected components to be matched is identified from the feature data of multiple connected components.

[0056] Determine whether the bounding rectangle region to be matched intersects with the expanded bounding rectangle region;

[0057] If the bounding rectangle region to be matched intersects with the expanded bounding rectangle region, then obtain the candidate rotation angle of the candidate connected component and the matching rotation angle of the connected component to be matched, respectively.

[0058] Calculate the rotation angle difference based on the candidate rotation angle and the rotation angle to be matched;

[0059] If the rotation angle difference is less than the preset angle difference threshold, the connected component to be matched is recorded as a kinship connected component.

[0060] By summing up the related connected components from multiple connected components to be matched, we obtain multiple related connected components.

[0061] The candidate connected component is merged with multiple related connected components to obtain a merged connected component, and the merged feature data of the merged connected component is calculated.

[0062] To achieve the above objectives, the present invention also provides a plastic product appearance inspection system, comprising:

[0063] The plastic product fixing module is used to acquire the original plastic product and fix it to the template recess area in the plastic product inspection station to obtain the fixed plastic product. Based on the slide rail of the plastic product inspection station, the fixed plastic product is transferred to the area directly below the industrial camera to obtain the plastic product to be inspected.

[0064] The plastic image acquisition module is used to capture images of the plastic product to be inspected using an industrial camera to obtain the plastic image to be inspected. The multi-angle line scan light source is turned on simultaneously during image capture to divide the plastic image to be inspected into detection areas and obtain the target plastic image.

[0065] The filter construction module is used to construct a target filter based on a preset offline sample image set, wherein the offline sample image set includes: an offline defective sample image set and an offline non-defective sample image set;

[0066] The defect data extraction module is used to enhance the defect of the target plastic image using the target filter and the pre-built smoothing filter to obtain the defect response image. Based on the defect response image, the defect region is divided to obtain the defect response dataset, which includes multiple defect response data.

[0067] To address the above problems, the present invention also provides an electronic device, the electronic device comprising:

[0068] Memory, storing at least one instruction;

[0069] The processor executes the instructions stored in the memory to implement the plastic product appearance inspection method described above.

[0070] To address the aforementioned problems, the present invention also provides a computer-readable storage medium storing at least one instruction, which is executed by a processor in an electronic device to implement the aforementioned plastic product appearance inspection method.

[0071] To address the problems described in the background section, this invention first uses a sliding rail to automatically transport and fix the product to the shooting station. Compared to traditional manual handling or non-automated positioning methods, this design achieves automatic transport and precise positioning of the product in the inspection process, reducing manual intervention and thus improving the continuity and automation level of the entire inspection process. Next, the inspection area is divided into the plastic image to be inspected, obtaining the target plastic image. This step creates a region of interest by extracting the product's geometric features and uses a multi-directional first-order differential operator for edge extraction, which can more accurately locate the contours of inherent structures such as logos and holes, and then cover them. This effectively prevents subsequent algorithms from misjudging these inherent structures as scratches, dents, or other defects, reducing the false detection rate and improving the reliability of the inspection. This scheme constructs a target filter based on a pre-set offline sample image set. This step calculates the autocorrelation matrix of the pixel structure using offline defective and non-defective sample images, and trains the filter parameters to maximize the feature separation between defective and non-defective regions. This data-driven approach enables the generated filter to more effectively enhance the response of real defects while suppressing normal background areas. Compared to general filters, this improves the signal-to-noise ratio of defect features. Finally, pixel energy is calculated on the preliminary filtered response. This step amplifies the contrast difference between the defective and background areas and uses a smoothing filter to suppress noise in the energy response image, making the response of the real defective area more continuous and prominent. This processing enhances the integrity of the defective area while smoothing out noise. Therefore, this invention can improve the automation level of plastic product appearance inspection and the ability to identify complex defects. Attached Figure Description

[0072] Figure 1 This is a flowchart illustrating the plastic product appearance inspection method provided in two embodiments of the present invention;

[0073] Figure 2 This is a functional block diagram of the plastic product appearance inspection system provided in two embodiments of the present invention;

[0074] Figure 3 This is a schematic diagram of the structure of an electronic device for implementing the plastic product appearance inspection method according to two embodiments of the present invention;

[0075] Figure 4 This is a side view of a visual inspection device provided in an embodiment of the present invention.

[0076] Explanation of reference numerals in the attached figures:

[0077] 1. Electronic equipment; 10. Processor; 11. Memory; 12. Bus; 201. Slide rail; 202. Multi-angle line scan light source; 203. Industrial camera; 204. Central axis; 205. Template recessed area; 206. Plastic product inspection table.

[0078] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0079] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0080] One embodiment of this application provides a visual inspection device, such as... Figure 4 As shown, the visual inspection equipment includes an industrial camera 203, a multi-angle line scan light source 202, and a plastic product inspection table 206. The plastic product inspection table 206 has a template recessed area 205 in the center and a slide rail 201 at the bottom. The multi-angle line scan light source 202 is distributed around the template recessed area 205.

[0081] Understandably, the industrial camera 203 refers to a camera used for photographing plastic products, and is mounted on the central axis 204 directly above the template recessed area 205. The multi-angle line scan light source 202 refers to light sources mounted on both sides of the plastic product, and each multi-angle line scan light source 202 has a different beam incident angle. The plastic product inspection table 206 refers to a smooth, solid-color platform for placing plastic products. The plastic product inspection table 206 has a template recessed area 205 in its center, which should fit the size of the plastic product to be inspected to fix the product and ensure its stable position during movement. The slide rail 201 refers to a linear guide rail mechanism installed below the plastic product inspection table 206. The slide rail 201 can move smoothly and at a uniform speed along a predetermined path, allowing the plastic product to slide smoothly.

[0082] For example, during use, the slide rail 201 drives the plastic product inspection stage 206 forward along a predetermined path and speed. When the plastic product inspection stage 206 reaches the designated position (i.e., the central axis 204 directly above the template recessed area 205 of the industrial camera 203), the industrial camera 203 and the multi-angle line scan light source 202 are triggered simultaneously to obtain an image of the plastic product in the template recessed area 205. During this process, the plastic product inspection stage 206 can remain stationary or pause briefly, which makes the entire plastic product inspection process highly automated. The operator only needs to perform simple operations during the loading process, such as placing the plastic product in the template recessed area 205, so that multiple plastic products can be automatically photographed by the industrial camera 203, thereby reducing manual intervention and improving the automation level of the plastic product inspection process.

[0083] This application provides a method for inspecting the appearance of plastic products. The execution entity of the plastic product appearance inspection method includes, but is not limited to, at least one of the following electronic devices that can be configured to execute the method provided in this application embodiment: a server, a terminal, etc. In other words, the plastic product appearance inspection method can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes, but is not limited to, a single server, a server cluster, a cloud server, or a cloud server cluster.

[0084] Reference Figure 1 The diagram shown is a flowchart illustrating a plastic product appearance inspection method according to two embodiments of the present invention. In these two embodiments, the plastic product appearance inspection method includes:

[0085] S1. Obtain the original plastic product and fix it to the recessed area of ​​the template in the plastic product testing station to obtain the fixed plastic product.

[0086] It is clear that the "raw plastic products" refer to plastic products that require visual inspection, such as plastic keyboard covers and mobile phone casings. The "fixed plastic products" refer to the raw plastic products that have been fixed, for example, in the feeding area, the raw plastic products are placed into the recessed area of ​​the template by manual labor or a robotic arm.

[0087] S2. The slide rail of the plastic product inspection station will transfer the fixed plastic product to the area directly below the industrial camera to obtain the plastic product to be inspected.

[0088] Understandably, the plastic product to be tested refers to a fixed plastic product that has been moved directly below the industrial camera.

[0089] S3. Use an industrial camera to capture images of the plastic product to be inspected, and obtain images of the plastic product to be inspected. During image capture, the multi-angle line scan light source is turned on simultaneously.

[0090] For example, when the plastic product inspection platform moves directly under the industrial camera, the control system that controls the movement of the plastic product inspection platform will issue a shooting command. After receiving the shooting command, the camera control system will simultaneously start the multi-angle line scan light source and the industrial camera, so that the industrial camera can capture images under the illumination of multiple different angle line scan light sources. These images are the plastic images to be inspected.

[0091] S4. Divide the plastic image to be detected into detection regions to obtain the target plastic image.

[0092] It is clear that the target plastic image refers to the plastic image to be inspected after the detection area has been divided. Since there are non-plastic areas such as logo markings, packaging holes, and positioning holes in the plastic image to be inspected, these non-plastic areas need to be covered from the image to avoid subsequent defect detection algorithms misjudging these inherent structures as surface defects such as scratches and dents, thereby improving the accuracy and reliability of the detection.

[0093] Specifically, the process of dividing the plastic image to be detected into a detection region to obtain the target plastic image includes:

[0094] Geometric features are extracted from the plastic product to be tested to obtain a set of geometric elements to be tested, which includes multiple geometric elements to be tested.

[0095] ROI regions are created based on the set of geometric elements to be detected, resulting in a set of regions of interest to be detected. The set of regions of interest to be detected includes multiple regions of interest to be detected, and each region of interest to be detected corresponds one-to-one with a geometric element to be detected.

[0096] Construct a first-order differential operator, which includes a 0-degree direction template, a 45-degree direction template, a 90-degree direction template, and a 135-degree direction template;

[0097] Edge extraction is performed on the region of interest set to be detected using a first-order differential operator to obtain the non-detection region set;

[0098] The target plastic image is obtained by covering the non-detection region of the non-detection region set with the non-detection region of the plastic image to be detected.

[0099] It should be explained that the set of geometric elements to be detected refers to a collection of multiple geometric elements to be detected. Each geometric element refers to the structural boundary contour of a smooth surface area of ​​the plastic product that is not a defect to be detected, such as the circular boundary of a sealing hole, the rectangular or specific shape boundary of a logo mark, or the circular boundary of a positioning hole. The set of regions of interest to be detected refers to a collection of multiple regions of interest to be detected. Each region of interest to be detected refers to the peripheral image range of a certain geometric element to be detected. The above-mentioned creation of the ROI based on the set of geometric elements to be detected means: based on the mathematical model of each geometric element to be detected (such as the center and radius of a circle, the equation of a line, etc.), extending a preset width of pixels around the geometric element to be detected, thereby defining a local image region for edge detection. This local image region is the region of interest to be detected. Algorithms such as the buffer algorithm and the polygon offset algorithm can be used to perform this ROI creation step. The first-order differential operator refers to a convolution kernel used to calculate the rate of change of image grayscale in multiple directions, such as the Sobel operator or the Prewitt operator. The 0-degree orientation template refers to the convolution kernel that detects the vertical edge of the region of interest to be detected, the 45-degree orientation template refers to the convolution kernel that detects the 45-degree diagonal edge of the region of interest to be detected, the 90-degree orientation template refers to the convolution kernel that detects the horizontal edge of the region of interest to be detected, and the 135-degree orientation template refers to the convolution kernel that detects the 135-degree diagonal edge of the region of interest to be detected.

[0100] Furthermore, the above 0-degree direction template is represented as: The template for a 45-degree direction is represented as follows: The template for a 90-degree direction is represented as: The template for a 135-degree direction is represented as follows: .

[0101] It is clear that the non-detection region set refers to a collection of multiple non-detection regions. These non-detection regions are contour areas representing inherent structures such as logos and holes, obtained through edge extraction and fitting. These non-detection regions should be excluded from defect detection in subsequent steps. The aforementioned non-detection region coverage of the plastic image to be inspected based on the non-detection region set refers to setting the pixel values ​​within the non-detection region set of the plastic image to a specific value, thereby generating a target plastic image that retains only the smooth surface area to be inspected.

[0102] Importantly, the step of using a first-order differential operator to extract edges from the set of regions of interest to be detected, to obtain a set of non-detection regions, includes:

[0103] Regions of interest to be detected are extracted sequentially from the set of regions of interest to be detected. The extracted regions of interest to be detected are convolved using a first-order differential operator to obtain 0-degree gradient component regions, 45-degree gradient component regions, 90-degree gradient component regions and 135-degree gradient component regions.

[0104] The first gradient magnitude is calculated based on the 0-degree gradient component region and the 90-degree gradient component region, and the second gradient magnitude is calculated based on the 45-degree gradient component region and the 135-degree gradient component region.

[0105] The target gradient region is determined based on the first gradient magnitude and the second gradient magnitude.

[0106] Adaptive threshold segmentation is performed on the target gradient region to obtain high gradient threshold and low gradient threshold. The high gradient threshold and low gradient threshold are then used to perform edge recognition on the target gradient image to obtain the edge pixel set.

[0107] Edge fitting is performed based on the edge pixel set to obtain the target detection edge, and the non-detection region is divided according to the target detection edge;

[0108] The non-detection regions corresponding to each region of interest to be detected are summarized to obtain the set of non-detection regions.

[0109] It should be explained that the 0-degree gradient component region, 45-degree gradient component region, 90-degree gradient component region, and 135-degree gradient component region refer to the gradient images obtained after convolution operations using the 0-degree, 45-degree, 90-degree, and 135-degree direction templates, respectively. The first gradient magnitude refers to the gradient intensity calculated by integrating the gradient information in the horizontal and vertical directions. The calculation method for this first gradient magnitude is as follows: ,in, This represents the magnitude of the first gradient. This represents the square root operation. This represents the gradient value of the pixel at the geometric center of the 0-degree gradient component region. This represents the gradient value of the pixel at the geometric center of the 90-degree gradient component region. The second gradient magnitude refers to the gradient strength calculated by combining the gradient information from the two diagonal directions; the calculation method for the second gradient magnitude is the same as that for the first gradient magnitude.

[0110] Furthermore, the high gradient threshold and low gradient threshold refer to two gradient magnitude thresholds obtained after adaptive thresholding. The adaptive thresholding step can be performed using methods such as the OTSU algorithm or the bimodal method. The edge pixel set refers to the set of coordinates of all pixels in the target gradient image identified as potential edges. Edge identification of the target gradient image using the high gradient threshold and low gradient threshold involves: first, marking pixels with gradient magnitudes greater than the high gradient threshold as strong edge points, and marking pixels with gradient magnitudes between the high and low gradient thresholds as weak edge points. Finally, using an edge connection and suppression algorithm, pixels connected to strong edge points among the weak edge points are also identified as strong edge points. The set of all strong edge points is the edge pixel set. The target detection edge refers to the geometric contour obtained after edge fitting, which can be performed using the least squares method. The above-mentioned division of non-detection regions based on target detection edges refers to treating the region enclosed by the target detection edge as the non-detection region.

[0111] S5. Construct a target filter based on a preset offline sample image set, wherein the offline sample image set includes: an offline defective sample image set and an offline non-defective sample image set.

[0112] It is clear that the target filter refers to a filter used to enhance the defective parts in the target plastic image. The offline defect sample image set refers to a collection of multiple offline defect sample images, wherein the offline defect sample images refer to images of plastic product areas containing real surface defects such as scratches and dents. The offline defect-free sample image set refers to a collection of multiple offline defect-free sample images, wherein the offline defect-free sample images refer to images of normal areas of intact plastic products without any surface defects.

[0113] Specifically, the step of constructing the target filter based on a preset offline sample image set includes:

[0114] For each offline defect sample image in the offline defect sample image set, perform the following operation:

[0115] Determine the set of defective pixels in the offline defect sample image, wherein the set of defective pixels includes multiple defective pixels;

[0116] Construct a defect autocorrelation matrix based on the defect pixel set;

[0117] The defect autocorrelation matrix corresponding to each offline defect sample image is summarized to obtain the defect autocorrelation matrix set;

[0118] Construct a set of defect-free autocorrelation matrices based on the offline set of defect-free sample images;

[0119] The defective autocorrelation matrix set and the defect-free autocorrelation matrix set are combined to obtain an autocorrelation matrix set, wherein the autocorrelation matrix set includes multiple autocorrelation matrix sets, and each autocorrelation matrix set includes a defective autocorrelation matrix and a defect-free autocorrelation matrix.

[0120] The optimal filter parameters are obtained by using the autocorrelation matrix set.

[0121] Set the target filter based on the optimal filter parameters.

[0122] It should be explained that the defective pixel set refers to a collection of multiple defective pixels, where defective pixels refer to pixels in the offline defective sample image. The aforementioned defect autocorrelation matrix represents the spatial correlation and structural characteristics between pixels in the offline defective sample image. The defect-free autocorrelation matrix set refers to the set of defect-free autocorrelation matrices corresponding to each offline defect-free sample image in the offline defect-free sample image set. The construction method of the defect-free autocorrelation matrix is ​​the same as that of the aforementioned defective autocorrelation matrix, and will not be repeated here. The autocorrelation matrix set refers to a collection of multiple autocorrelation matrix sets, where an autocorrelation matrix set refers to a data combination consisting of a defective autocorrelation matrix and a defect-free autocorrelation matrix. The aforementioned combination of the defective autocorrelation matrix set and the defect-free autocorrelation matrix set refers to combining each defective autocorrelation matrix in the defective autocorrelation matrix set with each defect-free autocorrelation matrix in the defect-free autocorrelation matrix set to obtain the autocorrelation matrix set. The optimal filter parameters refer to the filter parameters that enable the filter to have the optimal defect region enhancement capability.

[0123] Importantly, the specific method for optimizing filter parameters using the set of autocorrelation matrices to obtain the optimal filter parameters is as follows: Select the original filter, such as a two-dimensional FIR filter, and then use the original filter to perform the following operations on each set of autocorrelation matrices: First, calculate the defect separation value based on the set of autocorrelation matrices. This defect separation value refers to the numerical value of the filter's ability to distinguish between defective and non-defective regions. The larger the defect separation value, the better the filter's effect of enhancing the features of defective regions and suppressing the features of non-defective regions. Parameters such as Euclidean distance, Chebyshev distance, and Manhattan distance can be used as this defect separation value. Furthermore, the original filter is used to filter the offline defective sample images and offline defect-free sample images corresponding to the autocorrelation matrix group respectively, and the defect autocorrelation matrix of the filtered offline defective sample image (denoted as the filtered defect matrix) and the defect-free autocorrelation matrix of the offline defect-free sample image (denoted as the filtered defect-free matrix) are calculated. The calculation method here is the same as the calculation method of the defect autocorrelation matrix above. The defect separation value between the filtered defect matrix and the filtered defect-free matrix is ​​calculated. This defect separation value is denoted as the filtered separation value. The difference between the defect separation value and the filtered separation value is calculated to obtain the separation difference value. The separation difference values ​​corresponding to each autocorrelation matrix group are summarized to obtain the separation difference value set. The separation difference value set is averaged to obtain the average separation difference value. Then, the filter parameters in the original filter are adjusted according to the average separation difference value. The adjustment method can be intelligent optimization algorithms such as genetic optimization algorithms. The average separation difference value is used as the specific fitness value. The above calculation process of the average separation difference value is repeated until the filter parameters that minimize the average separation difference value are found. The filter parameters at this time are the optimal filter parameters.

[0124] Specifically, the construction of the defect autocorrelation matrix based on the defect pixel set includes:

[0125] Defect pixels are extracted sequentially from the defect pixel set, and a neighborhood pixel set is extracted from the offline defect sample image based on the extracted defect pixels.

[0126] Obtain the set of neighboring pixel values ​​corresponding to the set of neighboring pixel points, and construct the defective pixel value vector based on the set of neighboring pixel values;

[0127] The transposed pixel value vector is obtained from the defect pixel value vector, and the defect pixel value matrix is ​​obtained by performing a vector product operation on the defect pixel value vector and the transposed pixel value vector.

[0128] Summarize the defect pixel value matrix corresponding to each defective pixel to obtain the defect pixel value matrix set;

[0129] The defect pixel value matrix is ​​averaged to obtain the defect autocorrelation matrix.

[0130] It is clear that the neighboring pixel set refers to a collection of multiple neighboring pixels, and the neighboring pixels refer to pixels that are 4-connected or 8-connected adjacent to the defective pixel. The neighboring pixel value set refers to the set of pixel values ​​corresponding to each neighboring pixel in the neighboring pixel set. The defective pixel value vector refers to a numerical vector composed of the same value from each neighboring pixel value in the neighboring pixel value set. The transposed pixel value vector refers to the column vector or horizontal dimension of the defective pixel value vector. The defective pixel value matrix refers to the matrix obtained by performing an outer product operation on the defective pixel value vector and the transposed pixel value vector. The matrix averaging refers to the operation of averaging all defective pixel value matrices in the defective pixel value matrix set, that is, adding the matrix values ​​at all the same positions in the defective pixel value matrix set, and then dividing by the total number of defective pixel value matrices in the defective pixel value matrix set. The matrix composed of all the values ​​obtained is the defect autocorrelation matrix.

[0131] S6. Use the target filter and the pre-constructed smoothing filter to enhance the defect in the target plastic image to obtain the defect response image.

[0132] Understandably, the smoothing filter refers to a filter used to suppress isolated high-response points in an image caused by noise, making the response of the real defect area more continuous and prominent, such as a mean filter or a Gaussian filter. The defect response image refers to the target plastic image after the defect response has been processed.

[0133] In detail, the step of enhancing the target plastic image using a target filter and a pre-constructed smoothing filter to obtain a defect response image includes:

[0134] The target plastic image is convolved using a target filter to obtain a preliminary filtered response image, which includes multiple preliminary response pixels.

[0135] Energy is calculated for each preliminary response pixel in the preliminary filtered response image to obtain multiple pixel energy values;

[0136] The target plastic image is updated by updating the pixel values ​​based on multiple pixel energy values ​​to obtain an energy response image;

[0137] The energy response image is smoothed using a smoothing filter to obtain the defect response image.

[0138] It should be explained that the preliminary filtered response image refers to the target plastic image after convolution with the target filter. The preliminary response pixel refers to the pixel in the preliminary filtered response image. The pixel energy value refers to the square of the pixel value of the preliminary response pixel. The energy response image refers to the target plastic image after pixel value update. Updating the pixel value of the target plastic image based on multiple pixel energy values ​​means replacing the original pixel values ​​corresponding to multiple preliminary response pixels with multiple pixel energy values. The target plastic image after pixel value replacement is the energy response image.

[0139] S7. Based on the defect response image, the defect region is divided to obtain the defect response dataset, which includes multiple defect response data.

[0140] It is clear that the defect response dataset refers to a collection of multiple defect response data, wherein the defect response data refers to the information data of a certain defect part in the defect response image.

[0141] Specifically, the defect response dataset obtained by dividing the defect region based on the defect response image includes:

[0142] The defect response image is binarized to obtain a binary plastic image. Based on the binary plastic image, connected component analysis is performed to obtain multiple plastic connected components.

[0143] Feature extraction is performed on each of the multiple plastic connected domains to obtain multiple connected domain feature data. Each connected domain feature data includes: the center coordinates of the connected domain, the area of ​​the connected domain, the bounding rectangle region of the connected domain, and the bounding rotation angle.

[0144] By merging defects in multiple plastic connected components using multiple connected component feature data, multiple defect connected components are obtained;

[0145] Defect connected components are extracted sequentially from multiple defect connected components. Information is extracted from the extracted defect connected components to obtain defect response data. The defect response data is then summarized to obtain a defect response dataset.

[0146] It should be explained that the binary plastic image refers to the defect response image after binarization. Image binarization is existing technology and will not be elaborated further here. The plastic connected component refers to a connected component in the binary plastic image obtained after connected component analysis. The connected component feature data refers to the set consisting of the center coordinates of the connected component, the area of ​​the connected component, the bounding rectangle region of the connected component, and the bounding rotation angle. The center coordinates of the connected component refer to the coordinates of the geometric center of the plastic connected component. The area of ​​the connected component refers to the pixel area of ​​the plastic connected component. The bounding rectangle region of the connected component refers to the smallest rectangle that can completely enclose all pixels in the plastic connected component. The bounding rotation angle refers to the angle between the longer side of the bounding rectangle region of the connected component and the positive direction of the horizontal coordinate axis of the image. The defect connected component refers to the merged region of one or more plastic connected components obtained after defect merging. Because during imaging and image processing, a real, continuous physical defect may be broken into multiple discrete, spatially adjacent, and oriented small connected components in the binary plastic image due to contrast changes, noise, or threshold segmentation, the above-mentioned defect merging step must be performed. The information extraction refers to obtaining the location and size information of the defective connected domain, such as the center position of the defective connected domain, the outline of the connected domain, and the pixel area occupied by the connected domain. This information is the defect response data.

[0147] In detail, the method of merging defects in multiple plastic connected components using multiple connected component feature data to obtain multiple defect connected components includes:

[0148] Extract plastic connected components sequentially from multiple plastic connected components, and record the extracted plastic connected components as candidate connected components;

[0149] Candidate connected components are eliminated from multiple plastic connected components, resulting in multiple connected components to be matched;

[0150] Identify the candidate bounding rectangle region corresponding to the candidate connected component from multiple connected component feature data;

[0151] Based on the candidate bounding rectangle region, multiple connected components to be matched and candidate connected components are merged according to the same defect to obtain the merged connected components and merged feature data.

[0152] Multiple plastic connected components and multiple connected component feature data are updated by merging connected components and merging feature data respectively, resulting in multiple updated connected components and multiple updated connected component feature data;

[0153] The multiple updated connected components and the multiple updated connected component feature data are respectively used as multiple plastic connected components and multiple connected component feature data, and the step of sequentially extracting plastic connected components in the multiple plastic connected components is returned until no merged connected components can be obtained.

[0154] Multiple updated connected components that cannot be obtained when merging connected components are denoted as multiple defective connected components.

[0155] It should be explained that the multiple connected components to be matched refer to the multiple plastic connected components remaining after removing the candidate connected components from the multiple plastic connected components. The candidate bounding rectangle region refers to the bounding rectangle region of the connected component corresponding to the candidate connected component, recorded in the multiple connected component feature data. The merged connected component refers to the new connected component obtained by merging the candidate connected component with one or more connected components to be matched. The merged feature data refers to the connected component feature data corresponding to the merged connected component, and the method of obtaining the merged feature data is the same as the method of obtaining the connected component feature data mentioned above. The multiple updated connected components and the multiple updated connected component feature data refer to the updated multiple plastic connected components and the multiple connected component feature data, respectively. Updating the multiple plastic connected components and the multiple connected component feature data using the merged connected components and the merged feature data means: replacing one or more plastic connected components used to form the merged connected component with the merged connected component. The multiple plastic connected components after replacement are the multiple updated connected components, and the multiple connected component feature data corresponding to the multiple updated connected components are the multiple updated connected component feature data. When a merged connected component cannot be obtained, it means that each of the multiple plastic connected components is already an independent and complete defect region, and there is no need to merge it with other plastic connected components.

[0156] In detail, the step of merging multiple connected components to be matched and candidate connected components based on the candidate bounding rectangle region to obtain merged connected components and merged feature data includes:

[0157] The candidate bounding rectangle region is proportionally enlarged based on a preset pixel enlargement ratio to obtain an enlarged bounding rectangle region.

[0158] The connected components to be matched are extracted sequentially from multiple connected components to be matched, and the bounding rectangle region corresponding to the extracted connected components to be matched is identified from the feature data of multiple connected components.

[0159] Determine whether the bounding rectangle region to be matched intersects with the expanded bounding rectangle region;

[0160] If the bounding rectangle region to be matched intersects with the expanded bounding rectangle region, then obtain the candidate rotation angle of the candidate connected component and the matching rotation angle of the connected component to be matched, respectively.

[0161] Calculate the rotation angle difference based on the candidate rotation angle and the rotation angle to be matched;

[0162] If the rotation angle difference is less than the preset angle difference threshold, the connected component to be matched is recorded as a kinship connected component.

[0163] By summing up the related connected components from multiple connected components to be matched, we obtain multiple related connected components.

[0164] The candidate connected component is merged with multiple related connected components to obtain a merged connected component, and the merged feature data of the merged connected component is calculated.

[0165] It should be explained that the "pixel enlargement ratio" refers to a manually set proportional coefficient used to expand the boundary of the candidate circumscribed rectangular region. This pixel enlargement ratio can be set according to the size of the fracture gap that may be generated in the plastic image of the plastic product under inspection due to typical defects, for example, 0.2. The "expanded circumscribed rectangular region" refers to the candidate circumscribed rectangular region after being proportionally enlarged, wherein proportionally enlarging the region means expanding the candidate circumscribed rectangular region ( ) times, of which, This indicates the scaling factor. The bounding rectangle region to be matched refers to the bounding rectangle region of the connected component corresponding to the connected component to be matched, recorded in multiple connected component feature data. If the bounding rectangle region to be matched intersects with the expanded bounding rectangle region, it indicates that the connected component to be matched is spatially close enough to the candidate connected component.

[0166] Furthermore, the candidate rotation angle refers to the circumscribed rotation angle corresponding to the candidate connected region. The rotation angle to be matched refers to the circumscribed rotation angle corresponding to the connected region to be matched. The rotation angle difference refers to the absolute difference between the candidate rotation angle and the rotation angle to be matched. The angle difference threshold is a manually set maximum allowable angle deviation value used to determine whether the principal directions of the candidate connected region and the connected region to be matched are consistent. This angle difference threshold can be set based on the morphological prior knowledge of the defects in the plastic product to be tested. For example, for long strip-shaped scratch defects, the direction of the broken part should be basically consistent, so the angle difference threshold is set relatively small, such as 10 degrees. For point-shaped or block-shaped defects, the requirement for directional consistency can be relaxed, and the angle difference threshold can be set to 30 degrees. When the rotation angle difference is less than this angle difference threshold, it indicates that the principal extension direction of the candidate connected region and the connected region to be matched is highly consistent, that is, the connected region to be matched and the candidate connected region represent the same defect.

[0167] To address the problems described in the background section, this invention first uses a sliding rail to automatically transport and fix the product to the shooting station. Compared to traditional manual handling or non-automated positioning methods, this design achieves automatic transport and precise positioning of the product in the inspection process, reducing manual intervention and thus improving the continuity and automation level of the entire inspection process. Next, the inspection area is divided into the plastic image to be inspected, obtaining the target plastic image. This step creates a region of interest by extracting the product's geometric features and uses a multi-directional first-order differential operator for edge extraction, which can more accurately locate the contours of inherent structures such as logos and holes, and then cover them. This effectively prevents subsequent algorithms from misjudging these inherent structures as scratches, dents, or other defects, reducing the false detection rate and improving the reliability of the inspection. This scheme constructs a target filter based on a pre-set offline sample image set. This step calculates the autocorrelation matrix of the pixel structure using offline defective and non-defective sample images, and trains the filter parameters to maximize the feature separation between defective and non-defective regions. This data-driven approach enables the generated filter to more effectively enhance the response of real defects while suppressing normal background areas. Compared to general filters, this improves the signal-to-noise ratio of defect features. Finally, pixel energy is calculated on the preliminary filtered response. This step amplifies the contrast difference between the defective and background areas and uses a smoothing filter to suppress noise in the energy response image, making the response of the real defective area more continuous and prominent. This processing enhances the integrity of the defective area while smoothing out noise. Therefore, this invention can improve the automation level of plastic product appearance inspection and the ability to identify complex defects.

[0168] like Figure 2 The diagram shown is a functional block diagram of a plastic product appearance inspection system provided in an embodiment of the present invention.

[0169] The plastic product appearance inspection system 100 of the present invention can be installed in an electronic device. Depending on the functions implemented, the plastic product appearance inspection system 100 may include a plastic product fixing module 101, a plastic image acquisition module 102, a filter construction module 103, and a defect data extraction module 104. The module described in this invention can also be called a unit, which refers to a series of computer program segments that can be executed by the processor of an electronic device and can perform a fixed function, and which are stored in the memory of the electronic device.

[0170] The plastic product fixing module 101 is used to acquire the original plastic product, fix the original plastic product to the template recess area in the plastic product testing table to obtain the fixed plastic product, and transfer the fixed plastic product to the area directly below the industrial camera based on the slide rail of the plastic product testing table to obtain the plastic product to be tested.

[0171] The plastic image acquisition module 102 is used to capture images of the plastic product to be inspected using an industrial camera to obtain the plastic image to be inspected. The multi-angle line scan light source is turned on simultaneously during image capture to divide the plastic image to be inspected into detection areas and obtain the target plastic image.

[0172] The filter construction module 103 is used to construct a target filter based on a preset offline sample image set, wherein the offline sample image set includes: an offline defective sample image set and an offline non-defective sample image set;

[0173] The defect data extraction module 104 is used to enhance the defect of the target plastic image using a target filter and a pre-constructed smoothing filter to obtain a defect response image, and to divide the defect region based on the defect response image to obtain a defect response dataset, wherein the defect response dataset includes multiple defect response data.

[0174] In detail, the modules in the plastic product appearance inspection system 100 described in this embodiment of the invention employ the same methods as described above during use. Figure 1 The same technical means are used for the appearance inspection of plastic products described in the article, and can produce the same technical effect, so they will not be repeated here.

[0175] like Figure 3 The diagram shown is a schematic diagram of the electronic device for the plastic product appearance inspection method provided in the second embodiment of the present invention.

[0176] The electronic device 1 may include a processor 10, a memory 11 and a bus 12, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as a plastic product appearance inspection method program.

[0177] The memory 11 includes at least one type of readable storage medium, such as flash memory, portable hard drive, multimedia card, card-type memory (e.g., SD or DX memory), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of the electronic device 1, such as a portable hard drive. In other embodiments, the memory 11 can be an external storage device of the electronic device 1, such as a plug-in portable hard drive, smart media card (SMC), secure digital card (SD), flash card, etc., equipped on the electronic device 1. Furthermore, the memory 11 includes both internal storage units and external storage devices of the electronic device 1. The memory 11 can be used not only to store application software and various types of data installed on the electronic device 1, such as the code of a plastic product appearance inspection method program, but also to temporarily store data that has been output or will be output.

[0178] In some embodiments, the processor 10 may be composed of integrated circuits, such as a single packaged integrated circuit or multiple integrated circuits with the same or different functions, including combinations of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 10 is the control unit of the electronic device, connecting various components of the entire electronic device through various interfaces and lines. It executes programs or modules stored in the memory 11 (e.g., a plastic product appearance inspection method program) and calls data stored in the memory 11 to perform various functions of the electronic device 1 and process data.

[0179] The bus 12 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus 12 can be divided into an address bus, a data bus, a control bus, etc. The bus 12 is configured to realize the connection and communication between the memory 11 and at least one processor 10, etc.

[0180] Figure 3 Only electronic devices with components are shown; it will be understood by those skilled in the art that... Figure 3The structure shown does not constitute a limitation on the electronic device 1, and may include fewer or more components than shown, or combine certain components, or have different component arrangements.

[0181] For example, although not shown, the electronic device 1 may also include a power supply (such as a battery) to power the various components. Preferably, the power supply can be logically connected to the at least one processor 10 through a power management device, thereby enabling functions such as charging management, discharging management, and power consumption management. The power supply may also include one or more DC or AC power supplies, recharging devices, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device 1 may also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.

[0182] Furthermore, the electronic device 1 may also include a network interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a Wi-Fi interface, a Bluetooth interface, etc.), which is typically used to establish communication connections between the electronic device 1 and other electronic devices.

[0183] Optionally, the electronic device 1 may further include a user interface, which may be a display, an input unit (such as a keyboard), and optionally, a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen, etc. The display may also be appropriately referred to as a screen or display unit, used to display information processed in the electronic device 1 and to display a visual user interface.

[0184] The plastic product appearance inspection method program stored in the memory 11 of the electronic device 1 is a combination of multiple instructions. When run in the processor 10, it can achieve the following:

[0185] Obtain the original plastic product and fix it to the recessed area of ​​the template in the plastic product testing table to obtain the fixed plastic product;

[0186] The slide rail of the plastic product inspection station is used to transfer the fixed plastic product to the area directly below the industrial camera to obtain the plastic product to be inspected.

[0187] An industrial camera is used to capture images of the plastic product to be inspected, and the multi-angle line scan light source is turned on simultaneously during image capture.

[0188] The detection region is divided into the plastic image to be detected to obtain the target plastic image;

[0189] The target filter is constructed based on a preset offline sample image set, which includes: an offline defect sample image set and an offline non-defect sample image set;

[0190] Defect enhancement is performed on the target plastic image using a target filter and a pre-constructed smoothing filter to obtain a defect response image;

[0191] Defect regions are segmented based on defect response images to obtain a defect response dataset, which includes multiple defect response data.

[0192] Specifically, the processor 10's implementation method for the above instructions can be found in [reference needed]. Figures 1 to 3 The descriptions of the relevant steps in the corresponding embodiments are not repeated here.

[0193] Furthermore, if the modules / units integrated in the electronic device 1 are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, the computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, or a read-only memory (ROM).

[0194] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor of an electronic device, can perform the following:

[0195] Obtain the original plastic product and fix it to the recessed area of ​​the template in the plastic product testing table to obtain the fixed plastic product;

[0196] The slide rail of the plastic product inspection station is used to transfer the fixed plastic product to the area directly below the industrial camera to obtain the plastic product to be inspected.

[0197] An industrial camera is used to capture images of the plastic product to be inspected, and the multi-angle line scan light source is turned on simultaneously during image capture.

[0198] The detection region is divided into the plastic image to be detected to obtain the target plastic image;

[0199] The target filter is constructed based on a preset offline sample image set, which includes: an offline defect sample image set and an offline non-defect sample image set;

[0200] Defect enhancement is performed on the target plastic image using a target filter and a pre-constructed smoothing filter to obtain a defect response image;

[0201] Defect regions are segmented based on defect response images to obtain a defect response dataset, which includes multiple defect response data.

[0202] In the embodiments provided by this invention, it should be understood that the disclosed devices, systems, and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative, and actual implementations may have other classification methods.

[0203] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0204] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional modules.

[0205] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.

[0206] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims

1. A visual inspection device, characterized in that, The visual inspection equipment includes an industrial camera (203), a multi-angle line scan light source (202), and a plastic product inspection table (206). The plastic product inspection table (206) has a template recessed area (205) in the center and a slide rail (201) at the bottom. The multi-angle line scan light source (202) is distributed around the template recessed area (205).

2. A method for inspecting the appearance of plastic products using the visual inspection equipment described in claim 1, characterized in that, include: Obtain the original plastic product and fix it to the recessed area of ​​the template in the plastic product testing table to obtain the fixed plastic product; The slide rail of the plastic product inspection station is used to transfer the fixed plastic product to the area directly below the industrial camera to obtain the plastic product to be inspected. An industrial camera is used to capture images of the plastic product to be inspected, and the multi-angle line scan light source is turned on simultaneously during image capture. The detection region is divided into the plastic image to be detected to obtain the target plastic image; The target filter is constructed based on a preset offline sample image set, which includes: an offline defect sample image set and an offline non-defect sample image set; Defect enhancement is performed on the target plastic image using a target filter and a pre-constructed smoothing filter to obtain a defect response image; Defect regions are segmented based on defect response images to obtain a defect response dataset, which includes multiple defect response data.

3. The method for inspecting the appearance of plastic products as described in claim 2, characterized in that, The process of dividing the plastic image to be detected into detection regions to obtain the target plastic image includes: Geometric features are extracted from the plastic product to be tested to obtain a set of geometric elements to be tested, which includes multiple geometric elements to be tested. ROI regions are created based on the set of geometric elements to be detected, resulting in a set of regions of interest to be detected. The set of regions of interest to be detected includes multiple regions of interest to be detected, and each region of interest to be detected corresponds one-to-one with a geometric element to be detected. Construct a first-order differential operator, which includes a 0-degree direction template, a 45-degree direction template, a 90-degree direction template, and a 135-degree direction template; Edge extraction is performed on the region of interest set to be detected using a first-order differential operator to obtain the non-detection region set; The target plastic image is obtained by covering the non-detection region of the non-detection region set with the non-detection region of the plastic image to be detected.

4. The method for inspecting the appearance of plastic products as described in claim 3, characterized in that, The step of constructing the target filter based on a preset offline sample image set includes: For each offline defect sample image in the offline defect sample image set, perform the following operation: Determine the set of defective pixels in the offline defect sample image, wherein the set of defective pixels includes multiple defective pixels; Construct a defect autocorrelation matrix based on the defect pixel set; The defect autocorrelation matrix corresponding to each offline defect sample image is summarized to obtain the defect autocorrelation matrix set; Construct a set of defect-free autocorrelation matrices based on the offline set of defect-free sample images; The defective autocorrelation matrix set and the defect-free autocorrelation matrix set are combined to obtain an autocorrelation matrix set, wherein the autocorrelation matrix set includes multiple autocorrelation matrix sets, and each autocorrelation matrix set includes a defective autocorrelation matrix and a defect-free autocorrelation matrix. The optimal filter parameters are obtained by using the autocorrelation matrix set. Set the target filter based on the optimal filter parameters.

5. The method for inspecting the appearance of plastic products as described in claim 4, characterized in that, The construction of the defect autocorrelation matrix based on the defect pixel set includes: Defect pixels are extracted sequentially from the defect pixel set, and a neighborhood pixel set is extracted from the offline defect sample image based on the extracted defect pixels. Obtain the set of neighboring pixel values ​​corresponding to the set of neighboring pixel points, and construct the defective pixel value vector based on the set of neighboring pixel values; The transposed pixel value vector is obtained from the defect pixel value vector, and the defect pixel value matrix is ​​obtained by performing a vector product operation on the defect pixel value vector and the transposed pixel value vector. Summarize the defect pixel value matrix corresponding to each defective pixel to obtain the defect pixel value matrix set; The defect pixel value matrix is ​​averaged to obtain the defect autocorrelation matrix.

6. The method for inspecting the appearance of plastic products as described in claim 5, characterized in that, The method of enhancing the target plastic image using a target filter and a pre-constructed smoothing filter to obtain a defect response image includes: The target plastic image is convolved using a target filter to obtain a preliminary filtered response image, which includes multiple preliminary response pixels. Energy is calculated for each preliminary response pixel in the preliminary filtered response image to obtain multiple pixel energy values; The target plastic image is updated by updating the pixel values ​​based on multiple pixel energy values ​​to obtain an energy response image; The energy response image is smoothed using a smoothing filter to obtain the defect response image.

7. The method for inspecting the appearance of plastic products as described in claim 6, characterized in that, The defect response dataset is obtained by dividing the defect region based on the defect response image, including: The defect response image is binarized to obtain a binary plastic image. Based on the binary plastic image, connected component analysis is performed to obtain multiple plastic connected components. Feature extraction is performed on each of the multiple plastic connected domains to obtain multiple connected domain feature data. Each connected domain feature data includes: the center coordinates of the connected domain, the area of ​​the connected domain, the bounding rectangle region of the connected domain, and the bounding rotation angle. By merging defects in multiple plastic connected components using multiple connected component feature data, multiple defect connected components are obtained; Defect connected components are extracted sequentially from multiple defect connected components. Information is extracted from the extracted defect connected components to obtain defect response data. The defect response data is then summarized to obtain a defect response dataset.

8. The method for inspecting the appearance of plastic products as described in claim 7, characterized in that, The method involves merging defects in multiple plastic connected components using multiple connected component feature data to obtain multiple defect connected components, including: Extract plastic connected components sequentially from multiple plastic connected components, and record the extracted plastic connected components as candidate connected components; Candidate connected components are eliminated from multiple plastic connected components, resulting in multiple connected components to be matched; Identify the candidate bounding rectangle region corresponding to the candidate connected component from multiple connected component feature data; Based on the candidate bounding rectangle region, multiple connected components to be matched and candidate connected components are merged according to the same defect to obtain the merged connected components and merged feature data. Multiple plastic connected components and multiple connected component feature data are updated by merging connected components and merging feature data respectively, resulting in multiple updated connected components and multiple updated connected component feature data; The multiple updated connected components and their feature data are respectively used as multiple plastic connected components and their feature data, and the step of sequentially extracting plastic connected components from the multiple plastic connected components is returned until no merged connected components can be obtained. Multiple updated connected components that cannot be obtained when merging connected components are denoted as multiple defective connected components.

9. The method for inspecting the appearance of plastic products as described in claim 8, characterized in that, The step involves merging multiple connected components to be matched and candidate connected components based on the candidate bounding rectangle region, to obtain merged connected components and merged feature data, including: The candidate bounding rectangle region is proportionally enlarged based on a preset pixel enlargement ratio to obtain an enlarged bounding rectangle region. The connected components to be matched are extracted sequentially from multiple connected components to be matched, and the bounding rectangle region corresponding to the extracted connected components to be matched is identified from the feature data of multiple connected components. Determine whether the bounding rectangle region to be matched intersects with the expanded bounding rectangle region; If the bounding rectangle region to be matched intersects with the expanded bounding rectangle region, then obtain the candidate rotation angle of the candidate connected component and the matching rotation angle of the connected component to be matched, respectively. Calculate the rotation angle difference based on the candidate rotation angle and the rotation angle to be matched; If the rotation angle difference is less than the preset angle difference threshold, the connected component to be matched is recorded as a kinship connected component. By summing up the related connected components from multiple connected components to be matched, we obtain multiple related connected components. The candidate connected component is merged with multiple related connected components to obtain a merged connected component, and the merged feature data of the merged connected component is calculated.

10. A plastic product appearance inspection system, characterized in that, The system includes: The plastic product fixing module is used to acquire the original plastic product and fix it to the template recess area in the plastic product inspection station to obtain the fixed plastic product. Based on the slide rail of the plastic product inspection station, the fixed plastic product is transferred to the area directly below the industrial camera to obtain the plastic product to be inspected. The plastic image acquisition module is used to capture images of the plastic product to be inspected using an industrial camera to obtain the plastic image to be inspected. The multi-angle line scan light source is turned on simultaneously during image capture to divide the plastic image to be inspected into detection areas and obtain the target plastic image. The filter construction module is used to construct a target filter based on a preset offline sample image set, wherein the offline sample image set includes: an offline defective sample image set and an offline non-defective sample image set; The defect data extraction module is used to enhance the defect of the target plastic image using the target filter and the pre-built smoothing filter to obtain the defect response image. Based on the defect response image, the defect region is divided to obtain the defect response dataset, which includes multiple defect response data.