Shell detection method and device, computer device and readable storage medium
By acquiring shell inspection images, identifying abnormal points, and calculating the area and depth of defects, the accuracy problem of manual visual inspection is solved, and the automation and accuracy improvement of shell inspection are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN FUTAIXIN TECHNOLOGY CO LTD
- Filing Date
- 2025-12-26
- Publication Date
- 2026-05-12
AI Technical Summary
Current methods for detecting defects in the shell appearance rely on manual visual inspection, which can lead to missed detections and misjudgments. Traditional contact measurement cannot provide a quantitative evaluation of the entire surface and is not suitable for full inspection on the production line.
By acquiring inspection images of the shell, abnormal points are identified, abnormal areas are divided, refractive features are extracted, defect area and depth are calculated, and the results are judged in conjunction with inspection standards.
It improves the accuracy of shell inspection, reduces human subjectivity, and enables simultaneous quantification of two-dimensional area and three-dimensional morphology, making it suitable for automated inspection of complex surfaces and soft coatings.
Smart Images

Figure CN121414743B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image recognition, and more particularly to a shell detection method, apparatus, and computer equipment. Background Technology
[0002] Currently, the inspection of casing appearance defects in many enterprises still relies primarily on manual visual inspection, supplemented by spot checks using contact roughness testers or microscopes. Manual inspection depends on the inspector's experience and subjective thresholds, and is prone to missed detections and misjudgments when dealing with batches of casings with complex surface reflections (such as those with spraying, anodizing, electroplating, and plastic spraying). Defects such as micro-scratches, small pits, abrasions, orange peel texture, and pinholes show significant differences under different incident angles and background lighting, making it difficult to guarantee the consistency of results from multiple visual inspections of the same part. In addition, traditional point-based contact measurement can only sample locally, failing to provide a quantitative evaluation of the entire surface, and the contact probe introduces deformation errors and secondary damage on soft coatings or curved surfaces, making it unsuitable for full-line inspection.
[0003] Therefore, how to provide a shell inspection method that can effectively improve the accuracy of shell inspection has become a technical problem that urgently needs to be solved in this field. Summary of the Invention
[0004] Therefore, it is necessary to provide a shell detection method, apparatus, computer equipment, and readable storage medium to address the aforementioned technical problems and solve the problem of low accuracy in traditional shell detection methods.
[0005] A shell inspection method, the method comprising:
[0006] Acquire a detection image of the shell to be tested, wherein the shell to be tested corresponds to a detection standard;
[0007] Based on the detected image, abnormal points on the surface of the shell to be detected are detected;
[0008] Based on the anomalies, the detection image is divided into regions to obtain the anomalies and the defect area of the anomalies.
[0009] Refractive features are extracted from the abnormal region, and the defect depth of the abnormal region is determined based on the refractive features.
[0010] Based on the defect area, the defect depth, and the detection standard, the detection result of the shell to be tested is determined.
[0011] Optionally, acquiring the detection image of the shell to be detected includes:
[0012] Under preset lighting conditions, multiple initial detection images of the shell to be tested are acquired, and each initial detection image is captured from a different angle.
[0013] Based on multiple initial detection images, coordinate normalization processing is performed to obtain multiple normalized initial detection images;
[0014] The detection image is obtained by fusing multiple normalized initial detection images.
[0015] Optionally, detecting abnormal points on the surface of the housing to be detected based on the detected image includes:
[0016] The color and brightness information of each pixel are extracted from the detected image;
[0017] Based on the color information and the brightness information, the optical response value of each pixel is obtained by combining them according to a preset weight.
[0018] Calculate the difference between the optical response value of each pixel and the average optical response value of its neighborhood;
[0019] The abnormal points are identified by comparing the difference with a preset response threshold.
[0020] Optionally, the step of performing region segmentation processing on the detected image based on the anomaly points to obtain the anomaly region and the defect area of the anomaly region includes:
[0021] Based on the spatial relationship between the anomalies, the anomalies are clustered to obtain at least one anomaly region.
[0022] The number of abnormal points in each abnormal region is counted, and the defect area of the abnormal region is calculated based on the number of abnormal points and the preset mapping relationship between the pixels of the detected image and the physical size.
[0023] Optionally, extracting refractive features from the anomalous region and determining the defect depth of the anomalous region based on the refractive features includes:
[0024] Based on the brightness information of each pixel in the abnormal region, the brightness information distribution of the abnormal region is statistically obtained;
[0025] Based on the brightness information distribution, the refractive characteristics of the abnormal region are determined;
[0026] The refractive features are input into a preset mapping table to match and obtain the defect depth of the abnormal region. The preset mapping table includes different refractive features and the depth values corresponding to different refractive features.
[0027] Optionally, the detection standard includes a key surface detection standard and a non-key surface detection standard. The key surface detection standard includes a first defect area threshold and a first defect depth threshold. The non-key surface detection standard includes a second defect area threshold and a second defect depth threshold. The first defect area threshold is less than the second defect area threshold, and the first defect depth threshold is less than the second defect depth threshold. Determining the detection result of the shell to be inspected based on the defect area, the defect depth, and the detection standard includes:
[0028] Determine whether the detection surface to which the abnormal region belongs is a key surface;
[0029] If it is a critical surface, then the first defect area threshold is determined as the target defect area threshold, and the first defect depth threshold is determined as the target defect depth threshold;
[0030] If it is a non-critical surface, then the second defect area threshold is determined as the target defect area threshold, and the second defect depth threshold is determined as the target defect depth threshold;
[0031] When the defect area is not less than the target defect area threshold and / or the defect depth is not less than the target defect depth threshold, the test result of the shell to be tested is determined to be a defective product.
[0032] When the defect area is less than the target defect area threshold and the defect depth is less than the target defect depth threshold, the test result of the shell to be tested is determined to be a qualified product.
[0033] Optionally, after determining the detection result of the shell to be inspected based on the defect area, the defect depth, and the detection criteria, the method further includes:
[0034] When the test result is a defective product, an alarm signal is output and a control signal is output to a preset marking device so that the marking device marks the shell to be tested as a defective product.
[0035] When the test result is a qualified product, the test result is stored in a preset test database. A shell testing device, the device comprising:
[0036] The acquisition module is used to acquire the detection image of the shell to be detected, which corresponds to a detection standard;
[0037] The detection module is used to detect abnormal points on the surface of the shell to be detected based on the detection image;
[0038] The segmentation module is used to perform region segmentation processing on the detection image based on the abnormal points to obtain the abnormal region and the defect area of the abnormal region.
[0039] An extraction module is used to extract refractive features from the abnormal region and determine the defect depth of the abnormal region based on the refractive features.
[0040] The determination module is used to determine the detection result of the shell to be tested based on the defect area, the defect depth, and the detection standard.
[0041] A computer device includes a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein the processor implements the aforementioned housing detection method when executing the computer-readable instructions.
[0042] A readable storage medium having computer-readable instructions stored thereon, which, when executed by a processor, implement the aforementioned shell detection method.
[0043] The aforementioned shell inspection method acquires an inspection image of the shell to be inspected, which corresponds to an inspection standard; based on the inspection image, it detects abnormal points on the surface of the shell; based on the abnormal points, it performs region segmentation processing on the inspection image to obtain abnormal regions and the defect area of the abnormal regions; it extracts refractive features from the abnormal regions and determines the defect depth of the abnormal regions based on the refractive features; based on the defect area, the defect depth, and the inspection standard, it determines the inspection result of the shell to be inspected. By acquiring an inspection image, identifying abnormal points from the pixel layer and segmenting abnormal regions, calculating the defect area, extracting refractive features within the abnormal regions and mapping them to the defect depth, and finally judging according to the inspection standard, it forms a simultaneous quantification of two-dimensional range and three-dimensional morphology, which can significantly reduce human subjectivity and effectively improve inspection accuracy. Attached Figure Description
[0044] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0045] Figure 1 This is a schematic flowchart of a shell detection method according to an embodiment of the present invention;
[0046] Figure 2 This is a schematic diagram of the structure of the shell detection device in one embodiment of the present invention;
[0047] Figure 3 This is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed Implementation
[0048] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0049] In one embodiment, such as Figure 1 As shown, a shell inspection method is provided, including the following steps:
[0050] 101. Obtain the detection image of the shell to be detected.
[0051] In this embodiment of the invention, the housing to be inspected can be a structural shell such as a stamped part, die-cast part, or injection-molded part. These shells typically have a coating, anodized layer, or polished layer on their surface, making them susceptible to appearance defects due to process fluctuations, mold wear, or mechanical scratches during handling. By inspecting the shell, automatic screening of appearance quality can be achieved before shipment, preventing defective parts from entering subsequent assembly processes.
[0052] Inspection images can be acquired by industrial cameras under set lighting conditions and shooting angles, or by using multi-view camera arrays or mobile robotic arms to scan the housing from multiple angles to improve the coverage and resolution of complex curved surfaces. To ensure image quality and consistency, constant-illuminance ring light sources or surface light sources are typically installed at the inspection station, combined with diffusers to suppress specular highlights, thereby reducing brightness fluctuations caused by uneven illumination.
[0053] Before acquiring inspection images, inspection standard information can be retrieved. Inspection standards can be understood as the criteria for determining conformity for a specific housing product, which may include parameters such as the maximum allowable area threshold and maximum depth threshold for surface defects. During runtime, the inspection standard corresponding to the current product model can be automatically loaded, and the final inspection result is generated after comparing the defect area and depth obtained from image analysis with the thresholds. For example, when inspecting an aluminum alloy laptop casing, the inspection standard can be set to "visible scratch length must not exceed 0.5 mm, and depth must not exceed 5 μm," while when inspecting an automotive instrument panel casing, the standard can be defined as "dimple diameter less than 0.3 mm is acceptable." By pre-setting inspection standards, flexible adaptation to different product requirements can be achieved, realizing a universal inspection logic across products and processes.
[0054] 102. Based on the detected image, detect abnormal points on the surface of the shell to be detected.
[0055] In this embodiment of the invention, anomalies can refer to pixels in an image whose optical features (including brightness, color, or reflection intensity) are significantly different from those of the surrounding area. These pixels typically correspond to physical defects on the surface of the housing, such as scratches, dents, indentations, or coating peeling.
[0056] The system can perform pixel-by-pixel analysis on the detected image, extracting the color and brightness information of each pixel and combining them according to preset weights to obtain an optical response value that reflects the overall optical characteristics of the pixel. Then, the difference between the optical response value of each pixel and the average optical response value in its local neighborhood is calculated and compared with a response threshold. When the difference is greater than a first response threshold, the pixel is determined to have a significant deviation in optical performance from the surrounding background, and the pixel is marked as an anomaly.
[0057] The above methods can identify minor scratches or surface dents that are difficult to detect with the naked eye at an early stage, thus providing basic data for subsequent area division and quantitative defect analysis.
[0058] 103. Based on the anomalies, perform region segmentation processing on the detected image to obtain the anomaly region and the defect area of the anomaly region.
[0059] In this embodiment of the invention, the abnormal region can be a set of pixels composed of abnormal points that are close to each other in space, which is used to reflect the distribution range of the shell surface defects in the actual space.
[0060] First, the spatial coordinates of all anomalies are obtained, and the relative positions between them are analyzed. When the pixel distance between any two anomalies is less than a preset proximity threshold, they are determined to belong to the same potential defect area. Based on this, a clustering algorithm is used to group all anomalies, gradually merging anomalies that meet the proximity condition until no new anomalies meet the merging condition, thus obtaining at least one independent anomaly region.
[0061] Once each abnormal region is identified, the number of abnormal points contained within that region is counted. Combined with the resolution information of the detected image and the preset mapping relationship between pixels and physical dimensions, the number of pixels is converted into the actual physical area to obtain the defect area.
[0062] For example, when the camera's imaging ratio is calibrated to 1 pixel corresponding to 5 micrometers, and an abnormal area contains 8000 abnormal points, the calculated defect area of that area is approximately 0.2 square millimeters. This area information is not only used for subsequent quality assessment but can also serve as feedback data for production process control, used to analyze mold wear or process deviations.
[0063] The above method can quickly and accurately form abnormal regions corresponding to physical defects, providing clear spatial boundaries for subsequent refractive feature analysis and depth calculation.
[0064] 104. Extract refractive features from the abnormal region and determine the defect depth of the abnormal region based on the refractive features.
[0065] In this embodiment of the invention, refractive features can be understood as a combination of statistical parameters describing the light reflection behavior of abnormal regions, such as the peak position of the brightness distribution, the rate of change of the brightness gradient, the width of the bright-dark boundary, or the average brightness deviation of the region. Depending on the surface material and imaging conditions, the refractive features have a stable correspondence with the actual surface unevenness. Using a pre-established mapping relationship or model, the refractive features are converted into corresponding depth values, thereby estimating the defect depth of the abnormal region.
[0066] For example, in the inspection of metal or highly reflective shells, localized micro-dimples often result in a brightness distribution pattern of low brightness at the center and high brightness at the edges, while micro-scratches appear as bright stripes along a certain direction. By identifying these typical optical change patterns, the refractive characteristics of the abnormal area can be determined, and the corresponding depth range can be calculated using a mapping model.
[0067] Using the above method, the depth of surface defects can be quickly and accurately assessed without complex three-dimensional reconstruction, thus enabling a comprehensive judgment of the shell surface quality.
[0068] In an alternative implementation, if sufficient calibration data is available, a lightweight regression model can replace table lookup matching, directly mapping refractive features to depth values. The model's training objective remains consistent with the mapping table, still falling within the scope of predefined relationships. For deep curved surfaces or scenes with significant parallax, position-dependent scaling corrections or local illumination compensation can be introduced within the region to ensure the consistency of refractive features across different image locations, thereby maintaining the comparability of depth estimates.
[0069] By extracting refractive features from abnormal areas and determining defect depth accordingly, a third-dimensional quantitative support is provided for subsequent joint judgment based on defect area and depth, enabling differentiated treatment of shallow and wide scratches versus narrow and deep scratches. This process is traceable and reproducible: on the one hand, the depth is derived from a calibrated mapping relationship; on the other hand, the refractive features are directly derived from recordable brightness information distribution, facilitating evidence verification in quality audits or disputed scenarios. Overall, without altering the production line's shooting rhythm, the physical basis of detection is enhanced, extending automated optical inspection from two-dimensional area measurement to a comprehensive evaluation incorporating three-dimensional morphological information.
[0070] 105. Based on the defect area, defect depth, and testing standards, determine the test results of the shell to be tested.
[0071] In this embodiment of the invention, for each abnormal region, the calculated defect area is first compared with a defect area threshold, and the defect depth obtained by refractive feature matching is compared with a defect depth threshold. When either of these exceeds the corresponding threshold, the abnormal region is determined to be a defective product, and the shell to be inspected is classified as a defective product; if the area and depth of all abnormal regions are less than the threshold, the shell is determined to be a qualified product.
[0072] This judgment method can be expanded according to actual needs. For decorative products with high appearance requirements, an "OR" logic can be used, meaning that if either the area or depth exceeds the threshold, the product is considered defective. For structural or concealed components, an "AND" logic can be used, meaning that only when both the area and depth exceed the threshold is the product considered unqualified. Combined indicators, such as the approximate defect volume (the product of area and depth), can also be calculated during the judgment process to ensure consistent measurement across different types of defects. Furthermore, to prevent misjudgments caused by random noise or false detections, a confidence threshold can be set, allowing for manual review or a second inspection of results with low confidence levels.
[0073] For example, when a linear scratch is detected on the casing of a laptop, the calculated defect area is 0.45 mm² and the defect depth is 4 μm. However, the testing standard specifies an area threshold of 0.3 mm² and a depth threshold of 3 μm. Therefore, the defect exceeds the standard in both area and depth, and the casing is directly judged as a defective product, generating an alarm signal to alert the operator. If another tiny dent is detected, with an area of only 0.08 mm² and a depth of 2 μm, it does not exceed the standard range and is judged as a qualified product.
[0074] By using a dual-threshold joint judgment method, the bias caused by judging a single area or a single brightness can be avoided, making the detection results more consistent with actual visual perception and product function requirements.
[0075] In one possible embodiment, the detection standard may also incorporate the concept of region weights or sensitive areas. For example, in automotive interior parts, the threshold for the visible area can be set more strictly, while the threshold for the non-visible area can be appropriately relaxed; in mobile phone frame detection, the threshold for the edge area of the display screen can be lower than that for the back area. Based on the region template in the detection standard, the position index of the shell to be detected in the image is read, and the corresponding threshold is applied to different regions for judgment, thereby ensuring the targeting and accuracy of the detection.
[0076] In alternative implementations, testing standards can also be dynamically switched through online database updates or by issuing parameter files through the production management system, in order to quickly adapt to production scenarios involving multiple models and batches.
[0077] By comprehensively comparing defect area, defect depth, and inspection standards, accurate determination of pass / fail can be achieved under fully automated conditions, avoiding deviations caused by subjective judgment in manual inspection. This enables quantitative and traceable quality control throughout the entire inspection process and provides a clear logical basis for subsequent defect marking and data storage.
[0078] In this embodiment of the invention, a detection image of a shell to be inspected is acquired, the shell corresponding to a detection standard; based on the detection image, abnormal points on the surface of the shell are detected; based on the abnormal points, the detection image is divided into regions to obtain abnormal regions and the defect area of the abnormal regions; refractive features are extracted from the abnormal regions, and the defect depth of the abnormal regions is determined based on the refractive features; based on the defect area, the defect depth, and the detection standard, the detection result of the shell to be inspected is determined. By acquiring a detection image, identifying abnormal points from the pixel layer and dividing them into abnormal regions, calculating the defect area, extracting refractive features within the abnormal regions and mapping them to the defect depth, and finally judging according to the detection standard, a simultaneous quantification of the two-dimensional range and the three-dimensional morphology is formed, which can significantly reduce human subjectivity and effectively improve detection accuracy.
[0079] It is understood that in the specific embodiments of this application, data related to detection images, initial detection images, alarm signals, etc. are involved. When the embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0080] Optionally, in the step of acquiring the detection image of the shell to be detected, multiple initial detection images of the shell to be detected can be acquired under preset lighting conditions, with each initial detection image having a different shooting angle; coordinate normalization processing is performed on the multiple initial detection images to obtain multiple normalized initial detection images; the multiple normalized initial detection images are then fused to obtain the detection image.
[0081] In this embodiment of the invention, the purpose of multi-angle shooting is to overcome the problem of defect concealment caused by surface reflection characteristics under single illumination and a fixed viewing angle. For housings with specular reflection or complex curved surfaces, when the relative positions of the light source and the camera are fixed, some areas may be in reflection dead zones or shadow areas, making it difficult to detect minor defects such as fine scratches and dents. By changing the shooting angle, incident light from different directions can illuminate the same surface area, thereby enhancing the reflection characteristics of defects in at least one frame of image, significantly improving the detection coverage and reliability.
[0082] In practical implementation, the above-mentioned multi-angle acquisition can be achieved through a multi-camera array or multiple shots taken by a single camera. The multi-camera array method is suitable for high-speed production line inspection, where multiple cameras are fixed at different angle positions (such as 0°, 30°, 60°, 90°, etc.), and multiple frames of images are simultaneously exposed and acquired as the workpiece passes through the inspection area; the single-camera multiple-shot method is suitable for occasions with lower cycle time requirements, and multi-angle imaging can be achieved by changing the camera posture through a controllable rotating platform or robotic arm.
[0083] After each initial detection image is acquired, coordinate normalization is performed on multiple frames of images based on the shell's positioning features or the reference markings of the mounting fixture. The purpose of coordinate normalization is to map shell images from different viewpoints to a unified reference coordinate system, ensuring that the position of the same surface point is consistent across different images, facilitating subsequent fusion and feature analysis. Normalization can be achieved by calculating the homography matrix through feature point matching, or by implementing geometric transformations based on structured light, calibration points, or fixture coordinates. When normalizing curved shell surfaces, a projection transformation method based on a CAD model can also be used to establish a consistent mapping between image coordinates and shell surface coordinates.
[0084] After normalization of multiple frames, a fusion process is performed to obtain the final detection image. The fusion process can employ pixel-level maximum brightness fusion, weighted average fusion, or confidence-based adaptive fusion. Maximum brightness fusion is suitable for detecting scratch-like defects; by retaining the pixels with the largest brightness variations in each frame, it can highlight reflective bands and refractive differences. Weighted average fusion is suitable for removing random noise and obtaining smooth background brightness. Adaptive fusion, on the other hand, can allocate weights based on the local signal-to-noise ratio in each frame, achieving a balance between brightness enhancement and noise suppression.
[0085] Image fusion can effectively integrate illumination information from various angles to form a detection image with high contrast and high detail fidelity, providing richer feature inputs for subsequent anomaly detection and region segmentation.
[0086] For example, when inspecting the anodized aluminum alloy casing of a laptop, under single-angle illumination, some shallow scratches can only be observed at specific reflection angles; at other angles, they blend with the background reflection and are difficult to identify. By setting up four cameras to acquire images at incident angles of 15°, 30°, 45°, and 60°, and then fusing them after coordinate normalization, all potential scratches are enhanced and clearly visible in the fused image, with significant brightness differences, facilitating the algorithm's extraction of anomalies. Similarly, for the inspection of plastic painted casings, using a ring light source and imaging with different incident directions can significantly reduce false features of surface textures and improve the contrast of genuine pits or coating peeling areas.
[0087] Optionally, in the step of detecting abnormal points on the surface of the shell to be detected based on the detection image, the color information and brightness information of each pixel can also be extracted from the detection image; the optical response value of each pixel can be obtained by combining the color information and brightness information according to a preset weight; the difference between the optical response value of each pixel and the average optical response value of the neighborhood can be calculated; and the abnormal points can be identified among all pixels by comparing the difference with a preset response threshold.
[0088] In this embodiment of the invention, color information and brightness information of each pixel are obtained from the image. The color information can be directly obtained from the RGB channel, or converted to Lab, HSV, or other channels through color space conversion to enhance perceptual consistency. The brightness information can be obtained by using weighted grayscale or the Y channel to suppress interference caused by changes in pure color.
[0089] After obtaining the two types of information mentioned above, they are combined according to preset weights to obtain the optical response value used to characterize the optical features of the pixel. For example, the optical response value can be calculated using the formula R=αL+βΔE, where α is the luminance weight coefficient, β is the color weight coefficient, L is the luminance value, and ΔE is the color difference of the pixel.
[0090] The ratio of the brightness weighting coefficient to the color weighting coefficient can be set according to the material type of the shell to be inspected. For highly reflective materials such as brushed metal and anodized metal, changes in brightness are more sensitive to defects, and the brightness weighting coefficient can be increased to enhance the detection capability of morphological defects such as scratches and indentations. For materials with high requirements for color consistency, such as painted plastics and coated parts, the color weighting coefficient can be increased to more accurately identify anomalies such as color difference, contamination, or local fading. The sum of the brightness weighting coefficient and the color weighting coefficient is one; when the brightness weighting coefficient increases, the color weighting coefficient decreases accordingly, and vice versa.
[0091] After calculating the optical response value of each pixel, the average optical response value (i.e., the average value of the optical response values of other pixels adjacent to the pixel) can be obtained within the neighborhood of that pixel, and the difference between the pixel and the neighborhood average value can be calculated. If the difference exceeds a preset response threshold, it indicates that the optical characteristics of the pixel are significantly different from those of the surrounding area, and the pixel is marked as an anomaly.
[0092] By using the above methods, the sensitivity to defects can be flexibly adjusted under different materials and lighting conditions, which can effectively detect subtle reflection anomalies and avoid misjudgments caused by process differences in color or brightness itself.
[0093] Optionally, in the step of performing region segmentation processing on the detection image based on anomaly points to obtain anomaly regions and the defect area of the anomaly regions, it is also possible to perform clustering processing on the anomaly points based on the spatial positional relationship between the anomaly points to obtain at least one anomaly region; count the number of anomaly points in each anomaly region, and calculate the defect area of the anomaly region based on the number of anomaly points and the preset mapping relationship between the pixels of the detection image and the physical size.
[0094] In this embodiment of the invention, the clustering can be based on the pixel distance between outliers, local point density, or a combination of both. A proximity distance threshold and a minimum number of points threshold can be preset to limit the determination conditions of "the same cluster", thereby avoiding mistaking scattered noise points as valid defects.
[0095] Initially, each outlier can be treated as a cluster. When the boundaries of two clusters are close to each other and meet the merging criteria (i.e., the basis for the clustering described above), they are merged into a larger outlier region. Conversely, if two regions are connected by only a few points and do not meet the connectivity stability requirement, they are kept separate to prevent over-aggregation. To adapt to curved shells or scenarios with parallax, the coordinates of outliers can be mapped to a unified reference coordinate system or projected to unfolded coordinates consistent with the shell surface before clustering, to ensure that positional deviations caused by different viewing angles do not affect the accuracy of clustering.
[0096] After clustering to identify at least one anomalous region, the number of anomalous points contained in each region is counted, and the area is calculated using a preset mapping relationship between pixels and physical dimensions. When there are slight position-dependent changes in magnification within the field of view, a local scaling factor can be applied according to the location of the region for correction to improve measurement accuracy. For tiny clusters with fewer anomalous points than the minimum effective size, they can be marked as negligible micro-defects or isolated noise and excluded from subsequent judgment to improve the stability of the overall judgment.
[0097] For example, in an inspection image of an anodized aluminum alloy shell, several densely distributed anomalous point bands and scattered isolated points are first identified. Through distance and density-based clustering, a thin anomalous point band in the upper right corner is merged into a single anomalous region, exhibiting typical linear scratches; a cluster of nearly circular dense points in the middle is merged into a second anomalous region, exhibiting small pits or spray spots; and scattered individual anomalous points are automatically removed because they do not meet the minimum point count threshold.
[0098] Subsequently, the number of abnormal points in each abnormal area is counted, and the defect area of the two areas is calculated by combining the pixel and physical size correspondence obtained from camera calibration. If the inspection standard of the product has a stricter threshold for the visible area, the spatial location of the area will be marked while recording the area, providing input for subsequent depth estimation and pass / fail determination.
[0099] By using a region division method centered on spatial clustering, we can obtain region results that are highly consistent with the actual defect morphology while maintaining high efficiency. Furthermore, the logic is clear, the parameters are configurable, and it is easy to migrate and maintain the region under different material and process conditions.
[0100] Optionally, in the step of extracting refractive features in the abnormal region and determining the defect depth of the abnormal region based on the refractive features, the brightness information distribution of the abnormal region can also be statistically obtained based on the brightness information of each pixel in the abnormal region; the refractive features of the abnormal region can be determined based on the brightness information distribution; the refractive features can be input into a preset mapping table to match and obtain the defect depth of the abnormal region. The preset mapping table includes different refractive features and the depth values corresponding to different refractive features.
[0101] In this embodiment of the invention, the brightness information of each pixel in the abnormal area can first be extracted, and the brightness information can be statistically processed to obtain the brightness information distribution. Since defects on the shell surface cause changes in the reflection angle and energy distribution of incident light, defects of different depths or shapes will form brightness distribution patterns with distinct characteristics. For example, when there is a micro-dimple on the surface, the incident angle of light at the center of the depression is larger, and the reflected light deviates from the camera's optical axis, making the central brightness significantly lower than the surrounding area, forming a "dark center, bright edge" brightness distribution; if it is a protrusion or scratch, it will manifest as a localized high brightness or a strip-shaped high brightness area. The spatial variation characteristics of the brightness distribution can directly reflect the degree of offset in the refraction and reflection directions of the surface.
[0102] Based on the statistical results of brightness distribution, characteristic quantities describing the laws of light reflection are extracted, namely refractive features. Refractive features can include parameters such as the gradient amplitude of brightness distribution, the range of brightness difference, and the directionality or symmetry of brightness changes, used to characterize the optical response pattern of anomalous regions. By analyzing the changing trends of refractive features, the degree of light deflection within anomalous regions can be determined, and the relationship between the degree of deflection and surface micro-deformations (such as depth or height) is repeatable under the same material and lighting conditions.
[0103] To convert refractive features into quantifiable depth values, a correspondence between refractive features and defect depths is pre-established during the calibration phase. This correspondence is obtained through multiple sets of experimental measurements on standard samples with known depths. Specifically, brightness distribution data are collected from pit and scratch samples at different known depths, corresponding refractive feature parameters are extracted, and these parameters are paired with the actually measured depth values to form a mapping table. The mapping table records the defect depth values corresponding to different refractive features, covering a typical range of surface morphology variations.
[0104] During the detection process, the refractive characteristics of the current abnormal area are input into a preset mapping table for matching. The closest feature combination is found, or the corresponding defect depth is calculated through interpolation. For example, when the brightness distribution of the abnormal area is detected as a distinct ring pattern with a dark center and bright edges, the feature is identified as a concave refractive feature, and its depth is determined to be approximately several micrometers according to the mapping table. When the brightness distribution shows a bright band change along a single direction, it is judged to be a scratch-type defect, and the corresponding depth value is shallower.
[0105] The above method enables the approximate calculation of defect depth solely based on the variation in light reflection in a two-dimensional image, without requiring 3D reconstruction or laser scanning. This approach allows for rapid assessment of surface defect depth in high-speed inspection scenarios, providing a reliable basis for subsequent quality grade determination.
[0106] Optionally, the inspection standards include key surface inspection standards and non-key surface inspection standards. The key surface inspection standards include a first defect area threshold and a first defect depth threshold, and the non-key surface inspection standards include a second defect area threshold and a second defect depth threshold. The first defect area threshold is less than the second defect area threshold, and the first defect depth threshold is less than the second defect depth threshold. In the step of determining the inspection result of the shell to be inspected based on the defect area, defect depth, and inspection standards, it can also be determined whether the inspection surface to which the abnormal area belongs is a key surface. If it is a key surface, the first defect area threshold is determined as the target defect area threshold, and the first defect depth threshold is determined as the target defect depth threshold. If it is a non-key surface, the second defect area threshold is determined as the target defect area threshold, and the second defect depth threshold is determined as the target defect depth threshold. When the defect area is not less than the target defect area threshold and / or the defect depth is not less than the target defect depth threshold, the inspection result of the shell to be inspected is determined to be a defective product. When the defect area is less than the target defect area threshold and the defect depth is less than the target defect depth threshold, the inspection result of the shell to be inspected is determined to be a qualified product.
[0107] In this embodiment of the invention, the above-mentioned testing standards can not only set a uniform threshold for the entire casing, but also formulate separate testing standards for key surfaces and non-key surfaces based on the visual importance and usage scenarios of different testing surfaces of the casing. Key surfaces are usually the appearance areas that users are most likely to observe or directly touch during product use, such as the top cover of a laptop, the front of a mobile phone casing, and the front view of a monitor bezel, etc., and their surface quality requirements are high; non-key surfaces can be structural surfaces or bottom mounting surfaces, which have a relatively small impact on appearance and are allowed to have minor defects.
[0108] During the inspection process, the inspection surface where the current abnormal area is located is first identified based on the process design or appearance template, and it is determined whether the inspection surface belongs to the key surface. When it is determined to be a key surface, a first defect area threshold is selected as the target defect area threshold and a first defect depth threshold is selected as the target defect depth threshold. This threshold combination is relatively strict and is used to ensure the surface finish and visual consistency of the key appearance surface. When the inspection surface is identified as a non-key surface, a second defect area threshold is selected as the target defect area threshold and a second defect depth threshold is selected as the target defect depth threshold, allowing a certain degree of machining marks or minor dents to balance inspection accuracy and manufacturing cost.
[0109] For example, in the inspection of laptop casings, the outer surface of the top cover can be defined as a critical surface, with a first defect area threshold of 0.2 square millimeters and a first defect depth threshold of 3 micrometers. The inner side of the bottom shell or the assembly surface can be defined as a non-critical surface, with a second defect area threshold of 0.8 square millimeters and a second defect depth threshold of 10 micrometers. Thus, when the detection algorithm calculates an abnormal area with an area of 0.3 square millimeters and a depth of 5 micrometers, if this area belongs to a critical surface, it is judged as a defective product; however, if it is located on a non-critical surface, it can still be judged as a qualified product.
[0110] By employing the aforementioned differentiated threshold mechanism, the appearance quality of critical visual areas can be guaranteed while avoiding excessive screening of non-critical areas, thereby improving the overall rationality of inspection and the production line pass rate. This method can also flexibly adjust the threshold grading according to the material, coating reflectivity, or customer standards of different products, achieving adaptive inspection configuration across product categories and processes.
[0111] Optionally, after determining the inspection result of the shell to be inspected based on the defect area, defect depth, and inspection standards, an alarm signal can be output when the inspection result is a defective product, and a control signal can be output to a preset marking device so that the marking device marks the shell to be inspected as a defective product; when the inspection result is a qualified product, the inspection result is stored in a preset inspection database.
[0112] In this embodiment of the invention, when the detection result of the shell to be inspected is determined to be defective, the control module immediately generates an alarm signal and outputs it to the audible and visual alarm device or the production line control system to remind the operator or the host computer system that a non-conforming product has been detected. Simultaneously, a control signal is sent to a preset marking device, causing the device to physically mark or mark the corresponding defective shell with a position signal. For example, in a production line inspection scenario, the marking device can take the form of an inkjet printer, a color dot printhead, a robotic arm marker, or an electromagnetic push rod mechanism to spray, mark, or sort defective shells, ensuring that defective products do not flow into subsequent assembly or shipping stages.
[0113] If the test result indicates a qualified product, no alarm is triggered. Instead, the test result, along with information such as the corresponding shell number, test time, and defect characteristic values, is stored in a pre-set test database. This database can be located on a local server or in the cloud and is used for subsequent quality traceability, process optimization, and statistical analysis. By accumulating historical test data, threshold settings or refractive mapping parameters can be dynamically optimized in subsequent batch tests, achieving adaptive adjustment of test accuracy.
[0114] For example, in an automated production line for detecting laptop computer casings, if the scratched area of a certain casing exceeds the standard threshold, after determining it as defective, a red indicator light will flash immediately, and a signal will be output to the inkjet printing device to spray small color dots on the surface of the casing as a defect mark. At the same time, the casing number and detection data will be recorded in the database. For casings determined to be qualified, only the "passed" status and detection parameters will be registered in the database. Through the automated processing mechanism, a closed-loop control of determination, alarm, marking, and data recording is achieved, significantly improving the detection efficiency and the quality control level of the production line.
[0115] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not imply the order of execution. The order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
[0116] In one embodiment, a casing detection device is provided, which corresponds to the casing detection method in the above embodiment one by one. As Figure 2 shown, the casing detection device includes an acquisition module 201, a detection module 202, a division module 203, an extraction module 204, and a determination module 205. The detailed description of each functional module is as follows:
[0117] The acquisition module 201 is used to acquire a detection image of the casing to be detected, and a detection standard corresponds to the casing to be detected;
[0118] The detection module 202 is used to detect abnormal points on the surface of the casing to be detected based on the detection image;
[0119] The division module 203 is used to perform area division processing in the detection image based on the abnormal points to obtain an abnormal area and the defect area of the abnormal area;
[0120] The extraction module 204 is used to extract a refractive feature in the abnormal area and determine the defect depth of the abnormal area based on the refractive feature;
[0121] The determination module 205 is used to determine the detection result of the casing to be detected based on the defect area, the defect depth, and the detection standard.
[0122] Optionally, the acquisition module 201 is further used for:
[0123] Under a preset lighting condition, collect multiple initial detection images of the casing to be detected, and the shooting angles of each initial detection image are different;
[0124] Perform coordinate normalization processing on the multiple initial detection images to obtain multiple normalized initial detection images;
[0125] The detection image is obtained by fusing multiple normalized initial detection images.
[0126] Optionally, the detection module 202 is further configured to:
[0127] The color and brightness information of each pixel are extracted from the detected image;
[0128] Based on the color information and the brightness information, the optical response value of each pixel is obtained by combining them according to a preset weight.
[0129] Calculate the difference between the optical response value of each pixel and the average optical response value of its neighborhood;
[0130] The abnormal points are identified by comparing the difference with a preset response threshold.
[0131] Optionally, the partitioning module 203 is further configured to:
[0132] Based on the spatial relationship between the anomalies, the anomalies are clustered to obtain at least one anomaly region.
[0133] The number of abnormal points in each abnormal region is counted, and the defect area of the abnormal region is calculated based on the number of abnormal points and the preset mapping relationship between the pixels of the detected image and the physical size.
[0134] Optionally, the extraction module 204 is further configured to:
[0135] Based on the brightness information of each pixel in the abnormal region, the brightness information distribution of the abnormal region is statistically obtained;
[0136] Based on the brightness information distribution, the refractive characteristics of the abnormal region are determined;
[0137] The refractive features are input into a preset mapping table to match and obtain the defect depth of the abnormal region. The preset mapping table includes different refractive features and the depth values corresponding to different refractive features.
[0138] Optionally, the detection criteria include a key area detection criterion and a non-key area detection criterion. The key area detection criterion includes a first defect area threshold and a first defect depth threshold. The non-key area detection criterion includes a second defect area threshold and a second defect depth threshold. The first defect area threshold is less than the second defect area threshold, and the first defect depth threshold is less than the second defect depth threshold. The determining module 205 is further configured to:
[0139] Determine whether the detection surface to which the abnormal region belongs is a key surface;
[0140] If it is a critical surface, then the first defect area threshold is determined as the target defect area threshold, and the first defect depth threshold is determined as the target defect depth threshold;
[0141] If it is a non-critical surface, then the second defect area threshold is determined as the target defect area threshold, and the second defect depth threshold is determined as the target defect depth threshold;
[0142] When the defect area is not less than the target defect area threshold and / or the defect depth is not less than the target defect depth threshold, the test result of the shell to be tested is determined to be a defective product.
[0143] When the defect area is less than the target defect area threshold and the defect depth is less than the target defect depth threshold, the test result of the shell to be tested is determined to be a qualified product.
[0144] Optionally, the device further includes:
[0145] The output module is used to output an alarm signal when the detection result is a defective product, and to output a control signal to a preset marking device so that the marking device marks the shell to be tested as a defective product;
[0146] The storage module is used to store the test result in a preset test database when the test result is a qualified product.
[0147] Specific limitations regarding the casing detection device can be found in the limitations of the casing detection method described above, and will not be repeated here. Each module in the aforementioned casing detection device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in hardware or independently of the processor in a computer device, or stored in software in the memory of a computer device, so that the processor can call and execute the operations corresponding to each module.
[0148] In one embodiment, a computer device is provided, which may be a terminal device, and its internal structure diagram may be as follows: Figure 3 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes a readable storage medium storing computer-readable instructions. The network interface communicates with an external terminal via a network connection. When executed by the processor, the computer-readable instructions implement a casing detection method. The readable storage medium provided in this embodiment includes both non-volatile and volatile readable storage media.
[0149] In this application embodiment, a computer device is provided, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor. When the processor executes the computer-readable instructions, it implements the steps of the shell detection method described above.
[0150] In one embodiment of the application, a readable storage medium is provided, which stores computer-readable instructions. When the computer-readable instructions are executed by a processor, they implement the steps of the shell detection method described above.
[0151] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing related hardware with computer-readable instructions. These computer-readable instructions can be stored in a non-volatile readable storage medium or a volatile readable storage medium. When executed, these computer-readable instructions can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0152] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0153] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A shell detection method, characterized in that, The method includes: Acquire a detection image of the shell to be tested, wherein the shell to be tested corresponds to a detection standard; Based on the detected image, abnormal points on the surface of the shell to be detected are detected; Based on the anomalies, the detection image is divided into regions to obtain the anomalies and the defect area of the anomalies. Refractive features are extracted from the abnormal region, and the defect depth of the abnormal region is determined based on the refractive features. Based on the defect area, the defect depth, and the detection standard, the detection result of the shell to be tested is determined; The step of detecting abnormal points on the surface of the shell to be detected based on the detected image includes: The color and brightness information of each pixel are extracted from the detected image; Based on the color information and the brightness information, the optical response value of each pixel is obtained by combining them according to a preset weight. Calculate the difference between the optical response value of each pixel and the average optical response value of its neighborhood; The abnormal points are identified among all pixels by comparing the difference with a preset response threshold. The step of obtaining the optical response value of each pixel based on the color information and the brightness information according to a preset weight includes: The optical response value is calculated using the formula R=αL+βΔE, where α is the luminance weighting coefficient, β is the color weighting coefficient, L is the luminance value, and ΔE is the color difference between pixels. The ratio between the brightness weighting coefficient and the color weighting coefficient is set according to the material type of the shell to be tested; For materials with strong reflectivity such as brushed metal and anodized metal, the brightness weighting coefficient is increased to enhance the detection capability of scratches and indentations. For painted plastics and coated parts with high requirements for color consistency, the color weight coefficient is increased to more accurately identify color differences, contamination or local fading abnormalities. The sum of the luminance weighting coefficient and the color weighting coefficient is one. When the luminance weighting coefficient increases, the color weighting coefficient will decrease accordingly, and vice versa.
2. The shell detection method as described in claim 1, characterized in that, The acquisition of the detection image of the shell to be detected includes: Under preset lighting conditions, multiple initial detection images of the shell to be tested are acquired, and each initial detection image is captured from a different angle. Based on multiple initial detection images, coordinate normalization processing is performed to obtain multiple normalized initial detection images; The detection image is obtained by fusing multiple normalized initial detection images.
3. The shell detection method as described in claim 1, characterized in that, The step of performing region segmentation processing on the detected image based on the anomaly points to obtain the anomaly region and the defect area of the anomaly region includes: Based on the spatial relationship between the anomalies, the anomalies are clustered to obtain at least one anomaly region. The number of abnormal points in each abnormal region is counted, and the defect area of the abnormal region is calculated based on the number of abnormal points and the preset mapping relationship between the pixels of the detected image and the physical size.
4. The shell detection method as described in claim 1, characterized in that, The step of extracting refractive features from the abnormal region and determining the defect depth of the abnormal region based on the refractive features includes: Based on the brightness information of each pixel in the abnormal region, the brightness information distribution of the abnormal region is statistically obtained; Based on the brightness information distribution, the refractive characteristics of the abnormal region are determined; The refractive features are input into a preset mapping table to match and obtain the defect depth of the abnormal region. The preset mapping table includes different refractive features and the depth values corresponding to different refractive features.
5. The shell detection method as described in claim 1, characterized in that, The detection standards include key surface detection standards and non-key surface detection standards. The key surface detection standards include a first defect area threshold and a first defect depth threshold. The non-key surface detection standards include a second defect area threshold and a second defect depth threshold. The first defect area threshold is less than the second defect area threshold, and the first defect depth threshold is less than the second defect depth threshold. Determining the detection result of the shell to be inspected based on the defect area, the defect depth, and the detection standards includes: Determine whether the detection surface to which the abnormal region belongs is a key surface; If it is a critical surface, then the first defect area threshold is determined as the target defect area threshold, and the first defect depth threshold is determined as the target defect depth threshold; If it is a non-critical surface, then the second defect area threshold is determined as the target defect area threshold, and the second defect depth threshold is determined as the target defect depth threshold; When the defect area is not less than the target defect area threshold and / or the defect depth is not less than the target defect depth threshold, the test result of the shell to be tested is determined to be a defective product. When the defect area is less than the target defect area threshold and the defect depth is less than the target defect depth threshold, the test result of the shell to be tested is determined to be a qualified product.
6. The shell detection method as described in claim 5, characterized in that, After determining the detection result of the shell to be inspected based on the defect area, the defect depth, and the detection standard, the method further includes: When the test result is a defective product, an alarm signal is output and a control signal is output to a preset marking device so that the marking device marks the shell to be tested as a defective product. When the test result is a qualified product, the test result is stored in a preset test database.
7. A casing detection device, characterized in that, The device includes: The acquisition module is used to acquire the detection image of the shell to be detected, which corresponds to a detection standard; The detection module is used to detect abnormal points on the surface of the shell to be detected based on the detection image; The segmentation module is used to perform region segmentation processing on the detection image based on the abnormal points to obtain the abnormal region and the defect area of the abnormal region. An extraction module is used to extract refractive features from the abnormal region and determine the defect depth of the abnormal region based on the refractive features. The determination module is used to determine the detection result of the shell to be tested based on the defect area, the defect depth, and the detection standard. The detection module is also used for: The color and brightness information of each pixel are extracted from the detected image; Based on the color information and the brightness information, the optical response value of each pixel is obtained by combining them according to a preset weight. Calculate the difference between the optical response value of each pixel and the average optical response value of its neighborhood; The abnormal points are identified among all pixels by comparing the difference with a preset response threshold. The step of obtaining the optical response value of each pixel based on the color information and the brightness information according to a preset weight includes: The optical response value is calculated using the formula R=αL+βΔE, where α is the luminance weighting coefficient, β is the color weighting coefficient, L is the luminance value, and ΔE is the color difference between pixels. The ratio between the brightness weighting coefficient and the color weighting coefficient is set according to the material type of the shell to be tested; For materials with strong reflectivity such as brushed metal and anodized metal, the brightness weighting coefficient is increased to enhance the detection capability of scratches and indentations. For painted plastics and coated parts with high requirements for color consistency, the color weight coefficient is increased to more accurately identify color differences, contamination or local fading abnormalities. The sum of the luminance weighting coefficient and the color weighting coefficient is one. When the luminance weighting coefficient increases, the color weighting coefficient will decrease accordingly, and vice versa.
8. A computer device comprising a memory, a processor, and computer-readable instructions stored in the memory and running on the processor, characterized in that, When the processor executes the computer-readable instructions, it implements the casing detection method as described in any one of claims 1 to 6.
9. A readable storage medium having computer-readable instructions stored thereon, characterized in that, When the computer-readable instructions are executed by a processor, they implement the housing detection method as described in any one of claims 1 to 6.