Pin defect detection method, device, equipment and medium

By segmenting the pin images and analyzing morphological features, the angle between the central axis and the reference axis is determined, which solves the robustness problem of pin bending defect detection in the prior art and realizes efficient detection and quality assessment of pin defects.

CN121724939APending Publication Date: 2026-03-24SHENZHEN CHANGTIAN INTELLIGENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-12
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

Existing technologies struggle to accurately detect minor bending defects in pins, and their robustness is poor, especially in complex industrial settings, affecting the stability of electrical connections and signal transmission.

Method used

By segmenting images based on pin target localization, extracting morphological features, determining the angle between the central axis and the reference axis, and judging whether the angle is within a preset range, bending defects of the pins can be detected.

Benefits of technology

It enables efficient and accurate detection of pin bending defects, improving the stability of electrical connections and the reliability of signal transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121724939A_ABST
    Figure CN121724939A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of industrial detection, in particular to a pin defect detection method, device and equipment and a medium. According to the method, based on pin target positioning, image segmentation is carried out on a pin image, form extraction is carried out on a pin area, an actual included angle between a central axis and a reference axis is calculated, whether the actual included angle is in a preset angle range is detected, and if the actual included angle is detected not in the preset angle range, the pin area is determined. And if so, determining that the corresponding pin has a bending defect. The method comprises the following steps: acquiring a pin image from an original image based on pin target positioning, segmenting to obtain a pin area, extracting morphological characteristics of the pin area to determine a central axis, determining a reference axis according to the pin image, and calculating an actual included angle between the reference axis and the pin image; and finally, determining whether the pin has a bending defect or not by judging whether the included angle is within a preset range or not. And performing morphological analysis on the pin image to determine an included angle between the central axis and the reference axis so as to complete defect detection of the pin.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application relates to the technical field of industrial detection, and in particular to a pin defect detection method, device, equipment and medium. BACKGROUND

[0002] In many industrial fields, pins are key components for connecting electrical elements and transmitting signals, and the quality of the pins directly affects the stability and reliability of the entire system. During production, transportation or assembly, pins may have defects such as bending, deformation and missing, which can cause poor electrical connection, signal transmission interruption and other problems, thereby affecting the performance and service life of the product. Therefore, it is crucial to accurately and efficiently detect pin defects.

[0003] Currently, in the field of electronic component manufacturing, machine vision technology is mostly used for defect detection of component pins. For example, traditional image processing-based detection methods usually use edge detection, template matching and other algorithms for analysis. However, in a complex industrial environment, such methods are easily affected by factors such as light changes and background noise, and it is difficult to set the threshold for morphological defects (especially bending), and the robustness is poor. Or the detection method based on end-to-end deep learning, some existing technologies can directly classify and locate defects through general object detection networks. These methods can identify obvious defects such as breakage and missing, but they have limitations when dealing with geometric deformation defects such as slight pin bending.

[0004] Therefore, how to perform morphological analysis on pin images to determine the included angle between the center axis and the reference axis, and thus complete the defect detection of the pins, becomes a problem to be solved. SUMMARY

[0005] Therefore, the embodiments of the present application provide a pin defect detection method, device, equipment and medium to solve the problem of how to perform morphological analysis on pin images to determine the included angle between the center axis and the reference axis, and thus complete the defect detection of the pins.

[0006] In a first aspect, the embodiments of the present application provide a pin defect detection method, comprising: Based on pin target positioning, a pin image is collected from an original image, and image segmentation is performed on the pin image to obtain a pin region representing the pin contour; Morphological extraction is performed on the pin region to obtain morphological features, and a center axis of the pin region is determined according to the morphological features; According to the pin image, a reference axis is determined, and an actual included angle between the center axis and the reference axis is calculated; detect whether the actual included angle is in a preset angle range, and if it is detected that the actual included angle is not in the preset angle range, it is determined that the corresponding pin has a bending defect.

[0007] In a second aspect, an embodiment of the present application provides a pin defect detection device, which comprises: An image segmentation module is configured to collect a pin image from an original image based on pin target positioning, perform image segmentation on the pin image, and obtain a pin region representing a pin contour. A morphology extraction module is configured to perform morphology extraction on the pin region to obtain a morphology feature, and determine a center axis of the pin region according to the morphology feature. An included angle calculation module is configured to determine a reference axis according to the pin image, and calculate an actual included angle between the center axis and the reference axis. A defect determination module is configured to detect whether the actual included angle is in a preset angle range, and if it is detected that the actual included angle is not in the preset angle range, it is determined that the corresponding pin has a bending defect.

[0008] In a third aspect, an embodiment of the present application provides a computer device, which comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, and the processor implements the pin defect detection method according to the first aspect when executing the computer program.

[0009] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executable on a processor to implement the pin defect detection method according to the first aspect.

[0010] Compared with the prior art, the embodiment of the present application has the following beneficial effects: In the present application, a pin image is collected from an original image based on pin target positioning, image segmentation is performed on the pin image to obtain a pin region representing a pin contour, morphology extraction is performed on the pin region to obtain a morphology feature, a center axis of the pin region is determined according to the morphology feature, a reference axis is determined according to the pin image, an actual included angle between the center axis and the reference axis is calculated, it is detected whether the actual included angle is in a preset angle range, and if it is detected that the actual included angle is not in the preset angle range, it is determined that the corresponding pin has a bending defect. By collecting a pin image from an original image based on pin target positioning and segmenting to obtain a pin region, then extracting a morphology feature of the pin region to determine a center axis, then determining a reference axis according to the pin image and calculating an actual included angle between the two, and finally determining whether the pin has a bending defect by judging whether the included angle is in a preset range, the morphology of the pin image is analyzed to determine the included angle between the center axis and the reference axis, so as to complete the defect detection of the pin. BRIEF DESCRIPTION OF DRAWINGS

[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or prior art description will be briefly introduced as follows. Obviously, the drawings in the following description only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor.

[0012] Figure 1 is an application environment schematic diagram of a needle defect detection method provided by an embodiment of the present application; Figure 2 is a flow schematic diagram of a needle defect detection method provided by an embodiment of the present application; Figure 3 is a flow schematic diagram of a needle defect detection method provided by an embodiment of the present application; Figure 4 is a flow schematic diagram of a needle defect detection method provided by an embodiment of the present application; Figure 5 is a flow schematic diagram of a needle defect detection method provided by an embodiment of the present application; Figure 6 is a structure schematic diagram of a needle defect detection device provided by an embodiment of the present application; Figure 7 is a structure schematic diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0013] In the following description, specific details are set forth in order to provide a thorough understanding of the present application. However, persons of ordinary skill in the art will realize that the present application can be practiced without these specific details, and that the present application is not limited to the specific details described. In some instances, well-known systems, structures, circuits, and methods have not been described in detail in order to avoid obscuring the present application.

[0014] It should be understood that, when used in the specification and the appended claims of the present application, the term "comprising" indicates the presence of the described features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.

[0015] It should also be understood that the term "and / or" used in the specification and the appended claims of the present application means any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.

[0016] As used in the description of the application and the appended claims, the term "if' can be interpreted to mean "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [a described condition or event] is detected" can be interpreted to mean "upon determining" or "in response to determining" or "upon detecting [the described condition or event]" or "in response to detecting [the described condition or event]," depending on the context.

[0017] In addition, the terms "first", "second", "third", etc. as used in the description of the application and the appended claims are only used to distinguish descriptions and cannot be understood as indicating or implying relative importance.

[0018] The description of "one embodiment" or "some embodiments" or the like in the present application means that the specific features, structures or characteristics described in connection with the embodiment are included in one or more embodiments of the present application. Therefore, the statements "in one embodiment", "in some embodiments", "in other some embodiments", "in further some embodiments" and the like appearing in different places in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized. The terms "include", "contain", "have" and their variants mean "including but not limited to", unless otherwise specifically emphasized.

[0019] It should be understood that the size of the serial number of each step in the following embodiments does not mean the order of execution, and the execution order of each process should be determined by its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0020] In order to illustrate the technical solutions of the present application, the following will be described by specific embodiments.

[0021] The needle defect detection method provided by the embodiment of the present application can be applied in the application environment such as Figure 1 , wherein the client and the server are connected for communication, the user can provide the conditions, requirements and operation instructions of the needle defect detection by operating the client, and the server is used to control the needle defect detection method according to the control instruction of the needle defect detection method sent by the client.

[0022] The client includes, but is not limited to, a palm computer, a desktop computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cloud terminal device, a personal digital assistant (PDA), and the like computer device. The server can be a stand-alone server, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and basic cloud computing services such as big data and artificial intelligence platforms.

[0023] Referring to Figure 2 , a flowchart of a pin defect detection method provided in Embodiment Two of the present application, the pin defect detection method can be applied to Figure 1 a server.

[0024] As shown in Figure 2 , the pin defect detection method can include the following steps: Step S201, based on pin target positioning, a pin image is acquired from an original image, and the pin image is subjected to image segmentation to obtain a pin region representing a pin contour; Optionally, step S201 can include the following steps: An original image containing a plurality of pins is acquired, and the original image is input into a pre-set trained target detection model for position recognition to obtain a bounding box coordinate representing the position of each pin in the original image; According to the bounding box coordinate, the original image is split to obtain an image slice corresponding to each pin, pixel information of the image slice is extracted, and the image slice is subjected to region division according to the pixel information to obtain a pin region representing a pin contour.

[0025] The image containing a plurality of pins is acquired by a suitable image acquisition device (such as a camera). When acquiring, the image should be clear and the light should be uniform to ensure the accuracy of subsequent processing. For example, on an industrial production line, a high-precision industrial camera is used to take pictures of the pins on the circuit board to obtain an original image. The target detection model is a specially trained machine learning or deep learning model, such as the YOLO (You Only Look Once) series, FasterR-CNN, etc. In the training stage, a large number of image samples containing pins are used, and the accurate position of each pin in the image is labeled, so that the model learns the features and position information of the pins.

[0026] The original image is input into the trained object detection model, which analyzes the image and identifies the position of each needle thread, and outputs a bounding box. The bounding box is represented by four coordinate values (such as the x, y coordinates of the upper left corner and the x, y coordinates of the lower right corner), which can roughly frame the position range of each needle thread in the original image.

[0027] According to the bounding box coordinates output by the object detection model, the area contained in each bounding box is cropped from the original image to obtain the image slice corresponding to each needle thread. This has the advantage of extracting each needle thread separately, facilitating independent processing and analysis of each needle thread, and reducing background information interference.

[0028] An image is composed of individual pixels, each with its own specific attributes, such as color values (represented by red, green, and blue channel values in the RGB color space), brightness, etc. Extracting pixel information from an image slice involves obtaining the attribute values of these pixels.

[0029] Based on the extracted pixel information, use appropriate image segmentation algorithms (such as threshold segmentation, edge detection, clustering-based segmentation, etc.) to process the image slice and separate the needle thread region from the background. For example, by setting a suitable brightness threshold, pixels with brightness above the threshold are determined as needle thread regions, and pixels below the threshold are determined as background regions, thus obtaining a needle thread region representing the needle thread contour.

[0030] In step S202, the needle thread region is subjected to morphological extraction to obtain morphological features, and based on the morphological features, the center axis of the needle thread region is determined.

[0031] Optionally, step S202 can include the following steps: Extract the pixel coordinates corresponding to the needle thread region in the image slice, record the pixel coordinates and form a coordinate data set; Perform correlation analysis based on the coordinate data set to obtain a covariance matrix, perform eigenvalue decomposition on the covariance matrix to obtain eigenvalues and eigenvectors, and the eigenvalues represent the variance of the pixel coordinates in the direction corresponding to the eigenvectors; Sort the eigenvalues to obtain the principal vector corresponding to the largest eigenvalue, and determine the center axis of the needle thread region based on the principal vector.

[0032] Optionally, step S202 can include the following steps: Perform pixel width processing on the needle thread region to obtain a single-pixel width skeleton corresponding to the needle thread region; The relative distance between the pixel point coordinate and the single-pixel width skeleton is calculated, and the center axis of the stitch region is determined according to the relative distance.

[0033] The pixel point coordinates corresponding to the stitch region in the image slice are extracted, and the pixel point coordinates are recorded to form a coordinate data set. The image is stored in the form of a pixel matrix in the computer, and each pixel has its corresponding coordinates. The stitch region is a part of the image, and we need to find the coordinates of all the pixels in this region. Traverse the pixels in the image slice that belong to the stitch region, record the coordinates of each pixel, and combine these coordinates to form a coordinate data set.

[0034] Correlation analysis is performed on the coordinate data set to obtain the covariance matrix. Covariance is used to measure the correlation between two variables. In the pixel coordinate data set of the stitch region, we can analyze the correlation between the x and y coordinates. For example, if the stitch is in the horizontal direction, the change in the x coordinate may be related to the change in the y coordinate. By calculating the covariance and variance of all the pixels in the coordinate data set, we can obtain the covariance matrix.

[0035] Eigenvalue decomposition is an operation in linear algebra. For a square matrix (here it is the covariance matrix), it can be decomposed into eigenvalues and eigenvectors. Eigenvectors are a special set of vectors that, when the matrix acts on them, the vectors are only stretched or compressed, and the stretching or compression ratio is the corresponding eigenvalue.

[0036] In the analysis of the stitch region, the eigenvalue represents the variance of the pixel point coordinates in the direction of the corresponding eigenvector. The larger the variance, the more dispersed the distribution of the pixel points in the direction of the eigenvector.

[0037] Sort the eigenvalues to get the principal vector corresponding to the largest eigenvalue. The principal vector is determined according to the principal vector to determine the center axis of the stitch region. The eigenvector corresponding to the largest eigenvalue is called the principal vector. The direction of the principal vector represents the direction of the most dispersed distribution of the pixel points in the stitch region, which is the main direction of the stitch.

[0038] A straight line is drawn from the geometric center of the stitch region along the direction of the principal vector. This straight line can be approximately regarded as the center axis of the stitch region.

[0039] The second optional implementation involves pixel-width processing of the pin region to obtain a single-pixel-width skeleton for that region. Pixel-width processing is a morphological operation aimed at refining the pin region into a single-pixel-width skeleton. This can be achieved using algorithms such as the Zhang-Suen algorithm. By continuously removing pixels from the edges of the pin region until only a single-pixel-width skeleton remains, the main shape and topology of the pin are preserved. The single-pixel-width skeleton can be viewed as an approximate representation of the pin's center path, simplifying the pin's shape and facilitating subsequent analysis.

[0040] For each pixel within the pin region, calculate its distance to all points on the single-pixel-width skeleton, typically using Euclidean distance. Based on these relative distances, the central axis of the pin region can be determined using methods such as finding the path with the minimum average distance. For example, a path can be found that minimizes the average distance from all pixels within the pin region to this path; this path can then be used as the central axis.

[0041] Step S203: Determine the reference axis based on the pin image, and calculate the actual angle between the central axis and the reference axis.

[0042] Step S204: Detect whether the actual included angle is within the preset angle range. If the actual included angle is not within the preset angle range, it is determined that the corresponding pin has a bending defect.

[0043] The reference axis is a pre-defined reference axis used to measure whether the direction of the pin's center axis conforms to a standard. Its determination is based on the pin's design requirements, the overall product layout, or the characteristics of the image itself. If the pin is mounted on a component at a specific design angle, a theoretically standard direction can be determined as the reference axis based on the design drawings. For example, in circuit board design, if the pin should be perpendicular to the circuit board plane, then the direction perpendicular to the circuit board image plane can be used as the reference axis.

[0044] In an image, if there are obvious reference elements, such as edges or grid lines, these elements can be used to determine the reference axis. For example, if there is a horizontal border in the image, then the direction parallel to this border can be used as the reference axis.

[0045] The preset angle range is determined according to normal use requirements and production process standards of the needle. In an ideal case, the center axis of the needle should be completely coincident with the reference axis, and the included angle is 0°. However, due to certain errors in the production process, the needle is allowed to have a certain angle deviation. The actual included angle calculated in step S203 is compared with the preset angle range. If the actual included angle is within the preset angle range, it indicates that the direction of the needle meets the requirements and there is no bending defect. If the actual included angle exceeds the preset angle range, it indicates that the direction of the needle deviates from the normal standard, and there is a bending defect.

[0046] In the present application, based on the target positioning of the needle, the needle image is collected from the original image, the needle image is segmented to obtain the needle region representing the needle contour, the morphological feature is extracted from the needle region, the center axis of the needle region is determined according to the morphological feature, the reference axis is determined according to the needle image, the actual included angle between the center axis and the reference axis is calculated, and it is detected whether the actual included angle is within the preset angle range. If it is detected that the actual included angle is not within the preset angle range, it is determined that the corresponding needle has a bending defect. By first collecting the needle image from the original image based on the target positioning of the needle and segmenting to obtain the needle region, then extracting the morphological feature of the needle region to determine the center axis, and then determining the reference axis according to the needle image and calculating the actual included angle between the two, finally determining whether the needle has a bending defect by judging whether the included angle is within the preset range. Thus, the morphological analysis of the needle image is performed to determine the included angle between the center axis and the reference axis, so as to complete the defect detection of the needle.

[0047] Referring to Figure 3 is a flowchart of a needle defect detection method provided in Embodiment Three of the present application. As Figure 3 shown, the needle defect detection method can further include the following steps: Step S301, determining the quality judgment level of the needle according to the actual included angle; Step S302, labeling the image slice according to the quality judgment level to obtain a labeled image, and generating a detection report according to the labeled image.

[0048] The setting of the quality judgment level is based on the actual use requirements and production standards of the needle. Different application scenarios have different tolerances for the angle deviation of the needle, so the quality of the needle can be divided into different levels according to the size of the actual included angle. Generally, the smaller the angle deviation, the better the quality of the needle; the larger the angle deviation, the higher the possibility of problems in the needle, and the lower the quality level.

[0049] The labeled image is used to visually display the quality assessment results of each stitch, facilitating subsequent viewing and analysis. By labeling the quality level of each stitch on the image slice, it is clear to see which stitches are of good quality and which stitches have problems. Different colors, symbols or words can be used to represent different quality assessment levels. For example, green represents excellent level, yellow represents good level, orange represents medium level, and red represents poor level. On the image slice, the corresponding label is marked next to each stitch, and the labeled image is obtained.

[0050] The detection report is a summary of the entire stitch detection process and results, which can provide important basis for production management and quality control. According to the statistical data and actual situation, the overall quality of the stitches is evaluated, the possible problems and reasons are analyzed, and the corresponding improvement suggestions are put forward. For example, if the proportion of poor level stitches is high, it may be necessary to check whether the production equipment has failed or to adjust the production process parameters.

[0051] In the embodiments of the present application, the quality of the stitches is quantitatively evaluated, and the detection results are presented in the form of intuitive labeled images and detailed detection reports, which provides strong support for quality control and decision-making in the production process.

[0052] Reference Figure 4 is a flowchart of a stitch defect detection method provided in Embodiment Four of the present application. As Figure 4 indicated, the step S302 of labeling the image slice according to the quality assessment level to obtain a labeled image can include the following steps: Step S401, determining an image labeling method of the image slice according to the quality assessment level.

[0053] Step S402, labeling the image slice according to the image labeling method to obtain a labeled image.

[0054] Different colors can be used to represent different quality assessment levels. This way is intuitive and easy to understand, and can quickly identify stitches of different quality levels for the observer. For example, green represents excellent level, yellow represents good level, orange represents medium level, and red represents poor level.

[0055] Determining the image labeling method needs to consider multiple factors, such as the complexity of the image, the purpose and audience of the labeling, etc. According to the image labeling method, the image slice is labeled to obtain a labeled image. First, the position of each stitch in the image slice needs to be accurately located. This can be achieved by using the stitch area information extracted in the previous step. For example, according to the pixel coordinates of the stitch area, the specific position of the stitch in the image is determined.

[0056] According to the image labeling method determined in step S401, label at the corresponding position of each stitch.

[0057] If color labeling is used, use image processing software (such as OpenCV, etc.) to fill the corresponding quality level color to the stitch area or draw a small color mark next to the stitch. For example, for a stitch of excellent level, draw a small green circle around it.

[0058] For symbol labeling, draw the corresponding symbol next to the stitch. You can use the drawing function in the image processing library to draw the symbol, ensuring that the size and position of the symbol are appropriate and do not affect the observation of the stitch.

[0059] If text labeling is used, add text next to the stitch to indicate the quality level. Pay attention to the font, size and color of the text to ensure that the text is clear and readable, and has enough contrast with the image background.

[0060] After labeling, save the labeled image as a common image format (such as JPEG, PNG, etc.) to get the labeled image. The labeled image intuitively shows the quality determination result of each stitch, providing a clear visual basis for subsequent analysis and decision-making.

[0061] In the embodiments of the present application, by selecting the appropriate labeling method to label the image slice according to the quality determination level of the stitch, a labeled image that can clearly show the quality of the stitch is obtained.

[0062] Referring to Figure 5 is a flowchart of a stitch defect detection method provided in Embodiment Five of the present application. As Figure 5 indicated, the step S402 of generating a detection report according to the labeled image can include the following steps: Step S501, according to the actual angle combined with the labeled image, the stitch detection result of the stitch is obtained; Step S502, according to the detection result, generate a detection report.

[0063] Among them, the actual angle is a quantitative index to judge whether the stitch is bent and the degree of bending, and the labeled image directly shows the quality determination level of each stitch. Combining the two, we can fully and accurately understand the specific situation of each stitch.

[0064] The labeled image has been labeled according to the quality determination level of the stitch, and different labels represent different quality conditions. The actual angle is the basis for determining these quality levels. By looking at the labeled image, we can quickly locate each stitch, and then combine the corresponding actual angle to know the specific bending degree of the stitch and whether it meets the quality requirements.

[0065] For a single stitch, according to its annotation in the annotated image and the actual included angle, its quality judgment level and specific angle deviation situation are determined. All stitches are comprehensively analyzed, and the number and proportion of stitches of different quality judgment levels are counted. At the same time, the distribution of the angle deviation of the stitches can also be analyzed, for example, the angle deviation of most stitches is concentrated in which interval.

[0066] According to the detection result, a detection report is generated, which includes the title of the report (such as "stitch detection report"), the detection date, the detection unit and other basic information. Briefly introduce the purpose, object and scope of the detection. For example, this detection is to evaluate the quality situation of the stitches of a batch of products, and the detection object is the stitch images of the batch of products. Describe the method used in the detection process, including how to determine the reference axis, calculate the actual included angle, divide the quality judgment level and the way of annotating the image, etc. Let the person reading the report understand the scientificity and reliability of the detection.

[0067] The number, proportion of stitches of different quality judgment levels, and the distribution of the angle deviation of the stitches are listed in detail. The data can be presented in the form of a table, making the data more clear and intuitive.

[0068] The annotated image is attached to visually show the quality situation of the stitches. At the same time, the annotated image can be briefly explained to explain the meaning of different annotations.

[0069] According to the detection result, the overall quality situation of the stitches is summarized and evaluated. For example, it is judged whether the quality of the stitches of the batch of products meets the requirements, whether there are general problems, etc. Suggestions for improvement are made for the problems found in the detection. If the proportion of poor level stitches is high, it is suggested to check whether the production equipment needs to be debugged, whether the production process needs to be optimized, etc. The detection report can be written using a word processing software (such as Microsoft Word, WPS word, etc.), and the above contents are arranged according to a certain structure and format. In the process of writing, attention should be paid to the accuracy and conciseness of language expression, so that the report is easy to understand and read.

[0070] In the embodiment of the present application, by combining the actual detection data of the stitches with the intuitive annotated image, a comprehensive and detailed detection report is generated, which provides a strong basis for production management and quality control.

[0071] Corresponding to the stitch defect detection method of the above embodiment, Figure 6 The structure block diagram of the stitch defect detection device provided by the sixth embodiment of the present application is shown, and the above stitch defect detection device can be applied to the server in Figure 1 For the convenience of description, only the parts related to the embodiments of the present application are shown.

[0072] Referring toFigure 6 The needle defect detection device comprises: An image segmentation module 61 is configured to collect a needle image from an original image based on needle target positioning, perform image segmentation on the needle image, and obtain a needle region representing a needle contour. A morphology extraction module 62 is configured to perform morphology extraction on the needle region, obtain a morphology feature, and determine a center axis of the needle region based on the morphology feature. An included angle calculation module 63 is configured to determine a reference axis based on the needle image and calculate an actual included angle between the center axis and the reference axis. A defect determination module 64 is configured to detect whether the actual included angle is within a preset angle range, and determine that a corresponding needle has a bending defect if it is detected that the actual included angle is not within the preset angle range.

[0073] Optionally, the image segmentation module 61 comprises: A bounding box coordinate determination unit is configured to obtain an original image containing a plurality of needles, input the original image into a preset trained target detection model for position recognition, and obtain bounding box coordinates representing the positions of the needles in the original image. A region division unit is configured to divide the original image based on the bounding box coordinates, obtain image slices corresponding to the needles, extract pixel information of the image slices, divide the image slices into regions based on the pixel information, and obtain needle regions representing needle contours.

[0074] Optionally, the morphology extraction module 62 comprises: A data recording unit is configured to extract pixel point coordinates corresponding to the needle regions in the image slices, record the pixel point coordinates, and form a coordinate data set. A feature decomposition unit is configured to perform correlation analysis based on the coordinate data set, obtain a covariance matrix, perform feature decomposition on the covariance matrix, obtain eigenvalues and eigenvectors, and the eigenvalues represent the variance of the pixel point coordinates in the direction corresponding to the eigenvectors. An axis determination unit is configured to sort the sizes of the eigenvalues to obtain a principal vector corresponding to the largest eigenvalue, and determine a center axis of the needle region based on the principal vector.

[0075] Optionally, the morphology extraction module 62 comprises: A pixel processing unit is configured to perform pixel width processing on the needle region to obtain a single-pixel width skeleton corresponding to the needle region. A distance calculation unit is configured to calculate a relative distance between the pixel point coordinate and the single-pixel width skeleton, and determine a center axis of the stitch area according to the relative distance.

[0076] Optionally, the stitch defect detection device further comprises: A grade determination module is configured to determine a quality judgment grade of the stitch according to the actual included angle. An image labeling module is configured to label the image slice according to the quality judgment grade to obtain a labeled image, and generate a detection report according to the labeled image.

[0077] Optionally, the image labeling module comprises: A mode determination unit is configured to determine an image labeling mode of the image slice according to the quality judgment grade. A slice labeling unit is configured to label the image slice according to the image labeling mode to obtain a labeled image.

[0078] Optionally, the image labeling module comprises: A stitch detection unit is configured to obtain a stitch detection result of the stitch according to the actual included angle and the labeled image. A report generation unit is configured to generate a detection report according to the detection result.

[0079] It should be noted that the information interaction and execution process between the above modules, units and sub-units are based on the same concept as the method embodiments, and the specific functions and technical effects brought by them can be referred to the method embodiments part, which will not be repeated here.

[0080] Figure 7 A structural schematic diagram of a computer device according to Embodiment Seven of the present application is provided. As shown in the figure, Figure 7 the computer device of this embodiment comprises at least one processor (only one is shown in the figure), a memory, and a computer program stored in the memory and executable on the at least one processor, and the processor executes the computer program to implement the steps in any of the above stitch defect detection methods or stitch defect detection method embodiments. Figure 7

[0081] The computer device can include, but is not limited to, a processor and a memory. Those skilled in the art can understand that Figure 7 the computer device is only an example of the computer device and does not constitute a limitation on the computer device. The computer device can include more or fewer components than those shown, or combine certain components, or include different components, for example, it can also include a network interface, a display screen, and an input device, etc.

[0082] ​The processor can be a CPU, and can also be other general-purpose processors, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.

[0083] The memory includes a readable storage medium, an internal memory, etc., where the internal memory can be a memory of the computer device, and the internal memory provides an environment for running the operating system and the computer-readable instructions in the readable storage medium. The readable storage medium can be a hard disk of the computer device, and in other embodiments, can also be an external storage device of the computer device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. Further, the memory can include both an internal storage unit of the computer device and an external storage device. The memory is used to store an operating system, an application program, a BootLoader, data, and other programs, such as program codes of computer programs, etc. The memory can also be used to temporarily store data that has been output or will be output.

[0084] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is exemplified, and in actual application, the above-mentioned functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of software functional unit. In addition, the specific names of each functional unit and module are only for easy distinction, and do not limit the protection scope of the present application. The specific working process of the units and modules in the device can refer to the corresponding process in the foregoing method embodiments, which will not be repeated here. If the integrated unit is realized in the form of software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, all or part of the processes in the above-mentioned embodiment methods can be completed by a computer program to instruct related hardware, and the computer program can be stored in a computer readable storage medium. When the processor executes the computer program, the steps of the above-mentioned method embodiments can be implemented. The computer program includes computer program code, which can be in the form of source code, object code, executable file or some intermediate form. The computer readable medium at least includes any entity or device capable of carrying computer program code, recording medium, computer memory, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), electric carrier signal, telecommunication signal and software distribution medium. For example, U disk, mobile hard disk, magnetic disk or optical disk, etc. In some jurisdictions, according to legislation and patent practice, computer readable medium cannot be electric carrier signal and telecommunication signal.

[0085] The above-mentioned embodiment methods can also be completed by a computer program product, when the computer program product runs on the computer equipment, so that the computer equipment can execute the steps in the above-mentioned method embodiments.

[0086] In the above-mentioned embodiments, the description of each embodiment has its own emphasis, and the parts not described or recorded in detail in a certain embodiment can be referred to the related description of other embodiments.

[0087] Those skilled in the art can understand that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware or a combination of computer software and electronic hardware. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0088] In the embodiments provided in the present application, it should be understood that the disclosed apparatus / computer device and method can be implemented in other ways. For example, the apparatus / computer device embodiments described above are merely schematic, for example, the division of the modules or units is only a logical function division, and there can be another division in actual implementation, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, device or unit, and can be electrical, mechanical or other forms.

[0089] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e. can be located in one place, or can be distributed on a plurality of network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiments.

[0090] The above embodiments are only used to illustrate the technical solutions of the present application, but not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features can be replaced by equivalents; and these modifications or replacements do not make the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.

Claims

1. A method for detecting pin defects, characterized in that, include: Based on the pin target localization, pin images are acquired from the original image, and the pin images are segmented to obtain pin regions that characterize the pin outline; The morphology of the stitch region is extracted to obtain morphological features, and the central axis of the stitch region is determined based on the morphological features. Based on the pin image, determine the reference axis and calculate the actual angle between the central axis and the reference axis; The actual included angle is detected to be within a preset angle range. If the actual included angle is not detected to be within the preset angle range, it is determined that the corresponding pin has a bending defect.

2. The pin defect detection method according to claim 1, characterized in that, The process based on pin target localization involves acquiring pin images from the original image, performing image segmentation on the pin images to obtain pin regions characterizing the pin contours, including: Obtain an original image containing several pins, input the original image into a pre-trained target detection model for position recognition, and obtain the bounding box coordinates representing the position of each pin in the original image; Based on the bounding box coordinates, the original image is split to obtain image slices corresponding to each of the pins. Pixel information of the image slices is extracted, and the image slices are divided into regions based on the pixel information to obtain pin regions that characterize the pin outline.

3. The pin defect detection method according to claim 2, characterized in that, The step of extracting the morphology of the stitch region to obtain morphological features, and determining the central axis of the stitch region based on the morphological features, includes: Extract the pixel coordinates corresponding to the pin area in the image slice, record the pixel coordinates and form a coordinate dataset; Correlation analysis is performed on the coordinate dataset to obtain a covariance matrix. Eigenvalues ​​and eigenvectors are obtained from the covariance matrix. The eigenvalues ​​represent the variance of the pixel coordinates in the direction corresponding to the eigenvector. The eigenvalues ​​are sorted by size to obtain the principal vector corresponding to the largest eigenvalue. Based on the principal vector, the central axis of the stitch region is determined.

4. The pin defect detection method according to claim 3, characterized in that, The step of extracting the morphology of the stitch region to obtain morphological features, and determining the central axis of the stitch region based on the morphological features, includes: The pin area is processed to obtain a single-pixel width skeleton corresponding to the pin area; Calculate the relative distance between the pixel coordinates and the single-pixel width skeleton, and determine the central axis of the pin area based on the relative distance.

5. The pin defect detection method according to claim 2, characterized in that, If the actual included angle is detected to be outside the preset angle range, and it is determined that the corresponding pin has a bending defect, the method further includes: The quality grade of the pin is determined based on the actual included angle. Based on the quality assessment level, the image slices are labeled to obtain labeled images, and a detection report is generated based on the labeled images.

6. The pin defect detection method according to claim 5, characterized in that, The step of labeling the image slices according to the quality assessment level to obtain a labeled image includes: Based on the quality assessment level, determine the image annotation method for the image slice; The image slices are labeled according to the image labeling method to obtain labeled images.

7. The pin defect detection method according to any one of claims 5, characterized in that, The step of generating a detection report based on the labeled image includes: Based on the actual included angle and the labeled image, the pin detection result of the pin is obtained; A test report is generated based on the test results.

8. A pin defect detection device, characterized in that, include: The image segmentation module is used to acquire a pin image from the original image based on pin target localization, and to perform image segmentation on the pin image to obtain a pin region that represents the pin outline; The morphology extraction module is used to extract the morphology of the stitch region, obtain morphological features, and determine the central axis of the stitch region based on the morphological features. Angle calculation module is used to determine the reference axis based on the pin image and calculate the actual angle between the central axis and the reference axis; The defect determination module is used to detect whether the actual included angle is within a preset angle range. If the actual included angle is not within the preset angle range, it is determined that the corresponding pin has a bending defect.

9. A computer device, characterized in that, The computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the pin defect detection method as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the pin defect detection method as described in any one of claims 1 to 7.