Cable Production Detection Method and System Based on Machine Vision
By shooting and preprocessing cable images with a high-resolution camera, extracting edge information and training defect recognition models, the problem of unclear judgment basis for cable appearance defect detection and incomplete image information is solved, and more accurate cable defect detection is achieved.
Patent Information
- Application Number
- CN202411504103.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2044-10-25
AI Technical Summary
The existing cable appearance defect detection technology has insufficient basis for judging cable appearance defects and the comprehensive image information of the acquisition cable is not clear enough, resulting in insufficient reliability of the detection results.
Use a high-resolution camera to capture the cable appearance image, perform preprocessing, extract edge information, delineate the outline image, detect it through the defect recognition model, train sample cable features and perform defect detection.
It improves the comprehensiveness and accuracy of cable appearance defect detection, and through automated and comprehensive acquisition of image information, the reliability and rationality of detection are improved.
Smart Images

Figure CN119516254B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of cable appearance defect detection, and specifically to a cable production detection method and system based on machine vision. Background Art
[0002] The cable appearance defect detection technology refers to using various sensors and image processing technologies to scan and analyze the external surface of the cable, so as to detect and identify possible defects on the external surface of the cable in a timely manner, such as scratches, cracks, wear, and deformation. This technology is usually used to ensure the quality and safety of the cable, as well as improve production efficiency and reduce failure rates. Through an automated detection process, it can effectively reduce errors caused by human factors and improve the accuracy and reliability of detection.
[0003] Existing cable appearance defect detection technologies usually form a defect dataset by collecting defect images, and then judge whether there are defects in the cable appearance through similarity analysis with the defect dataset. At the same time, since the cable is cylindrical and relatively long, existing cable appearance defect detection technologies do not have a perfect image acquisition scheme. Usually, single-point acquisition and single-point judgment are carried out, and the specific operation process of collecting cable images and how to collect comprehensive image information of the cable are not described. For example, in the patent application with the publication number CN117571714A, a cable sheath appearance defect detection device and method based on machine vision are disclosed. When judging whether there are defects in the cable appearance, this scheme judges by comparing with an image data processing library, and the specific judgment process is not described. The specific judgment basis for cable appearance defects is not clear enough. Existing cable appearance defect detection technologies also have the problems that the judgment basis for cable appearance defects is not clear enough and the process of collecting comprehensive image information of the cable is not clear enough, resulting in insufficient reliability of cable appearance defect detection results. Summary of the Invention
[0004] The present invention aims to solve at least one of the technical problems in the existing technology to some extent. By using a high-resolution camera to photograph the appearance of the cable, obtaining an appearance image, then preprocessing the appearance image, obtaining an appearance grayscale image after improving the image quality, then extracting the edge information of the cable in the appearance grayscale image, delimiting the contour image of the cable based on the edge information, then screening the cables without appearance defects, marking them as sample cables, extracting the appearance features of the sample cables and conducting feature analysis, training a defect recognition model, and after the training is completed, detecting defects in the cable appearance through the defect recognition model, so as to solve the problems that the judgment basis for cable appearance defects in existing cable appearance defect detection technologies is not clear enough and the process of collecting comprehensive image information of the cable is not clear enough, resulting in insufficient reliability of cable appearance defect detection results.
[0005] To achieve the above object, in a first aspect, the present application provides a cable production detection method based on machine vision, including the following steps:
[0006] Use a high-resolution camera to take pictures of the appearance of the cable to obtain appearance images;
[0007] Preprocess the appearance images to obtain appearance grayscale images after improving the image quality;
[0008] Extract the edge information of the cable in the appearance grayscale image, and delimit the contour image of the cable based on the edge information;
[0009] Extract the appearance features of the contour image, perform feature analysis on the appearance features, analyze the gray-scale floating threshold and gray-scale floating area of the cable through sample cables, then train a defect recognition model and perform defect detection on the appearance of the cable through the defect recognition model.
[0010] Further, using a high-resolution camera to take pictures of the appearance of the cable to obtain appearance images includes the following sub-steps:
[0011] Set up a support structure, on which a rolling device and two retractable rings are installed, named the first ring and the second ring in order from left to right;
[0012] Pass the cable through the first ring and the second ring, and pass one end of the cable through the rolling device, clamp the cable through the rolling device, and then control the first ring and the second ring to contract to clamp the cable;
[0013] Take pictures of the cable.
[0014] Further, taking pictures of the cable includes the following sub-steps:
[0015] A high-resolution camera is arranged in the front of the midpoint between the first ring and the second ring to take pictures of the cable between the first ring and the second ring to obtain appearance images;
[0016] Loosen the rolling device, control the first ring and the second ring to rotate clockwise by 90° at the same time, and take pictures again. The same section of cable needs to be rotated three times, and a total of four appearance images are obtained by taking pictures;
[0017] The length of the cable in each taken appearance image is the first shooting length;
[0018] Loosen the first ring and the second ring, and then control the rolling device to clamp the cable and roll. When rolling, the cable will be driven to move to the left;
[0019] When the cable moves the first shooting length, stop rolling, and control the first ring and the second ring to contract, and take pictures of the appearance image again;
[0020] A cable will capture multiple sets of appearance images.
[0021] Furthermore, preprocess the appearance images, and after improving the image quality, obtain the appearance grayscale images, including the following sub-steps:
[0022] Filter the appearance images by Gaussian filtering;
[0023] After the processing is completed, gray-scale the images to obtain the appearance grayscale images.
[0024] Furthermore, extract the edge information of the cable in the appearance grayscale images, and delimit the contour image of the cable based on the edge information, including the following sub-steps:
[0025] When photographing the cable, a pure white baffle is set in the background. In the captured appearance images, except for the part of the cable, the rest are all pure white, and the gray-scale values after gray-scaling are all 255;
[0026] Eliminate the pixel points with a gray-scale value of 255, and mark the remaining pixel points as cable points;
[0027] The contour image is composed of cable points.
[0028] Furthermore, extract the appearance features of the contour image, conduct feature analysis on the appearance features, analyze the gray-scale floating threshold and gray-scale floating area of the cable through sample cables, and then train a defect recognition model and use the defect recognition model to detect the appearance of the cable, including the following sub-steps:
[0029] Select cables with no appearance defects, mark them as sample cables, extract the appearance features of the sample cables and conduct feature analysis, and train a defect recognition model;
[0030] After the training is completed, use the defect recognition model to detect the appearance of the cable.
[0031] Furthermore, select cables with no appearance defects, mark them as sample cables, extract the appearance features of the sample cables and conduct feature analysis, and train a defect recognition model, including the following sub-steps:
[0032] Select sample cables with no appearance defects for photographing, mark the captured and processed contour images as sample images, obtain multiple sets of sample images, and integrate the sample images of the same cable into homologous images;
[0033] For any homologous image, obtain the gray-scale values of the cable points in the homologous image, and mark them as single-point gray-scale values;
[0034] Count the number of different single-point gray values, mark it as the same-value quantity, find the maximum value among the same-value quantities, mark it as the maximum occupancy ratio, and obtain the single-point gray value corresponding to the maximum occupancy ratio, mark it as the reference gray value;
[0035] Calculate the absolute value of the difference between the single-point gray value except the reference gray value and the reference gray value, mark it as the gray difference;
[0036] Count the number of different gray differences, mark it as the difference quantity, establish a plane rectangular coordinate system with the gray difference as the X-axis and the difference quantity as the Y-axis, name it the gray float distribution graph, and input the gray difference and the corresponding difference quantity into the gray float distribution graph;
[0037] Mark the coordinate points in the gray float distribution graph as gray float points, connect the adjacent gray float points in the X direction with a smooth curve, and name the obtained curve the gray float curve;
[0038] Analyze the remaining homologous images. Each group of homologous images can obtain a gray float curve, and draw all the gray float curves in the gray float distribution graph;
[0039] Further analyze the gray float distribution graph, extract the features of the gray float curve and perform training.
[0040] Further, further analyzing the gray float distribution graph, extracting the features of the gray float curve and performing training includes the following sub-steps:
[0041] Obtain the maximum value of X of the gray float points in the gray float distribution graph, mark it as the gray float threshold;
[0042] Mark the gray float points with the smallest and largest X values in the gray float curve as the minimum float point and the maximum float point respectively;
[0043] Connect the adjacent minimum float points with a smooth curve in ascending order of Y, and at the same time connect the adjacent maximum float points with a smooth curve to obtain the minimum closed curve and the maximum closed curve;
[0044] Based on the minimum closed curve and the maximum closed curve, fill the area between any two gray float curves with gray, and repeat the execution until the area between any two gray float curves is gray, and obtain a gray area marked as the gray float area;
[0045] Extract the graph of the gray float area. At this time, the gray float area and the gray float threshold are the features of the gray float curve.
[0046] Further, after the training is completed, the defect detection of the cable appearance by the defect recognition model includes the following sub-steps:
[0047] After training the defect recognition model through the features of the gray-scale floating curve, when it is necessary to detect the appearance defects of the cable, obtain the contour image of the cable and mark it as the figure to be recognized;
[0048] Based on the figure to be recognized, extract the gray-scale floating distribution map and gray-scale floating curve of the figure to be recognized, and mark them as the distribution map to be recognized and the curve to be recognized respectively;
[0049] Extract the maximum value of X of the coordinate points in the distribution map to be recognized, mark it as the maximum deviation value, compare the maximum deviation value with the gray-scale floating threshold. If the maximum deviation value is less than or equal to the gray-scale floating threshold, output a normal deviation signal; if the maximum deviation value is greater than the gray-scale floating threshold, output an abnormal deviation signal;
[0050] Extract the curve to be recognized, mark the coordinate point with the smallest X in the curve to be recognized as the reference moving point, place the reference moving point in the smallest closed curve, move the reference moving point in ascending order of Y, and the curve to be recognized moves following the reference moving point. Detect whether the curve to be recognized is entirely within the gray-scale floating area. If so, output a normal floating signal; if not, output a continue moving signal;
[0051] If the continue moving signal is output, continue to move the reference moving point and make a judgment. If the normal floating signal is output, stop moving;
[0052] Count the output signals. If an abnormal deviation signal is output or the normal floating signal is not output, mark that there are defects on the cable surface; if the normal deviation signal is output and the normal floating signal is output at the same time, mark that there are no defects on the cable surface.
[0053] In the second aspect, the present application provides a cable production detection system based on machine vision, including an appearance photographing module, a preprocessing module, an appearance extraction module, and a feature analysis module; the appearance photographing module, the preprocessing module, and the appearance extraction module are respectively connected to the feature analysis module for data connection;
[0054] The appearance photographing module is used to photograph the appearance of the cable using a high-resolution camera to obtain an appearance image;
[0055] The preprocessing module is used to preprocess the appearance image to obtain an appearance gray-scale image after improving the image quality;
[0056] The appearance extraction module is used to extract the edge information of the cable in the appearance gray-scale image and delimit the contour image of the cable based on the edge information;
[0057] The feature analysis module is used to extract the appearance features of the contour image, analyze the appearance features, analyze the gray-scale floating threshold and gray-scale floating area of the cable through the sample cable, train the defect recognition model, and detect the appearance defects of the cable through the defect recognition model.
[0058] Advantages of the present invention: By providing a support structure with a rolling device and two retractable rings installed thereon, the cable is passed through the first ring and the second ring, and one end of the cable is passed through the rolling device. The cable is clamped by the rolling device, and then the first ring and the second ring are controlled to contract to clamp the cable and take pictures of the cable. The advantage is that the cable can be moved and rotated by the rotation of the rolling device and the rings, and the appearance image of the cable can be automatically and comprehensively collected, improving the comprehensiveness and effectiveness of the cable appearance defect detection.
[0059] The present invention preprocesses the appearance image, obtains the appearance gray-scale image after improving the image quality, then extracts the edge information of the cable in the appearance gray-scale image, delimits the contour image of the cable based on the edge information, screens the cables without appearance defects, marks them as sample cables, extracts the appearance features of the sample cables and performs feature analysis, trains the defect recognition model, and after training, detects the appearance defects of the cable through the defect recognition model. The advantage is that by extracting the appearance features of the sample cables, the change features of the gray-scale values of the pixel points in the cable appearance under normal circumstances are analyzed. If there are defects in the appearance, the change of the gray-scale value will deviate from the change features, so as to judge whether there are defects in the cable appearance, improving the accuracy and rationality of the cable appearance defect detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 is the principle block diagram of the system of the present invention;
[0061] Figure 2 is the schematic diagram of the shooting environment of the present invention;
[0062] Figure 3 is the schematic diagram of the placement of the cable of the present invention in the rolling device, the first ring and the second ring;
[0063] Figure 4 is the appearance gray-scale image of the present invention;
[0064] Figure 5 is the contour image of the present invention;
[0065] Figure 6 is the schematic diagram of a gray-scale floating curve of the present invention;
[0066] Figure 7 is the schematic diagram of the gray-scale floating distribution map of the present invention;
[0067] Figure 8 Schematic diagram of the minimum floating point and the maximum floating point of the present invention;
[0068] Figure 9 Schematic diagram of connecting the minimum floating point and the maximum floating point of the present invention through a smooth curve;
[0069] Figure 10 Schematic diagram of the minimum closed curve and the maximum closed curve of the present invention;
[0070] Figure 11 Schematic diagram of the grayscale floating area of the present invention;
[0071] Figure 12 Schematic diagram of the distribution map to be recognized and the curve to be recognized of the present invention;
[0072] Figure 13 Schematic diagram of detecting whether the curve to be recognized is entirely within the grayscale floating area of the present invention;
[0073] Figure 14 Flowchart of the steps of the method of the present invention. Detailed implementation manners
[0074] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0075] Example 1, please refer to Figure 1 As shown, the present application provides a cable production detection system based on machine vision, including an appearance shooting module, a preprocessing module, an appearance extraction module, and a feature analysis module; the appearance shooting module, the preprocessing module, and the appearance extraction module are respectively connected to the feature analysis module for data connection;
[0076] The appearance shooting module is used to shoot the appearance of the cable using a high-resolution camera to obtain an appearance image; the appearance shooting module includes an environment construction unit and a cable shooting unit;
[0077] The environment construction unit is configured with an environment construction strategy, and the environment construction strategy includes:
[0078] Please refer to Figure 2 As shown, a support structure is set, and a rolling device and two retractable rings are installed on the support structure, which are named the first ring and the second ring in order from left to right;
[0079] Pass the cable through the first ring and the second ring, pass one end of the cable through the rolling device, clamp the cable through the rolling device, and then control the first ring and the second ring to contract to clamp the cable;
[0080] Take a picture of the cable;
[0081] In practical applications, a shooting environment is built through the support structure, the rolling device, the first ring and the second ring as Figure 2 shown. To facilitate the identification of the cable, a pure white baffle is also set in the shooting environment as the shooting background;
[0082] The cable shooting unit is configured with a cable shooting strategy, and the cable shooting strategy includes:
[0083] A high-resolution camera is arranged on the front of the midpoint between the first ring and the second ring to take pictures of the cable between the first ring and the second ring to obtain appearance images;
[0084] Please refer to Figure 3 shown. Loosen the rolling device, control the first ring and the second ring to rotate 90° clockwise at the same time, and take pictures again. The same section of cable needs to be rotated three times, and a total of four appearance images are obtained by shooting;
[0085] The length of the cable in each appearance image taken is the first shooting length;
[0086] Loosen the first ring and the second ring, and then control the rolling device to clamp the cable and roll. When rolling, the cable will be driven to move to the left;
[0087] When the cable moves the first shooting length, stop rolling, and control the first ring and the second ring to contract, and take pictures of the appearance image again;
[0088] Multiple groups of appearance images will be obtained for one cable;
[0089] In practical applications, the placement of the cable in the rolling device, the first ring and the second ring is as Figure 3 shown. The rotation of the ring drives the cable to rotate to take pictures of the appearance images of each surface of the cable, and then the cable is driven to move to the left by the rotation device to take pictures of the appearance images of other parts of the cable. For one cable, due to its length and different surfaces, multiple appearance images will be obtained by shooting.
[0090] The preprocessing module is used to preprocess the appearance image to obtain an appearance grayscale image after improving the image quality;
[0091] The preprocessing module is configured with a preprocessing strategy, and the preprocessing strategy includes:
[0092] Filter the appearance image by Gaussian filtering;
[0093] Please refer to Figure 4 as shown. After the processing is completed, the image is grayscaled to obtain the appearance grayscale image;
[0094] In practical applications, when performing Gaussian filtering processing, the existing Gaussian filtering technology is used. After the processing is completed, the image is grayscaled to obtain the appearance grayscale image as Figure 4 shown.
[0095] The appearance extraction module is used to extract the edge information of the cable in the appearance grayscale image, and delimit the contour image of the cable based on the edge information;
[0096] The appearance extraction module is configured with an appearance extraction strategy, and the appearance extraction strategy includes:
[0097] Please refer to Figure 5 as shown. When photographing the cable, a pure white baffle is set in the background. Therefore, in the photographed appearance image, except for the part of the cable, the rest are all pure white, and the grayscale values after grayscaling are all 255;
[0098] Eliminate the pixel points with a grayscale value of 255, and mark the remaining pixel points as cable points;
[0099] The contour image is composed of cable points;
[0100] In practical applications, the contour image composed of cable points is as Figure 5 shown.
[0101] The feature analysis module is used to extract the appearance features of the contour image, perform feature analysis on the appearance features, analyze the grayscale floating threshold and grayscale floating area of the cable through the sample cable, and then train the defect recognition model and perform defect detection on the appearance of the cable through the defect recognition model; The feature analysis module includes a floating distribution extraction unit, a floating feature analysis unit, and a defect recognition unit;
[0102] The floating distribution extraction unit and the floating feature analysis unit are used to screen the cables with no appearance defects, mark them as sample cables, extract the appearance features of the sample cables and perform feature analysis, and train the defect recognition model;
[0103] The floating distribution extraction unit is configured with a floating distribution extraction strategy, and the floating distribution extraction strategy includes:
[0104] Screen the sample cables with no appearance defects for photographing, mark the photographed and processed contour image as a sample image, obtain multiple groups of sample images, and integrate the sample images of the same cable into a homologous image;
[0105] For any homologous image, obtain the grayscale value of the cable points in the homologous image and mark it as the single-point grayscale value;
[0106] Count the number of different single-point gray values, mark it as the same-value number, find the maximum value among the same-value numbers, mark it as the maximum occupancy ratio, obtain the single-point gray value corresponding to the maximum occupancy ratio, and mark it as the reference gray value;
[0107] In practical applications, the number of sample cables is usually the more the better, and the minimum should not be less than 100 to provide a sufficient data basis. Take 100 cables without appearance defects as sample cables. For the same sample cable, the obtained sample image is a homologous image. The homologous image includes multiple groups of sample images, and one sample cable corresponds to one group of homologous images. For a group of homologous images, count the single-point gray values of all sample images in it. When counting the same-value number, taking the single-point gray value 131 as an example, the number of single-point gray values with a gray value of 131 is counted as 52630, that is, the same-value number of the single-point gray value 131 is 52630. The maximum value found among the same-value numbers is 63249, that is, the maximum occupancy ratio is 63249, and the single-point gray value corresponding to the maximum occupancy ratio is 135, that is, the reference gray value is 135;
[0108] Calculate the absolute value of the difference between the single-point gray value except the reference gray value and the reference gray value, and mark it as the gray difference;
[0109] Please refer to Figure 6 As shown, count the number of different gray differences, mark it as the difference number, establish a plane rectangular coordinate system with the gray difference as the X-axis and the difference number as the Y-axis, name it the gray fluctuation distribution diagram, and enter the gray difference and the corresponding difference number into the gray fluctuation distribution diagram;
[0110] Mark the coordinate points in the gray fluctuation distribution diagram as gray fluctuation points, connect the gray fluctuation points adjacent to X through a smooth curve, and name the obtained curve the gray fluctuation curve;
[0111] Please refer to Figure 7 As shown, analyze the remaining homologous images. Each group of homologous images can obtain a gray fluctuation curve, and draw all the gray fluctuation curves in the gray fluctuation distribution diagram;
[0112] Further analyze the gray fluctuation distribution diagram, extract the characteristics of the gray fluctuation curve and conduct training;
[0113] In practical applications, calculate the difference between other single-point gray values except 135 and 135. For example, for the single-point gray value 131, the gray difference from 135 is 4, and the same-value number of the single-point gray value 131 is 52630, that is, the difference number of the gray difference 4 is 52630; Through statistical calculation, the gray fluctuation distribution diagram is constructed as shown in Figure 6 shown, Figure 6Only one gray-scale floating curve is shown, that is, the gray-scale floating curve of one sample cable. After analyzing all the sample cables, Figure 7 , since the different lengths of the cables will result in different numbers of captured sample images, and thus different numbers of pixel points, in this embodiment, the lengths of the captured sample cables are all of the same length to ensure the same number of captured sample images;
[0114] The floating feature analysis unit is configured with a floating feature analysis strategy, and the floating feature analysis strategy includes:
[0115] Obtain the maximum value of X of the gray-scale floating points in the gray-scale floating distribution map and mark it as the gray-scale floating threshold;
[0116] Please refer to Figure 8 as shown, mark the gray-scale floating points with the smallest X and the largest X in the gray-scale floating curve as the minimum floating point and the maximum floating point respectively;
[0117] Please refer to Figures 9 to 10 as shown, connect the adjacent minimum floating points with a smooth curve in ascending order of Y, and at the same time connect the adjacent maximum floating points with a smooth curve to obtain the minimum closed curve and the maximum closed curve;
[0118] Please refer to Figure 11 as shown, based on the minimum closed curve and the maximum closed curve, fill the area between any two gray-scale floating curves with gray, and repeat the execution until the area between any two gray-scale floating curves is gray, and obtain a gray area marked as the gray-scale floating area;
[0119] Extract the graph of the gray-scale floating area. At this time, the gray-scale floating area and the gray-scale floating threshold are the features of the gray-scale floating curve;
[0120] In practical applications, the maximum value of X of the obtained gray-scale floating points is 21, that is, the gray-scale floating threshold is 21, Figure 8 the black circle in [[ ]] is the minimum floating point, and the black triangle is the maximum floating point. After connecting the minimum floating point and the maximum floating point with a smooth curve, Figure 9 , for the convenience of distinguishing the minimum closed curve and the maximum closed curve, Figure 10 the gray-scale floating curve is removed to show the minimum closed curve and the maximum closed curve; the gray-scale floating area obtained by filling is as shown in [[ ]] Figure 11 In this embodiment, only a part of the gray-scale floating curves are shown in the gray-scale floating distribution map, so the obtained gray-scale floating area is small and only for reference when explaining this embodiment, not the accurate result in actual applications;
[0121] The defect recognition unit is used to detect the appearance defects of the cable through the defect recognition model after the training is completed;
[0122] The defect recognition unit is configured with a defect recognition strategy, and the defect recognition strategy includes:
[0123] After training the defect recognition model through the characteristics of the gray-scale floating curve, when it is necessary to detect the appearance defects of the cable, obtain the contour image of the cable and mark it as the graph to be recognized;
[0124] Please refer to Figure 12 As shown, based on the graph to be recognized, extract the gray-scale floating distribution graph and the gray-scale floating curve of the graph to be recognized, and mark them as the distribution graph to be recognized and the curve to be recognized respectively;
[0125] Extract the maximum value of X of the coordinate points in the distribution graph to be recognized, mark it as the maximum deviation value, compare the maximum deviation value with the gray-scale floating threshold. If the maximum deviation value is less than or equal to the gray-scale floating threshold, output a normal deviation signal; if the maximum deviation value is greater than the gray-scale floating threshold, output an abnormal deviation signal;
[0126] In practical applications, in this embodiment, after photographing and analyzing the cable that needs to be inspected for appearance, obtain the distribution graph to be recognized and the curve to be recognized as Figure 12 As shown, obtain the maximum deviation value of 20. By comparison, it is obtained that the maximum deviation value of 20 is less than the gray-scale floating threshold of 21, and output a normal deviation signal;
[0127] Please refer to Figure 13 As shown, extract the curve to be recognized, mark the coordinate point with the smallest X in the curve to be recognized as the reference moving point, place the reference moving point in the smallest closed curve, and move the reference moving point in ascending order of Y. The curve to be recognized moves with the reference moving point, and detect whether the curve to be recognized is entirely within the gray-scale floating area. If so, output a normal floating signal; if not, output a continue moving signal;
[0128] If a continue moving signal is output, continue to move the reference moving point and make a judgment. If a normal floating signal is output, stop moving;
[0129] Count the output signals. If an abnormal deviation signal is output or a normal floating signal is not output, mark that there are defects on the cable surface; if a normal deviation signal and a normal floating signal are output at the same time, mark that there are no defects on the cable surface;
[0130] In practical applications, as Figure 13As shown, through movement, it is found that there is a situation where the curve to be analyzed is entirely within the grayscale floating region, and then a floating normal signal is output. Since both the deviation normal signal and the floating normal signal are output, it means that there are no defects in the appearance of the cable being detected this time. Since the outside of the cable is usually wrapped with insulating material, and the color of the outside insulating material of a cable is usually the same color, when the computer displays an image, the pixel values usually vary within a certain range, making the image look more natural and smooth. And this variation follows a certain pattern. As long as it conforms to the analyzed pattern, it means that there are no defects in the appearance of the cable. On the contrary, if there are defects in the appearance of the cable, whether it is a protrusion or a scratch or other appearance defects, it will destroy the balance pattern of the grayscale values on the cable surface, resulting in the curve to be analyzed exceeding the grayscale floating region.
[0131] Embodiment 2, please refer to Figure 4 As shown, the present application provides a cable production detection method based on machine vision, including the following steps:
[0132] Step S1, use a high-resolution camera to photograph the appearance of the cable to obtain an appearance image; Step S1 includes the following sub-steps:
[0133] Step S101, set up a support structure, on which a rolling device and two retractable rings are installed, named the first ring and the second ring in order from left to right;
[0134] Step S102, pass the cable through the first ring and the second ring, and pass one end of the cable through the rolling device. Clamp the cable through the rolling device, and then control the first ring and the second ring to contract to clamp the cable;
[0135] Step S103, photograph the cable;
[0136] Step S103 includes the following sub-steps:
[0137] Step S103.1, a high-resolution camera is arranged in the front of the midpoint between the first ring and the second ring to photograph the cable between the first ring and the second ring to obtain an appearance image;
[0138] Step S103.2, loosen the rolling device, control the first ring and the second ring to rotate clockwise by 90° simultaneously, and photograph again. The same section of the cable needs to be rotated three times, and a total of four appearance images are obtained by photographing;
[0139] Step S103.3, the length of the cable in each photographed appearance image is the first photographing length;
[0140] Step S103.4, loosen the first ring and the second ring, and then control the rolling device to clamp the cable and roll it, which drives the cable to move to the left;
[0141] Step S103.5, when the cable moves to the first shooting length, the rolling is stopped, and the first ring and the second ring are controlled to shrink, and the appearance image is shot again;
[0142] Step S103.6, a cable will be photographed to obtain multiple sets of appearance images;
[0143] Step S2, preprocessing the appearance image to obtain an appearance grayscale image after improving the image quality; Step S2 includes the following sub-steps:
[0144] Step S201, filtering the appearance image by Gaussian filtering;
[0145] Step S202, after the processing is completed, the image is grayed to obtain an appearance grayscale image;
[0146] Step S3, extracting edge information of the cable in the appearance grayscale image, and delineating a contour image of the cable based on the edge information; Step S3 includes the following sub-steps:
[0147] Step S301, when photographing the cable, a pure white baffle is set in the background, so that except for the cable part, the rest of the appearance image obtained by photographing is all pure white, and the grayscale value after grayscale conversion is 255;
[0148] Step S302, removing pixels with a gray value of 255 and marking the remaining pixels as cable points;
[0149] Step S303, forming a contour image from the cable points;
[0150] Step S4, extracting the appearance features of the contour image, performing feature analysis on the appearance features, analyzing the grayscale floating threshold and grayscale floating area of the cable through the sample cable, retraining the defect recognition model and performing defect detection on the appearance of the cable through the defect recognition model; Step S4 includes the following sub-steps:
[0151] Step S401, screening cables with no defects in appearance, marking them as sample cables, extracting appearance features of the sample cables and performing feature analysis, and training a defect recognition model;
[0152] Step S401 includes the following sub-steps:
[0153] Step S401.1, selecting sample cables without defects in appearance and photographing them, marking the contour images obtained by photographing and processing as sample images, obtaining multiple groups of sample images, and integrating the sample images of the same cable into homologous images;
[0154] Step S401.2: For any homologous image, obtain the gray value of the cable points in the homologous image, and mark it as the single-point gray value.
[0155] Step S401.3: Count the number of different single-point gray values, mark it as the same-value number, find the maximum value among the same-value numbers, mark it as the maximum occupancy ratio, and obtain the single-point gray value corresponding to the maximum occupancy ratio, which is marked as the reference gray value.
[0156] Step S401.4: Calculate the absolute value of the difference between the single-point gray value except the reference gray value and the reference gray value, and mark it as the gray difference.
[0157] Step S401.5: Count the number of different gray differences, mark it as the difference number, establish a plane rectangular coordinate system with the gray difference as the X-axis and the difference number as the Y-axis, name it the gray fluctuation distribution diagram, and enter the gray difference and the corresponding difference number into the gray fluctuation distribution diagram.
[0158] Step S401.6: Mark the coordinate points in the gray fluctuation distribution diagram as gray fluctuation points, connect the gray fluctuation points adjacent in X by a smooth curve, and name the obtained curve the gray fluctuation curve.
[0159] Step S401.7: Analyze the remaining homologous images. Each group of homologous images can obtain a gray fluctuation curve, and draw all the gray fluctuation curves in the gray fluctuation distribution diagram.
[0160] Step S401.8: Further analyze the gray fluctuation distribution diagram, extract the features of the gray fluctuation curve and perform training.
[0161] Step S401.8 includes the following sub-steps:
[0162] Step S401.8.a: Obtain the maximum value of X of the gray fluctuation points in the gray fluctuation distribution diagram, and mark it as the gray fluctuation threshold.
[0163] Step S401.8.b: Mark the gray fluctuation points with the smallest and largest X in the gray fluctuation curve as the minimum fluctuation point and the maximum fluctuation point respectively.
[0164] Step S401.8.c: Connect the adjacent minimum fluctuation points by a smooth curve in ascending order of Y, and at the same time connect the adjacent maximum fluctuation points by a smooth curve to obtain the minimum closed curve and the maximum closed curve.
[0165] Step S401.8.d: Based on the minimum closed curve and the maximum closed curve, fill the area between any two gray-scale floating curves with gray, and repeat the operation until the area between any two gray-scale floating curves is gray, obtaining a gray area marked as the gray-scale floating area;
[0166] Step S401.8.e: Extract the graph of the gray-scale floating area. At this time, the gray-scale floating area and the gray-scale floating threshold are the features of the gray-scale floating curve;
[0167] Step S402: After the training is completed, use the defect recognition model to detect the appearance defects of the cable;
[0168] Step S402 includes the following sub-steps:
[0169] Step S402.1: After training the defect recognition model with the features of the gray-scale floating curve, when it is necessary to detect the appearance defects of the cable, obtain the contour image of the cable and mark it as the graph to be recognized;
[0170] Step S402.2: Based on the graph to be recognized, extract the gray-scale floating distribution map and the gray-scale floating curve of the graph to be recognized, and mark them as the distribution map to be recognized and the curve to be recognized respectively;
[0171] Step S402.3: Extract the maximum value of X of the coordinate points in the distribution map to be recognized, mark it as the maximum deviation value, compare the maximum deviation value with the gray-scale floating threshold. If the maximum deviation value is less than or equal to the gray-scale floating threshold, output a normal deviation signal; if the maximum deviation value is greater than the gray-scale floating threshold, output an abnormal deviation signal;
[0172] Step S402.4: Extract the curve to be recognized, mark the coordinate point with the smallest X in the curve to be recognized as the reference moving point, place the reference moving point in the minimum closed curve, and move the reference moving point in ascending order of Y. The curve to be recognized follows the reference moving point to move, and detect whether the curve to be recognized is entirely within the gray-scale floating area. If so, output a normal floating signal; if not, output a continue moving signal;
[0173] Step S402.5: If the continue moving signal is output, continue to move the reference moving point and make a judgment. If the normal floating signal is output, stop moving;
[0174] Step S402.6: Count the output signals. If the abnormal deviation signal is output or the normal floating signal is not output, mark that there are defects on the cable surface; if the normal deviation signal is output and the normal floating signal is output at the same time, mark that there are no defects on the cable surface.
[0175] Embodiment 3. The present application provides an electronic device, which may include: a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete mutual communication through the communication bus. The memory stores computer-readable instructions, and the processor can call the instructions in the memory. When the computer-readable instructions are executed by the processor, the steps in the cable production detection method based on machine vision are run to achieve the following functions: using a high-resolution camera to capture the appearance of the cable to obtain an appearance image; preprocessing the appearance image to obtain an appearance grayscale image after improving the image quality; extracting the edge information of the cable in the appearance grayscale image, and delimiting the contour image of the cable based on the edge information; extracting the appearance features of the contour image, performing feature analysis on the appearance features, and then training a defect recognition model to detect defects in the appearance of the cable.
[0176] In addition, when the logical instructions in the above-mentioned memory are implemented in the form of software functional units and sold or used as an independent product, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.
[0177] Embodiment 4. The present application also provides a computer-readable storage medium. The present application provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the cable production detection method based on machine vision described above are run to achieve the following functions: using a high-resolution camera to capture the appearance of the cable to obtain an appearance image; preprocessing the appearance image to obtain an appearance grayscale image after improving the image quality; extracting the edge information of the cable in the appearance grayscale image, and delimiting the contour image of the cable based on the edge information; extracting the appearance features of the contour image, performing feature analysis on the appearance features, and then training a defect recognition model to detect defects in the appearance of the cable.
[0178] Through the description of the above embodiments, the embodiments of the present invention can be provided as a method, a system or a computer program product. Based on such an understanding, the above technical solution, in essence or the part that contributes to the prior art, can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0179] In the embodiments provided in the present application, it should be understood that the disclosed system or method can be implemented in other ways. The above-described embodiments are only illustrative. For example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation. For another example, multiple modules or units can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection between each other can be through some communication interfaces. The indirect coupling or communication connection of systems, modules and units can be in electrical, mechanical or other forms.
[0180] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and are not intended to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A cable production detection method based on machine vision, characterized in that The steps are as follows: Use a high-resolution camera to take pictures of the appearance of the cable to obtain appearance images; Preprocess the appearance images to obtain appearance grayscale images after improving the image quality; Extract the edge information of the cable in the appearance grayscale image and delimit the contour image of the cable based on the edge information; Extract the appearance features of the contour image, perform feature analysis on the appearance features, analyze the gray level floating threshold and gray level floating area of the cable through sample cables, then train a defect recognition model and use the defect recognition model to detect defects in the appearance of the cable; Extract the appearance features of the contour image, perform feature analysis on the appearance features, analyze the gray level floating threshold and gray level floating area of the cable through sample cables, then train a defect recognition model and use the defect recognition model to detect defects in the appearance of the cable, which includes the following sub-steps: Screen the cables without appearance defects, mark them as sample cables, extract the appearance features of the sample cables and perform feature analysis, and train a defect recognition model; After training, use the defect recognition model to detect defects in the appearance of the cable; Screen the cables without appearance defects, mark them as sample cables, extract the appearance features of the sample cables and perform feature analysis, and train a defect recognition model, which includes the following sub-steps: Screen the sample cables without appearance defects for shooting, mark the contour images obtained by shooting and processing as sample images, obtain multiple groups of sample images, and integrate the sample images of the same cable into homologous images; For any homologous image, obtain the gray level value of the cable points in the homologous image and mark it as the single-point gray level value; Count the number of different single-point gray level values, mark it as the same-value number, find the maximum value in the same-value number, mark it as the maximum occupancy ratio, and obtain the single-point gray level value corresponding to the maximum occupancy ratio and mark it as the reference gray level value; Calculate the absolute value of the difference between the single-point gray level value except the reference gray level value and the reference gray level value, and mark it as the gray level difference; Count the number of different gray level differences, mark it as the difference number, establish a plane rectangular coordinate system with the gray level difference as the X-axis and the difference number as the Y-axis, name it the gray level floating distribution diagram, and enter the gray level difference and the corresponding difference number into the gray level floating distribution diagram; Mark the coordinate points in the gray level floating distribution diagram as gray level floating points, connect the gray level floating points adjacent to X through a smooth curve, and name the obtained curve the gray level floating curve; Analyze the remaining homologous images. Each group of homologous images can obtain a gray level floating curve, and draw all the gray level floating curves in the gray level floating distribution diagram; Further analyze the gray level floating distribution diagram, extract the features of the gray level floating curve and perform training; Further analyze the gray level floating distribution diagram, extract the features of the gray level floating curve and perform training, which includes the following sub-steps: Obtain the maximum value of X of the gray level floating points in the gray level floating distribution diagram and mark it as the gray level floating threshold; Mark the gray level floating points with the smallest and largest X in the gray level floating curve as the minimum floating point and the maximum floating point respectively; Connect adjacent minimum floating points with a smooth curve in ascending order of Y, and at the same time connect adjacent maximum floating points with a smooth curve to obtain a minimum closed curve and a maximum closed curve; Based on the minimum closed curve and the maximum closed curve, fill the area between any two gray floating curves with gray, and repeat the operation until the area between any two gray floating curves is gray, obtaining a gray area marked as the gray floating area; Extract the graph of the gray floating area. At this time, the gray floating area and the gray floating threshold are the characteristics of the gray floating curve.
2. The cable production detection method based on machine vision according to claim 1, wherein, Use a high-resolution camera to take pictures of the appearance of the cable. The steps to obtain the appearance image are as follows: Set up a support structure, on which a rolling device and two retractable rings are installed, named the first ring and the second ring in order from left to right; Pass the cable through the first ring and the second ring, and pass one end of the cable through the rolling device. Clamp the cable through the rolling device, and then control the first ring and the second ring to contract to clamp the cable; Take pictures of the cable.
3. The cable production detection method based on machine vision according to claim 2, characterized in that Taking pictures of the cable includes the following sub-steps: A high-resolution camera is arranged in the front of the midpoint between the first ring and the second ring to take pictures of the cable between the first ring and the second ring to obtain an appearance image; Loosen the rolling device, control the first ring and the second ring to rotate clockwise by 90° at the same time, and take pictures again. The same section of the cable needs to be rotated three times, and a total of four appearance images are obtained; The length of the cable in each taken appearance image is the first shooting length; Loosen the first ring and the second ring, and then control the rolling device to clamp the cable and roll. The rolling will drive the cable to move to the left; When the cable moves the first shooting length, stop rolling, and control the first ring and the second ring to contract, and take pictures of the appearance image again; Multiple groups of appearance images will be obtained for one cable.
4. The method for detecting cable production based on machine vision according to claim 3, wherein Preprocess the appearance image to obtain an appearance grayscale image after improving the image quality. The steps are as follows: Filter the appearance image by Gaussian filtering; After the processing is completed, perform grayscale processing on the image to obtain an appearance grayscale image.
5. The method for detecting cable production based on machine vision according to claim 4, wherein Extract the edge information of the cable in the appearance grayscale image. Based on the edge information, delimit the contour image of the cable. The steps are as follows: When taking pictures of the cable, a pure white baffle is set in the background. In the taken appearance image, except for the part of the cable, the rest are all pure white, and the grayscale values after grayscale processing are all 255; Eliminate the pixel points with a grayscale value of 255, and mark the remaining pixel points as cable points; The contour image is composed of cable points.
6. The cable production detection method based on machine vision according to claim 5, wherein, After the training is completed, use the defect recognition model to detect the appearance defects of the cable. The steps are as follows: After training the defect recognition model through the characteristics of the gray floating curve, when it is necessary to detect the appearance defects of the cable, obtain the contour image of the cable and mark it as the graph to be recognized; Based on the graph to be recognized, extract the gray floating distribution map and the gray floating curve of the graph to be recognized, and mark them as the distribution map to be recognized and the curve to be recognized respectively; Extract the maximum value of X of the coordinate points in the distribution map to be recognized, mark it as the maximum deviation value, compare the maximum deviation value with the gray-scale floating threshold. If the maximum deviation value is less than or equal to the gray-scale floating threshold, output a normal deviation signal; if the maximum deviation value is greater than the gray-scale floating threshold, output an abnormal deviation signal; Extract the curve to be recognized, mark the coordinate point with the smallest X in the curve to be recognized as the reference moving point, place the reference moving point in the smallest closed curve, move the reference moving point in ascending order of Y, and the curve to be recognized follows the reference moving point to move. Detect whether the curve to be recognized is entirely within the gray-scale floating area. If so, output a normal floating signal; if not, output a continue moving signal; If the continue moving signal is output, continue to move the reference moving point and make a judgment. If the normal floating signal is output, stop moving; Count the output signals. If an abnormal deviation signal is output or the normal floating signal is not output, mark that there are defects on the cable surface; If a normal deviation signal is output and at the same time a normal floating signal is output, mark that there are no defects on the cable surface.
7. A cable production detection system based on machine vision, which is used to implement the cable production detection method based on machine vision according to any one of claims 1-6, characterized in that, It includes an appearance photographing module, a preprocessing module, an appearance extraction module and a feature analysis module; the appearance photographing module, the preprocessing module and the appearance extraction module are respectively connected to the feature analysis module for data connection; The appearance photographing module is used to photograph the appearance of the cable using a high-resolution camera to obtain an appearance image; The preprocessing module is used to preprocess the appearance image to obtain an appearance gray-scale image after improving the image quality; The appearance extraction module is used to extract the edge information of the cable in the appearance gray-scale image and delimit the contour image of the cable based on the edge information; The feature analysis module is used to extract the appearance features of the contour image, perform feature analysis on the appearance features, analyze the gray-scale floating threshold and the gray-scale floating area of the cable through a sample cable, and then train a defect recognition model and detect the appearance of the cable through the defect recognition model.
Citation Information
Patent Citations
Cable sheath appearance defect detection device and method based on machine vision
CN117571714A
Surface defect detection method for guide rail based on image processing
CN118015000A