Magnetic stripe appearance defect automatic detection method and system based on image recognition
By combining the image acquisition technology of structured light projection and line scanning cameras, combined with geometric distortion and brightness gradient analysis, defect repair is used to use a generative reduction model to solve the problem of low accuracy in the appearance of magnetic stripes, and high-precision defect detection is achieved.
Patent Information
- Application Number
- CN202510704084.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-29
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2045-05-29
AI Technical Summary
In the prior art, the accuracy of magnetic strip appearance defect detection is low, especially in complex background interference and diverse defect forms, the accuracy is insufficient, the robustness is poor, and it is difficult to meet the application scenarios of high accuracy and high stability requirements.
The structured light projector and industrial camera are used to collect geometric interference images, and the line scanning camera is used to collect line scanning images. The defects are identified through geometric distortion and spatial brightness gradient calculations, and defect repair is used to use defect mutual verification and generative reduction models to generate the third defect detection result.
Improve the accuracy and reliability of magnetic stripe appearance defect detection, ensuring efficient inspection in complex environments.
Smart Images

Figure CN120471904A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image recognition, and in particular to a method and system for automatically detecting appearance defects of magnetic stripes based on image recognition. Background Art
[0002] During the manufacturing process of magnetic stripe products, their appearance quality directly impacts product performance and reliability, especially in applications requiring high precision and stability, such as financial cards, access control cards, and industrial sensing equipment. However, magnetic stripes are susceptible to interference from factors such as mechanical vibration, uneven coating, material defects, and environmental pollution during the production process, resulting in various surface defects such as scratches, bubbles, shedding, and discoloration. Traditional manual visual inspection methods are inefficient and highly subjective, making them difficult to adapt to the demands of high-speed continuous production. Automated inspection systems based on single-image acquisition often exhibit problems such as insufficient accuracy and poor robustness when faced with complex background interference and diverse defect morphologies. Summary of the Invention
[0003] The present application provides a method and system for automatically detecting appearance defects of magnetic stripes based on image recognition, which solves the technical problem of low accuracy in detecting appearance defects of magnetic stripes in the prior art.
[0004] In a first aspect of the present application, a method for automatically detecting appearance defects of a magnetic stripe based on image recognition is provided, the method comprising: Activate the first image acquisition device on the magnetic stripe production line, perform geometric interference image acquisition on the target magnetic stripe moving on the production line, and generate first image data; activate the second image acquisition device on the magnetic stripe production line, perform line scanning image acquisition on the target magnetic stripe moving on the production line, and generate second image data; perform image recognition based on geometric distortion on the first image data, and generate a first defect detection result; perform image recognition based on spatial brightness gradient calculation on multiple consecutive frames of images in the second image data, and generate a second defect detection result; analyze the first defect detection result and the second defect detection result for defect mutual verification, and call the pre-trained generative restoration model based on the defect mutual verification result to perform residual detection under defect repair, and generate a third defect detection result.
[0005] A second aspect of the present application provides an automatic detection system for magnetic stripe appearance defects based on image recognition, the system comprising: The first image acquisition module: activates the first image acquisition device on the magnetic stripe production line, performs geometric interference image acquisition on the target magnetic stripe moving on the production line, and generates first image data; the second image acquisition module: activates the second image acquisition device on the magnetic stripe production line, performs line scanning image acquisition on the target magnetic stripe moving on the production line, and generates second image data; the first image recognition module: performs image recognition based on geometric distortion on the first image data, and generates a first defect detection result; the second image recognition module: performs image recognition based on spatial brightness gradient calculation on multiple consecutive frames of images in the second image data, and generates a second defect detection result; the detection module: analyzes the first defect detection result and the second defect detection result for defect mutual verification, and based on the defect mutual verification result, calls the pre-trained generative restoration model to perform residual detection under defect repair, and generates a third defect detection result.
[0006] One or more technical solutions provided in this application have at least the following technical effects or advantages: First, the first image acquisition device on the magnetic stripe production line is activated to perform geometric interference image acquisition on the target magnetic stripe moving on the production line to generate first image data; the second image acquisition device on the magnetic stripe production line is activated to perform line scanning image acquisition on the target magnetic stripe moving on the production line to generate second image data. Next, image recognition based on geometric distortion is performed on the first image data to generate a first defect detection result; image recognition based on spatial brightness gradient calculation is performed on multiple consecutive frames of images in the second image data to generate a second defect detection result. Finally, the first defect detection result and the second defect detection result are analyzed for defect mutual verification. Based on the defect mutual verification result, a pre-trained generative restoration model is called to perform residual detection under defect repair to generate a third defect detection result. This solves the technical problem of low accuracy in magnetic stripe appearance defect detection in the existing technology, and achieves the technical effect of improving the accuracy and reliability of magnetic stripe appearance defect detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0007] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0008] Figure 1 A schematic flow chart of a method for automatically detecting appearance defects of magnetic stripes based on image recognition according to an embodiment of the present application; Figure 2 Schematic diagram of the structure of the automatic detection system for magnetic stripe appearance defects based on image recognition provided in an embodiment of the present application.
[0009] Explanation of reference numerals: first image acquisition module 11 , second image acquisition module 12 , first image recognition module 13 , second image recognition module 14 , detection module 15 . DETAILED DESCRIPTION
[0010] The present application solves the technical problem of low accuracy in magnetic stripe appearance defect detection in the prior art by providing a method and system for automatic detection of magnetic stripe appearance defects based on image recognition.
[0011] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only some of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0012] It should be noted that the terms "including" and "having" are intended to cover non-exclusive inclusions. For example, a process, method, system, product or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or modules that are not clearly listed or are inherent to these processes, methods, products or devices.
[0013] Example 1, as Figure 1 As shown, the present application provides a method for automatically detecting appearance defects of magnetic stripes based on image recognition, wherein the method includes: The first image acquisition device on the magnetic stripe production line is activated to perform geometric interference image acquisition on the target magnetic stripe moving on the production line to generate first image data.
[0014] Furthermore, the first image acquisition device is a structured light assisted vision device, including a structured light projector and an industrial camera.
[0015] In an embodiment of the present application, a first image acquisition device installed on a magnetic stripe production line performs geometric interference image acquisition on a target magnetic stripe moving on the production line to generate first image data. The first image acquisition device includes a structured light projector and an industrial camera. The structured light projector is used to project a regular stripe light pattern onto the surface of the moving target magnetic stripe. The stripe light pattern is a periodic linear structured light, which is used to form a stable geometric interference pattern on the surface of the magnetic stripe. The industrial camera captures images of the magnetic stripe surface at a fixed angle. As the target magnetic stripe passes through the structured light projection area, it captures an image of its surface after being disturbed by the structured light in real time.
[0016] The second image acquisition device on the magnetic stripe production line is activated to perform line scanning image acquisition on the target magnetic stripe moving on the production line to generate second image data.
[0017] Furthermore, the second image acquisition device is a line scan camera, and the frame rate of the line scan camera matches the moving speed of the target magnetic stripe.
[0018] In an embodiment of the present application, a second image acquisition device installed on a magnetic stripe production line performs line scan image acquisition on a target magnetic stripe moving on the production line to generate second image data, wherein the second image data comprises a continuous multi-frame image. The second image acquisition device is a line scan camera. Based on the line scan imaging principle, the line scan camera acquires image data of the magnetic stripe surface line by line and splices the data line by line to generate a complete image as the magnetic stripe continuously moves along the production direction, thereby achieving continuous high-resolution image acquisition of the entire magnetic stripe surface.
[0019] Furthermore, the first image acquisition device and the second image acquisition device have a distance constraint; the distance constraint is configured by the influence range of the structured light projector in the first image acquisition device, the frame rate of the second image acquisition device, and the speed of the target magnetic strip on the production line.
[0020] A fixed distance constraint is set between the first image acquisition device and the second image acquisition device on the magnetic stripe production line to ensure the correspondence between the image data in time and space. The distance constraint is determined by multiple factors, including the effective influence range of the structured light projector in the first image acquisition device, the frame rate setting of the second image acquisition device, and the running speed of the target magnetic stripe on the production line. Specifically, the structured light projector needs to complete the stable projection of the stripe pattern within its projection uniform area, and the first image acquisition device needs to be in this area to accurately capture the distortion information; at the same time, to ensure that the line scan image does not appear stretched or compressed, the frame rate of the second image acquisition device must strictly match the moving speed of the magnetic stripe. Therefore, the device must maintain a certain physical distance from the first image acquisition device during installation.
[0021] The magnetic stripe runs at a constant or quasi-constant speed. To ensure that the first image data and the second image data respectively capture image information of the same batch and the same physical area, it is necessary to calculate a reasonable device spacing D based on the production line speed V, structured light imaging and line scanning delay compensation time Δt, satisfying the formula D=V⋅Δt.
[0022] Image recognition based on geometric distortion is performed on the first image data to generate a first defect detection result.
[0023] Based on a comparison between the standard structured light pattern model projected by the structured light projector and the first image data, an image processing algorithm is used to analyze the deformation of the structured light stripes in the image, including but not limited to gradient mutations of the stripes (detecting areas with abnormal gradient changes in the direction of the light stripes, which can reflect surface undulations or protrusions), stripe breakage (detecting interrupted or missing parts of the light stripes, which usually indicate scratches, paint peeling, or obstruction by foreign objects), and stripe distortion or offset (determining the degree to which the stripes deviate from the reference position, which is used to identify defects such as warping, dents, or surface warping). Based on the distribution, range, and intensity of the distortion features, an initial determination of the defect type (such as scratches, deformation, indentation, contamination, etc.) and its spatial positioning are performed, and the identified defect information is formatted and processed, ultimately outputting the first defect detection result, including but not limited to the position coordinates, size parameters, distortion feature values, and preliminary classification labels of the defect area.
[0024] Furthermore, performing geometric distortion-based image recognition on the first image data to generate a first defect detection result includes: Acquire a preset structured light pattern of the first image acquisition device; based on the preset structured light pattern, identify stripe distortion of the first image data, including gradient mutation, stripe breakage, and distorted areas, to determine distortion feature information; analyze the surface defect type based on the distortion feature, and map and associate it with the distortion position to generate the first defect detection result.
[0025] First, a preset structured light pattern projected by a structured light projector in a first image acquisition device is obtained. This preset structured light pattern is a regular and uniform periodic stripe light pattern formed on the surface of an ideal defect-free magnetic stripe, which serves as a benchmark for subsequent distortion identification. In the first image data acquired, the stripe pattern will produce obvious geometric distortion due to various defects on the surface of the magnetic stripe, which is specifically manifested as abnormal morphologies such as gradient mutations, fractures, and distortions of the stripes. By comparing the acquired image with the preset pattern, an edge gradient detection operator such as the Sobel operator is used to extract the stripe gradient changes and identify gradient mutation areas, which usually correspond to scratches, peelings, or other defects with clear boundaries. Connected domain analysis and void filling techniques are used to detect broken segments in the stripes. The fracture phenomenon reflects surface particle contamination or local material defects. At the same time, a curve fitting method is used to analyze the stripe direction to detect stripe distortion caused by surface warping, depressions, or stress deformation, and then determine the distortion area. The distortion features extracted by the above-mentioned image processing method include information such as the spatial position, size, shape and distortion intensity of the defect area. Based on these distortion features, the preset defect type discrimination rules are further combined to analyze the specific type of defects, such as scratches, warping, indentations or contaminant attachment, and the defect type is mapped and associated with its corresponding distortion position to form a structured first defect detection result.
[0026] Image recognition based on spatial brightness gradient calculation is performed on a plurality of consecutive frames of images in the second image data to generate a second defect detection result.
[0027] For the continuous multiple frames in the second image data, the magnetic stripe area in each frame is first aligned at the pixel level to eliminate the displacement error caused by the movement of the magnetic stripe or the jitter of the acquisition device, and to ensure the continuity of the pixels at the same spatial position in the time series. Subsequently, for the aligned pixel sequence, the brightness value of each pixel that changes with time is extracted to form a brightness change sequence. Based on this brightness change sequence, the spatial brightness gradient of each pixel is calculated, that is, the rate of change of the brightness value in the spatial position is analyzed to further capture the details of the brightness mutation and texture change. By analyzing the spatial brightness gradient map of all pixels, a set of pixels with consistent gradient changes is identified. These pixels satisfy the adjacency relationship in space and form a continuous gradient consistent region. Based on the information of these gradient consistent regions, combined with the spatial connected domain analysis, the second defect detection result is generated. The result contains information such as the spatial position, size and morphological characteristics of the defect, providing an important basis for subsequent defect mutual verification and comprehensive judgment.
[0028] Furthermore, performing image recognition based on spatial brightness gradient calculation on a plurality of consecutive frames of images in the second image data to generate a second defect detection result includes: After pixel alignment processing is performed on the magnetic stripe area in the continuous multi-frame images, a sequence of brightness values of each pixel changing over time is calculated and extracted to generate a brightness change sequence of each pixel; brightness change gradient calculation is performed on the brightness change sequence of each pixel to generate a gradient change map of each pixel; based on the gradient change map of each pixel, consistent pixels are respectively extracted and connected according to an adjacency relationship to generate the second defect detection result.
[0029] First, pixel alignment is performed on the magnetic stripe region across multiple consecutive image frames. This process uses an image registration algorithm to eliminate image displacement caused by magnetic stripe movement or camera shake, ensuring accurate temporal correspondence between pixels at the same spatial location. After alignment, the brightness values of each pixel in consecutive frames are extracted to form a temporal brightness variation sequence for that pixel. Based on this brightness variation sequence, a brightness gradient calculation is performed. By calculating the rate of change of the brightness values in the spatial dimension, a gradient variation map for each pixel is generated. This gradient variation map reflects the local brightness variations on the magnetic stripe surface and is sensitive to brightness unevenness or texture changes caused by defects. Subsequently, based on the gradient variation map, a set of pixels with similar and continuous gradient variations is extracted according to preset gradient consistency constraints. These pixels are then connected into continuous regions based on spatial adjacency. Analysis of these continuous regions identifies areas of abnormal brightness variation, ultimately generating a second defect detection result that includes the defect location, size, and morphological characteristics. This result provides accurate reference data for subsequent defect cross-verification and repair.
[0030] Furthermore, based on the gradient change maps of each pixel point, consistent pixels are extracted respectively and connected according to an adjacency relationship to generate the second defect detection result, including: Construct a gradient consistency judgment constraint, including a continuous gradient deviation threshold; use the gradient consistency judgment constraint to extract consistent pixels from the gradient change map of each pixel point to generate an extracted pixel point set; connect the extracted pixel points in the set that meet the similarity of the preset adjacency relationship to generate the second defect detection result.
[0031] Specifically, by setting a threshold to limit the maximum allowable deviation of the gradient values of adjacent pixels, it is ensured that only pixels with similar gradient change amplitudes are extracted as consistent pixels. Using this gradient consistency judgment constraint, the gradient change map of each pixel is analyzed point by point to screen out a set of pixels that meet the gradient consistency conditions, that is, the extracted pixel set. Subsequently, for this pixel set, according to the preset spatial adjacency relationship rules (such as the four-neighborhood or eight-neighborhood connection rules), the pixels that meet the spatial adjacency and similar gradient changes are connected to form several continuous gradient consistent areas. Ultimately, these areas are identified as potential defect areas and integrated to form a second defect detection result, which contains information such as the spatial position, size and morphological characteristics of the defect, providing accurate and reliable data support for defect detection.
[0032] The first defect detection result and the second defect detection result are analyzed to perform defect mutual verification, and based on the defect mutual verification result, a pre-trained generative restoration model is called to perform residual detection under defect repair to generate a third defect detection result.
[0033] When performing defect mutual verification on the first defect detection result and the second defect detection result, the defect areas in the two sets of detection results are first compared and matched according to spatial position and morphological features. The consistency and mutual verification degree of the defect information are determined by calculating the overlap, distance difference and morphological similarity of the defect areas. If both sets of results detect defects in the same area and the features match well, the defect is confirmed to be a valid defect and the defect mutual verification result passes; conversely, if there are significant differences between the two sets of results or the defect information does not match, the defect mutual verification result is determined to have failed. Based on the results of the defect mutual verification, if the defect mutual verification fails, the pre-trained generative restoration model is called to perform defect repair on the target defect image area identified in the second defect detection. The generative restoration model can generate a defect-repaired version of the image by learning the texture and structural features of a large number of defect-free magnetic stripe images. Subsequently, the repaired image and the original defect image are subjected to pixel-level difference analysis to extract residual information. The defect area is relocated and fine-tuned for detection based on the spatial distribution and intensity of the residual. Finally, the defects that pass the mutual verification are combined with the defect information obtained from the residual detection to generate a third defect detection result with higher accuracy and completeness to support subsequent production quality control and judgment.
[0034] Furthermore, analyzing the first defect detection result and the second defect detection result to perform defect mutual verification, calling a pre-trained generative restoration model based on the defect mutual verification result to perform residual detection under defect repair, and generating a third defect detection result, including: The corresponding relationship of the defect areas is compared based on the first defect detection result and the second defect detection result to generate the defect mutual verification result; if the defect mutual verification result passes, the first defect detection result is output as the final defect detection result.
[0035] When analyzing the first defect detection result and the second defect detection result for defect mutual verification, the system first compares the spatial position and morphological features of the defect areas in the two sets of defect detection results. Specifically, this includes calculating the spatial overlap rate between the defect areas and evaluating the degree of positional overlap by determining the ratio of the intersection to the union of the two defect areas (i.e., the intersection-over-union ratio, IoU); at the same time, analyzing the similarity of the defect morphology, such as contour shape, size ratio, and edge features. Based on the above comparison results, a defect mutual verification result is generated to determine whether the two sets of detection results detected the same defect in the same area. If the defect mutual verification result shows that the correspondence between the two sets of detection results in the defect area meets the preset consistency threshold (for example, the IoU is greater than a certain threshold and the morphological similarity exceeds a certain ratio), the defect mutual verification is determined to have passed. At this point, the system outputs the first defect detection result as the final defect detection result to ensure the accuracy and consistency of the defect detection results.
[0036] Furthermore, after generating the defect mutual verification result, the method further includes: If the defect mutual verification result fails, extract the target image with the highest detection value from the second image data; call the generative restoration model to perform defect repair on the target image to generate a repaired image; compare the pixel-level residual information of the repaired image and the target image; relocate the defect area using the pixel-level residual information to generate the third defect detection result.
[0037] If the defect mutual verification result fails, meaning a stable consistency relationship cannot be established between the first and second defect detection results, the system initiates a residual error detection process to improve detection accuracy. First, the target image with the highest detection value is extracted from the second image data. The target image's value is evaluated using multiple image quality metrics, including image contrast (i.e., brightness difference intensity), edge sharpness (based on edge gradient change rate or Laplacian operator response), information entropy (reflecting the image's detail complexity and information content), and texture clarity (extracted using methods such as gray-level co-occurrence matrix or local binary pattern (LBP)). The system weights and scores these metrics and selects the frame with the highest score as the target image. The system then uses a pre-trained generative restoration model to perform defect repair on this target image. This model, built on a defect-free magnetic stripe image and trained using a generative adversarial network (GAN) architecture, learns the distribution characteristics of the normal texture, structure, and background of the magnetic stripe. Given a defective image as input, the model outputs a repaired image—a repaired image in which the defective area in the target image is predicted to be normal. Next, the inpainted image is compared with the original target image at the pixel level to extract pixel-level residual information. This information reflects the difference in the repair model's effect on the defect area. This pixel-level residual information is used to accurately relocate the defect area, combining the spatial distribution and intensity characteristics of the residual to redefine the specific location and scope of the defect. Finally, a third defect detection result is generated based on this relocalization result, significantly improving the accuracy and reliability of defect detection.
[0038] Furthermore, the generative restoration model is trained on defect-free magnetic stripe images based on a generative network and is used to repair defects and generate the texture and structure of defect-free magnetic stripes.
[0039] The generative restoration model is an image restoration model based on a generative neural network architecture, and its training data consists of a large number of defect-free magnetic stripe images. During the training process, the model gradually builds up the ability to generate "ideal magnetic stripe images" by learning the texture arrangement patterns, edge structure characteristics, and background continuity information of these normal magnetic stripe images. Since the training samples do not contain any defect type data, such as scratches, stains, foreign object occlusion, or local peeling, the model will not establish a generation path for defect features during the parameter convergence process. Therefore, in the model inference stage, even if the input image contains the above-mentioned defect information, the model will automatically ignore such areas and regard them as "outliers" that do not conform to its learned pattern, thereby reconstructing the image in a manner closest to the training distribution and outputting an idealized magnetic stripe image after the defects are repaired.
[0040] The core capability of generative restoration models lies in reconstructing abnormal regions using the normal image distribution, thereby indirectly revealing defective areas in the original image. Specifically, by calculating the pixel-level difference between the original image and the model output, a residual map is generated. This map focuses on areas that the model cannot restore, typically representing actual defects in the image. Areas in the residual map with significant pixel value deviations are considered high-confidence defect candidates, providing the data foundation for subsequent defect relocation and classification.
[0041] In summary, the embodiments of the present application have at least the following technical effects: First, the first image acquisition device on the magnetic stripe production line is activated to perform geometric interference image acquisition on the target magnetic stripe moving on the production line to generate first image data; the second image acquisition device on the magnetic stripe production line is activated to perform line scanning image acquisition on the target magnetic stripe moving on the production line to generate second image data. Next, image recognition based on geometric distortion is performed on the first image data to generate a first defect detection result; image recognition based on spatial brightness gradient calculation is performed on multiple consecutive frames of images in the second image data to generate a second defect detection result. Finally, the first defect detection result and the second defect detection result are analyzed for defect mutual verification. Based on the defect mutual verification result, a pre-trained generative restoration model is called to perform residual detection under defect repair to generate a third defect detection result. This solves the technical problem of low accuracy in magnetic stripe appearance defect detection in the existing technology, and achieves the technical effect of improving the accuracy and reliability of magnetic stripe appearance defect detection.
[0042] The second embodiment is based on the same inventive concept as the method for automatically detecting appearance defects of magnetic stripes based on image recognition in the above embodiment. Figure 2 As shown, the present application provides an automatic detection system for magnetic stripe appearance defects based on image recognition, wherein the system includes: The first image acquisition module 11: activates the first image acquisition device on the magnetic stripe production line, performs geometric interference image acquisition on the target magnetic stripe moving on the production line, and generates first image data; the second image acquisition module 12: activates the second image acquisition device on the magnetic stripe production line, performs line scanning image acquisition on the target magnetic stripe moving on the production line, and generates second image data; the first image recognition module 13: performs image recognition based on geometric distortion on the first image data, and generates a first defect detection result; the second image recognition module 14: performs image recognition based on spatial brightness gradient calculation on multiple consecutive frames of images in the second image data, and generates a second defect detection result; the detection module 15: analyzes the first defect detection result and the second defect detection result for defect mutual verification, and based on the defect mutual verification result, calls the pre-trained generative restoration model to perform residual detection under defect repair, and generates a third defect detection result.
[0043] Furthermore, the first image acquisition module 11 is configured to execute the following method: The first image acquisition device is a structured light assisted vision device, including a structured light projector and an industrial camera.
[0044] Furthermore, the second image acquisition module 12 is configured to execute the following method: The second image acquisition device is a line scan camera, and the frame rate of the line scan camera matches the moving speed of the target magnetic stripe.
[0045] Furthermore, the second image acquisition module 12 is configured to execute the following method: The first image acquisition device and the second image acquisition device have a distance constraint; the distance constraint is configured by the influence range of the structured light projector in the first image acquisition device, the frame rate of the second image acquisition device and the speed of the target magnetic strip on the production line.
[0046] Furthermore, the first image recognition module 13 is configured to execute the following method: Acquire a preset structured light pattern of the first image acquisition device; based on the preset structured light pattern, identify stripe distortion of the first image data, including gradient mutation, stripe breakage, and distorted areas, to determine distortion feature information; analyze the surface defect type based on the distortion feature, and map and associate it with the distortion position to generate the first defect detection result.
[0047] Furthermore, the second image recognition module 14 is configured to perform the following method: After pixel alignment processing is performed on the magnetic stripe area in the continuous multi-frame images, a sequence of brightness values of each pixel changing over time is calculated and extracted to generate a brightness change sequence of each pixel; brightness change gradient calculation is performed on the brightness change sequence of each pixel to generate a gradient change map of each pixel; based on the gradient change map of each pixel, consistent pixels are respectively extracted and connected according to an adjacency relationship to generate the second defect detection result.
[0048] Furthermore, the second image recognition module 14 is configured to perform the following method: Construct a gradient consistency judgment constraint, including a continuous gradient deviation threshold; use the gradient consistency judgment constraint to extract consistent pixels from the gradient change map of each pixel point to generate an extracted pixel point set; connect the extracted pixel points in the set that meet the similarity of the preset adjacency relationship to generate the second defect detection result.
[0049] Furthermore, the detection module 15 is configured to perform the following method: The corresponding relationship of the defect areas is compared based on the first defect detection result and the second defect detection result to generate the defect mutual verification result; if the defect mutual verification result passes, the first defect detection result is output as the final defect detection result.
[0050] Furthermore, the detection module 15 is configured to perform the following method: If the defect mutual verification result fails, extract the target image with the highest detection value from the second image data; call the generative restoration model to perform defect repair on the target image to generate a repaired image; compare the pixel-level residual information of the repaired image and the target image; relocate the defect area using the pixel-level residual information to generate the third defect detection result.
[0051] Furthermore, the detection module 15 is configured to perform the following method: The generative restoration model is based on a generative network and is trained using defect-free magnetic stripe images to repair defects and generate the texture and structure of defect-free magnetic stripes.
[0052] It should be noted that the order in which the embodiments of the present application are presented is for illustrative purposes only and does not necessarily represent the superiority or inferiority of the embodiments. Furthermore, the foregoing descriptions of specific embodiments of this specification are provided. The processes depicted in the accompanying drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0053] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
[0054] This specification and drawings are merely illustrative of the present application and are intended to cover any and all modifications, variations, combinations, or equivalents within the scope of this application. Obviously, those skilled in the art may make various modifications and variations to this application without departing from the scope of this application. Thus, this application is intended to include such modifications and variations as fall within the scope of this application and its equivalents.
Claims
1. The automatic detection method of magnetic stripe appearance defects based on image recognition is characterized by: Methods include: activating a first image acquisition device on the magnetic stripe production line to acquire a geometric interference image of a target magnetic stripe moving on the production line to generate first image data; activating a second image acquisition device on the magnetic stripe production line to perform line scanning image acquisition on a target magnetic stripe moving on the production line to generate second image data; performing geometric distortion-based image recognition on the first image data to generate a first defect detection result; performing image recognition based on spatial brightness gradient calculation on a plurality of consecutive frames of images in the second image data to generate a second defect detection result; The first defect detection result and the second defect detection result are analyzed to perform defect mutual verification, and based on the defect mutual verification result, a pre-trained generative restoration model is called to perform residual detection under defect repair to generate a third defect detection result.
2. The method for automatically detecting magnetic stripe appearance defects based on image recognition according to claim 1, characterized in that: The first image acquisition device is a structured light assisted vision device, including a structured light projector and an industrial camera; the second image acquisition device is a line scan camera, and the frame rate of the line scan camera matches the moving speed of the target magnetic strip.
3. The method for automatically detecting magnetic stripe appearance defects based on image recognition according to claim 2, characterized in that: There is a distance constraint between the first image acquisition device and the second image acquisition device; The distance constraint is configured by the influence range of the structured light projector in the first image acquisition device, the frame rate of the second image acquisition device, and the speed of the target magnetic strip on the production line.
4. The method for automatically detecting magnetic stripe appearance defects based on image recognition according to claim 1, characterized in that: Performing geometric distortion-based image recognition on the first image data to generate a first defect detection result includes: Acquire a preset structured light pattern of the first image acquisition device; Based on the preset structured light pattern, the first image data is subjected to fringe distortion recognition, including gradient mutation, fringe breakage, and distorted area, to determine distortion feature information; Surface defect type analysis is performed based on the distortion features, and mapping and associating them with the distortion positions to generate the first defect detection result.
5. The method for automatically detecting magnetic stripe appearance defects based on image recognition according to claim 1, characterized in that: Performing image recognition based on spatial brightness gradient calculation on a plurality of consecutive frames of images in the second image data to generate a second defect detection result includes: After performing pixel alignment processing on the magnetic stripe area in the continuous multi-frame image, a sequence of brightness values of each pixel changing over time is calculated and extracted to generate a brightness change sequence of each pixel; Calculating the brightness change gradient based on the brightness change sequence of each pixel point to generate a gradient change map of each pixel point; Based on the gradient change maps of each pixel point, consistent pixel points are extracted respectively and connected according to an adjacency relationship to generate the second defect detection result.
6. The method for automatically detecting appearance defects of magnetic stripes based on image recognition according to claim 5, characterized in that: Extracting consistent pixels based on the gradient change maps of each pixel point and connecting them according to an adjacency relationship to generate the second defect detection result includes: Construct gradient consistency constraints, including continuous gradient deviation thresholds; Extracting consistent pixels from the gradient change graphs of each pixel point based on the gradient consistency judgment constraint to generate an extracted pixel point set; The extracted pixel points are concentrated and connected with similarities that satisfy a preset adjacency relationship to generate the second defect detection result.
7. The method for automatically detecting magnetic stripe appearance defects based on image recognition according to claim 1, characterized in that: Analyzing the first defect detection result and the second defect detection result to perform defect mutual verification, calling a pre-trained generative restoration model based on the defect mutual verification result to perform residual detection under defect repair, and generating a third defect detection result, including: Comparing the corresponding relationship of the defect areas according to the first defect detection result and the second defect detection result to generate the defect mutual verification result; If the defect mutual verification result passes, the first defect detection result is output as the final defect detection result.
8. The method for automatically detecting magnetic stripe appearance defects based on image recognition according to claim 7, characterized in that: After generating the defect mutual verification result, the method further includes: If the defect mutual verification result fails, extracting a target image with the highest detection value from the second image data; Calling the generative restoration model to perform defect repair processing on the target image to generate a repaired image; Comparing pixel-level residual information between the repaired image and the target image; The defect area is relocated using the pixel-level residual information to generate the third defect detection result.
9. The method for automatically detecting magnetic stripe appearance defects based on image recognition according to claim 8, characterized in that: The generative restoration model is based on a generative network and is trained using defect-free magnetic stripe images to repair defects and generate the texture and structure of defect-free magnetic stripes.
10. The automatic detection system for magnetic stripe appearance defects based on image recognition is characterized by: A system for implementing the method for automatically detecting appearance defects of magnetic stripes based on image recognition according to any one of claims 1 to 9, the system comprising: The first image acquisition module activates the first image acquisition device on the magnetic stripe production line, performs geometric interference image acquisition on the target magnetic stripe moving on the production line, and generates first image data; The second image acquisition module activates the second image acquisition device on the magnetic stripe production line, performs line scanning image acquisition on the target magnetic stripe moving on the production line, and generates second image data; A first image recognition module is configured to perform geometric distortion-based image recognition on the first image data to generate a first defect detection result; A second image recognition module is configured to perform image recognition based on spatial brightness gradient calculation on a plurality of consecutive frames of images in the second image data to generate a second defect detection result; Detection module: Analyze the first defect detection result and the second defect detection result to perform defect mutual verification, call the pre-trained generative restoration model based on the defect mutual verification result to perform residual detection under defect repair, and generate a third defect detection result.
Citation Information
Patent Citations
Image processing device for defect inspection and image processing method for defect inspection
CN102630299A
Defect and three-dimensional topography detection method based on grating imaging
CN108802054A
Device and method for detecting and measuring surface defects of products
CN115201202A
Industrial defect detection method based on image restoration
CN118212196A
Food nondestructive testing model construction method based on machine vision
CN119131260A