A detection method and device for pipe defects based on backlight images
Through the backlight image detection method and device, the problem of online detection of pipe flaring defects is solved, and accurate defect judgments of unflamed sections and flared sections are realized, which improves the reliability and accuracy of the detection and avoids system error processing.
Patent Information
- Application Number
- CN202211012259.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2022-04-28
- Filing Date
- 2022-08-23
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2042-08-23
AI Technical Summary
The prior art lacks the ability to measure the flaring size of the pipe and detect flaring defects online, resulting in the production of a large number of unqualified pipes and economic losses.
The detection method based on backlight image is adopted, and the pipe image is collected through the camera, the graphics data of the unflamed section and the flared section are calculated, and the defects are judged using edge search and template matching technology, and combined with photoelectric switch and push plate position detection to avoid system error processing.
Accurately judge the types and degrees of defects in the unflamed sections and flared sections of the pipe, improve detection accuracy, avoid system error processing, and ensure work reliability.
Smart Images

Figure CN115471455B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of detection technology, and particularly relates to a detection method and device for pipe defects based on backlight images. Background Art
[0002] Pipes generally refer to plastic pipes formed by hot pressing after mixing polyvinyl chloride resin with stabilizers, lubricants, etc. After the pipe is flared, it can be used to connect two pipes, eliminating the need for a transition pipe, greatly reducing production costs and construction costs. The flaring process of pipes generally involves inserting a high-temperature iron rod into one end of the pipe to achieve the effect of flaring the end of the pipe.
[0003] However, when connecting two pipes by flaring, there are extremely high requirements for the depth, width, angle, and quality of the flare. Once these indicators do not meet the requirements, problems will occur in the connection between the pipes, and the produced pipes will be unusable.
[0004] The flaring production line is prone to producing unqualified pipes due to problems such as incorrect setting of flaring equipment parameters and equipment abnormalities. Currently, there is a lack of a technology that can measure the flaring size of pipes online and detect flaring defects, resulting in the inability to detect pipe flaring abnormalities in a timely manner. This is likely to cause accidents where a large number of unqualified pipes are processed on the flaring production line, causing huge economic losses to the manufacturer. Summary of the Invention
[0005] To overcome the deficiencies and problems of the prior art, the present invention provides a detection method and device for pipe defects based on backlight images.
[0006] To achieve the above object, the present invention adopts the following technical solutions:
[0007] A detection method for pipe defects based on backlight images, comprising:
[0008] Collecting the pipe image captured by a camera under backlight as a backlight image;
[0009] Calculating the graphic data of the unflared section in the backlight image;
[0010] Judging whether the graphic data of the unflared section is within the range of safe unflared section graphic parameters. If not, it is determined that the pipe has defects;
[0011] Obtaining the flare contour on the backlight image through an edge search method, matching the flare contour with a first flare template to generate a matching displacement and a matching angle;
[0012] Performing position correction on the flare contour according to the matching displacement and the matching angle to obtain the backlight flare section area;
[0013] Generate flare section graphic data based on the backlight flare section area;
[0014] Determine whether the flare section graphic data is within the range of the safe flare section graphic parameters. If it is not, it is determined that the pipe has defects.
[0015] Preferably, the unflared section graphic data includes the pipe diameter of the unflared section of the pipe and the quantity of the pipes.
[0016] Preferably, the step of calculating the unflared section graphic data in the backlight image specifically includes:
[0017] Obtain the edge straight lines of the unflared section in the backlight image through an edge search method;
[0018] Determine the pipe diameter of the unflared section and the quantity of the pipes according to the edge straight lines of the unflared section.
[0019] Preferably, the flare section graphic data includes the depth, width, angle of the flare section, and the difference between the distance between the two ends of the flare section head and the width of the flare section.
[0020] Preferably, the range of the safe flare section graphic parameters includes the depth range, width range, angle range, and difference range of the safe flare section.
[0021] Preferably, the step of determining whether the flare section graphic data is within the range of the safe flare section graphic parameters. If it is not, it is determined that the pipe has defects specifically includes:
[0022] Determine whether the depth of the flare section is within the depth range of the safe flare section. If it is not, it is determined that the pipe has defects;
[0023] Determine whether the width of the flare section is within the width range of the safe flare section. If it is not, it is determined that the pipe has defects;
[0024] Determine whether the angle of the flare section is within the angle range of the safe flare section. If it is not, it is determined that the pipe has defects;
[0025] Determine whether the difference between the distance between the two ends of the flare section head and the width of the flare section is within the difference range of the safe flare section. If it is not, it is determined that the pipe has defects.
[0026] Preferably, the step of generating the flare section graphic data based on the backlight flare section area specifically includes:
[0027] Generate the edge straight lines of the flare section by using a straight line fitting method for the backlight flare section area;
[0028] Match the second flare template on the backlight flare section area and generate matching point information;
[0029] Generate the flaring section graphic data based on the straight line of the flaring section edge and the matching point information.
[0030] Preferably, it further includes:
[0031] If the non-flaring section graphic data is within the safe non-flaring section graphic parameter range and the flaring section graphic data is within the safe flaring section graphic parameter range, it is determined that the pipe has no defects.
[0032] Preferably, the edge finding method specifically includes:
[0033] Divide the backlight image into several sub-regions;
[0034] Perform edge point extraction processing on each sub-region in the direction from white pixel points to black pixel points;
[0035] Successively store the edge points with different horizontal coordinate components extracted in the first group into different edge point sets;
[0036] Successively compare the edge points extracted in the remaining groups with the edge points extracted in the first group, and put the edge points that meet the condition that the absolute value of the difference in the horizontal coordinate components of the corresponding edge points between the two groups is less than the set threshold into the corresponding edge point sets established in the previous step. Each edge point set is the left edge information of each pipe.
[0037] Preferably, before the step of taking the image of the pipe captured by the camera under backlight as the backlight image, the following steps are further included:
[0038] Convey the pipe to above the background board through the push plate, and the camera takes an image of the pipe above the background board.
[0039] Preferably, the step of collecting the image of the pipe captured by the camera under backlight as the backlight image further includes the following steps:
[0040] Judge whether the current spatio-temporal parameters of the push plate meet the expected spatio-temporal parameters. If they meet, collect the image of the pipe captured by the camera under backlight as the backlight image. If they do not meet, do not collect the image of the pipe captured by the camera under front light as the front light image and the image of the pipe captured by the camera under backlight as the backlight image.
[0041] Preferably, when judging whether the current spatio-temporal parameters of the push plate meet the expected spatio-temporal parameters, the following steps are further included:
[0042] Set the trigger area;
[0043] Judge whether the current position of the push plate is within the trigger area. If it is not, do not take the backlight image.
[0044] Preferably, when the current position of the push plate is within the trigger area, further, the following steps are further included:
[0045] The processor collects the mis-trigger time;
[0046] The processor determines whether the mis-trigger time collected by the processor is less than the first preset time. If it is less, the backlight image is not collected.
[0047] Preferably, when the mis-trigger time is not less than the first preset time, further, the following steps are further included:
[0048] The processor collects the delay trigger time;
[0049] The processor determines whether the collected delay trigger time is less than the second preset time. If it is less, the backlight image is not collected.
[0050] Preferably, the step of determining whether the current spatio-temporal parameters of the push plate conform to the expected spatio-temporal parameters further includes the following steps:
[0051] The processor collects the trigger interval time;
[0052] The processor determines whether the collected trigger interval time is less than the third preset time. If it is less, the backlight image is not collected.
[0053] Preferably, in the step of collecting the pipe image captured by the camera under the backlight as the backlight image, specifically includes:
[0054] If the current position of the push plate is within the trigger area, the mis-trigger time is not less than the first preset time, the delay trigger time is not less than the second preset time, and the trigger interval time is not less than the third preset time, then the pipe image captured by the camera under the backlight is collected as the backlight image.
[0055] Preferably, when collecting the pipe image captured by the camera under the backlight as the backlight image, further includes the following steps:
[0056] The processor obtains the contour of the push plate in the backlight image;
[0057] The processor compares the contour of the push plate and the standard contour of the push plate to generate a matching degree;
[0058] The processor determines whether the matching degree is not greater than the safety matching degree. If it is not greater, the processor determines that the pipe is in an abnormal position,
[0059] If it is greater, the processor obtains the matching angle of the current push plate contour according to the push plate contour and the standard push plate contour;
[0060] The processor determines whether the matching angle is less than the safe matching angle. If it is not less than, the processor determines that the pipe is in an abnormal position. If it is less than, the processor determines that the pipe is in a normal position.
[0061] Preferably, when the backlight image is acquired, the following steps are further included:
[0062] Perform distortion correction processing on the backlight image.
[0063] Preferably, the step of performing distortion correction processing on the backlight image specifically includes:
[0064] Acquire the calibration plate image;
[0065] Perform distortion correction on the calibration plate image and generate a distortion calibration file;
[0066] Perform distortion correction on the backlight image according to the distortion calibration file.
[0067] The present invention also provides a detection device for pipe defects based on a backlight image, which is implemented by using the above-mentioned detection method for pipe defects based on a backlight image, and includes:
[0068] A light source, which is used to shine light on the back of the pipe as backlight;
[0069] A camera, which is used to capture an image on the front of the pipe;
[0070] A processor, which is used to acquire the pipe image captured by the camera under backlight as a backlight image, calculate the graphic data of the non-flared section in the backlight image. If the graphic data of the non-flared section is not within the range of the safe non-flared section graphic parameters, it is determined that the pipe has a defect. The flare contour is obtained on the backlight image by the edge search method, the flare contour is matched with the first flare template, the matching displacement and matching angle are generated, the position of the flare contour is corrected according to the matching displacement and matching angle to obtain the backlight flare section area, and the flare section graphic data is generated according to the backlight flare section area. If the flare section graphic data is not within the range of the safe flare section graphic parameters, it is determined that the pipe has a defect.
[0071] Preferably, the light source includes a backlight source, and the backlight source is used to shine light on the back of the pipe as backlight.
[0072] Preferably, a background board is further included, which is used as the background in the pipe image captured by the camera
[0073] Preferably, the background board is white and light-transmissive.
[0074] Preferably, a push plate is further included, which is used to convey the pipe above the background board.
[0075] Preferably, the push plate can slide horizontally above the background plate.
[0076] Preferably, it further includes a photoelectric switch for detecting the position of the push plate.
[0077] Preferably, the triggering area of the photoelectric switch is located above the background plate.
[0078] Preferably, the camera is arranged above the background plate, and the backlight source is arranged below the background plate.
[0079] The prominent and beneficial technical effects of the present invention compared with the prior art are:
[0080] (1) In the present invention, based on the backlight images of the unflared section and the flared section of the pipe, the unflared section graphic data and the flared section graphic data can be generated. According to the unflared section graphic data, the defect types and defect degrees of the unflared section can be accurately judged, and according to the flared section graphic data and combined with the data obtained from the unflared section, the defect types and defect degrees of the flared section can be accurately judged.
[0081] (2) In the present invention, the backlight image is used to generate the flared section graphic data. The backlight image has the characteristic of clear contour, which improves the accuracy of the flared section graphic data detection.
[0082] (3) In the present invention, by setting the mis-triggering time, delay triggering time and interval triggering time of the photoelectric switch, and setting the position detection of the push plate, the possible system misprocessing during the feeding process can be avoided. Therefore, the present invention has the advantage of reliable operation. Description of the Drawings
[0083] Figure 1 is a schematic flow chart of the steps of the method for detecting pipe defects based on backlight images of the present invention;
[0084] Figures 2-1 to 2-8 is a schematic diagram of the physical objects of the defect types of each pipe of the present invention;
[0085] Figures 3-1 to 3-8 is a schematic diagram of the front light image of the defect types of each pipe of the present invention;
[0086] Figures 4-1 to 4-7 is a schematic diagram of the backlight image of the defect types of each pipe of the present invention;
[0087] Figure 5 is a schematic structural diagram of the device for detecting pipe defects based on backlight images of the present invention;
[0088] Figure 6 is a schematic structural diagram of the present invention applied with the device for detecting pipe defects based on backlight images;
[0089] Figure 7 It is a schematic flow chart of the steps for detecting the position of the pushing plate in the present invention;
[0090] Figure 8 It is a schematic flow chart of the steps for detecting the non-flared section of the pipe in the present invention;
[0091] Figure 9 It is a schematic flow chart of the steps for the edge finding method in the present invention;
[0092] Figure 10 It is a schematic flow chart of the steps for the edge point processing method in the present invention;
[0093] Figure 11 It is a schematic flow chart of the steps for the straight line fitting method in the present invention;
[0094] Figure 12 It is a schematic flow chart of the steps for detecting under normal light in the present invention;
[0095] Figure 13 It is a schematic flow chart of the steps for detecting under backlight in the present invention;
[0096] In the figure: 1 - background board, 2 - pushing plate, 3 - front light source, 4 - back light source, 5 - camera, 6 - processor, 7 - photoelectric switch, 8 - pipe, 81 - flared section, 82 - non-flared section. Detailed implementation manners
[0097] For the convenience of those skilled in the art to understand, the present invention will be further described below in conjunction with the accompanying drawings and specific embodiments.
[0098] For the convenience of those skilled in the art to understand, the present invention will be further described below in conjunction with the accompanying drawings and specific embodiments.
[0099] It should be noted that when the pipe is processed through the flaring production line, a flared section is formed at the end of the pipe. The flared section can be used to insert the root of another pipe, so as to connect the two pipes together, avoiding the use of a transition pipe to connect the two pipes. The design of the flared section greatly reduces the costs in aspects such as production, assembly, and construction. The pipe after being processed through the flaring production line also includes a non-flared section, and the non-flared section and the flared section are connected in sequence.
[0100] As Figures 2-1 to 2-8 shown, according to the feedback from the pipe manufacturer and the on-site investigation of the flaring production line, it is found that the defect types of pipe flaring include: (1) Figure 2-1 , the end of the flared section of the pipe shows abnormal protrusion or bending; (2) Figure 2-2 in, the surface of the flared section of the pipe is scalded and damaged; (3) Figure 2-3 in, the depth of the flared section of the pipe is not within the tolerance range, and there are problems of being too short or too long in depth; (4)Figure 2-4 In (5), the pipe is not flared; Figure 2-5 In (6), the front end face of the flared section of the pipe is uneven, and the uneven end face includes concave, convex, and irregular shapes; Figure 2-6 In (7), the flared section of the pipe shows a retracted condition; Figure 2-7 In (8), the pipe is not flared and the pipe body is flattened. Figure 2-8 In, the flared section of the pipe has obvious color difference and uneven surface color defects.
[0101] In order to detect defects in the flared pipe and sort out the pipes with defects, such as Figure 1 As shown, this embodiment provides a method for detecting pipe defects based on backlight images, which is implemented using a device for detecting pipe defects based on backlight images provided by the present invention, and includes the following steps:
[0102] S1: Transport the pipe to above the background board through a push plate;
[0103] S2: Determine whether the current spatio-temporal parameters of the push plate meet the expected spatio-temporal parameters. If they meet, collect the pipe image captured by the camera under positive light as the positive light image and the pipe image captured by the camera under backlight as the backlight image; if they do not meet, do not collect the pipe image captured by the camera under positive light as the positive light image and the pipe image captured by the camera under backlight as the backlight image;
[0104] S3: Perform distortion correction processing on the positive light image and the backlight image;
[0105] S4: Calculate the graphic data of the non-flared section in the backlight image;
[0106] S5: Determine whether the graphic data of the non-flared section is within the range of the safe non-flared section graphic parameters. If it is not within the range, it is determined that the pipe has defects;
[0107] S6: Obtain the flared contour on the backlight image through an edge search method, match the flared contour with the first flared template, and generate a matching displacement and a matching angle;
[0108] S7: Perform position correction on the flared contour according to the matching displacement and the matching angle to obtain the backlight flared section area, perform position correction on the positive light image according to the matching displacement and the matching angle, and obtain the positive light flared section graphic in the position-corrected positive light image according to the backlight flared section area;
[0109] S8: Generate the flared section graphic data according to the backlight flared section area and the positive light flared section graphic;
[0110] S9: Determine whether the flared section graphic data is within the range of the safe flared section graphic parameters. If it is not within the range, it is determined that the pipe has defects.
[0111] In the present invention, based on the images of the unflared section and the flared section of the pipe, the unflared section graphic data and the flared section graphic data can be generated. According to the unflared section graphic data, the types and degrees of defects in the unflared section can be accurately judged, and according to the flared section graphic data and the data obtained from the unflared section, the types and degrees of defects in the flared section can be accurately judged.
[0112] In the present invention, the positive light image and the backlight image are jointly used to generate the flared section graphic data. The positive light image has clear color expression but unclear contour, and the backlight image has clear contour but cannot display the surface information of the pipe. By combining the above images and utilizing their respective advantages to generate the flared section graphic data, the accuracy of the flared section graphic data detection is improved.
[0113] In the present invention, distortion correction processing is performed on the positive light image and the backlight image, thereby eliminating the distortion caused by the imaging system of the camera and improving the image restoration degree.
[0114] In the above step of transporting the pipe to the upper part of the background board by the push plate, the processor can control the motor to drive the push plate to transport the pipe to the upper part of the background board. When the push plate transports the pipe to the upper part of the background board and the push plate is also located above the background board, the camera can capture an image with the pipe and the push plate.
[0115] When judging whether the current spatio-temporal parameters of the push plate conform to the expected spatio-temporal parameters, the following steps are further included:
[0116] Set the trigger area;
[0117] Judge whether the current position of the push plate is within the trigger area. If not, the positive light image and the backlight image are not collected.
[0118] Among them, the current spatio-temporal parameters of the push plate include the current position of the push plate, and the expected spatio-temporal parameters include the trigger area. The trigger area is the sensing area of the photoelectric switch. The trigger area is set above the background board by the photoelectric switch. The processor is electrically connected to the photoelectric switch, and data communication can be carried out between the photoelectric switch and the processor. When the current position of the push plate is not within the trigger area, the push plate has not transported the pipe to the upper part of the background board, the photoelectric switch does not generate a trigger signal, and the processor does not receive the trigger signal of the photoelectric switch. When the processor does not receive the trigger signal, the images captured by the camera are not collected as the positive light image and the backlight image. The trigger signal refers to the part with an edge jump in the level signal generated by the photoelectric switch.
[0119] When the current position of the push plate is within the trigger area, further, the following steps are included:
[0120] The processor collects the mis-trigger time;
[0121] The processor determines whether the mis-trigger time collected by the processor is less than a first preset time. If it is less, the front light image and the backlight image are not collected.
[0122] Among them, the current spatio-temporal parameters of the push plate include the mis-trigger time, and the expected spatio-temporal parameters include the first preset time. Since when the push plate just triggers the photoelectric switch, the push plate is very likely not to be stable above the background plate. In order to let the camera capture the push plate when it is stable, the processor needs to determine whether the mis-trigger time is less than the first preset time. The mis-trigger time refers to the time that the trigger signal remains when the photoelectric switch is triggered, and the time that the trigger signal remains is the mis-trigger time. The first preset time refers to the minimum reasonable time required for the push plate to be stable when the photoelectric switch is triggered, and the first preset time can be preset in the processor. In actual use, if the current position of the push plate is within the trigger area, the photoelectric switch generates a trigger signal. If the processor receives the trigger signal, the time that the trigger signal remains is collected as the mis-trigger time. If the mis-trigger time collected by the processor is less than the first preset time, the push plate is very likely not to be stable above the background plate, and the processor does not collect the front light image and the backlight image. If the mis-trigger time is not less than the first preset time, the push plate has been stable above the background plate.
[0123] If the mis-trigger time is not less than the first preset time, further, the following steps are also included:
[0124] The processor collects the delay trigger time;
[0125] The processor determines whether the collected delay trigger time is less than a second preset time. If it is less, the backlight image and the front light image are not collected.
[0126] Among them, the current spatio-temporal parameters of the push plate include the delay trigger time, and the expected spatio-temporal parameters include the second preset time. Since the pipe may still not be stable above the background plate after the push plate stops stably above the background plate, in order to avoid collecting the image of the pipe when it is not stable as the backlight image, the processor needs to judge whether the delay trigger time is less than the second preset time. The delay trigger time refers to the time that the trigger signal remains after the mis-trigger time reaches the first preset time, and the difference between the time that the trigger signal remains and the first preset time is the delay trigger time. The second preset time refers to the minimum reasonable time required for the pipe to stop stably above the background plate after the push plate stops stably above the background plate, and the second preset time can be preset in the processor. In actual use, when the mis-trigger time reaches the first preset time, the processor collects the delay trigger time, and the processor judges whether the collected delay trigger time is less than the second preset time. If the delay trigger time is less than the second preset time, at this time, the pipe is very likely not to be stable above the background plate, and the processor does not collect the image captured by the camera as the backlight image. If the delay trigger time is not less than the second preset time, then the pipe has stopped stably above the background plate.
[0127] In addition, the judgment of whether the current spatio-temporal parameters of the push plate meet the expected spatio-temporal parameters further includes the following steps:
[0128] The processor collects the trigger interval time;
[0129] The processor judges whether the collected trigger interval time is less than the third preset time. If it is less than, the backlight image and the front light image are not collected.
[0130] Among them, the current spatio-temporal parameters of the push plate include the trigger interval time, and the expected spatio-temporal parameters include the third preset time. Since after the system finishes detecting a batch of pipes, the pipes of this batch need to be bundled after being unloaded, and after the pipes of this batch are bundled, the next batch of pipes will be loaded. Therefore, the system needs to leave enough bundling time between the unloading of the previous batch of pipes and the loading of the next batch of pipes. The loading of the pipes refers to the pipes being transported above the background board, and the unloading of the pipes refers to unloading the pipes from above the background board. In order to enable the system to leave enough bundling time between the unloading of the previous batch of pipes and the loading of the next batch of pipes, the processor needs to determine whether the trigger interval time is less than the third preset time. The trigger interval time refers to the time interval between the previous triggering of the photoelectric switch and the next triggering of the photoelectric switch, corresponding to the time interval between the unloading of the previous batch of pipes and the loading of the next batch of pipes. The third preset time refers to the minimum reasonable time interval between the unloading and bundling of the previous batch of pipes and the loading of the next batch of pipes, and the third preset time can be preset in the processor in advance. In actual use, when the previous batch of pipes is unloaded and the next batch of pipes is loaded, the processor collects the trigger interval time. If the trigger interval time collected by the processor is less than the third preset time, it is very likely that the detected pipes have not been unloaded or bundled in time. At this time, the processor does not collect the backlight image and the front light image, that is, the system does not detect the next batch of pipes, avoiding the problem of detecting the next batch of pipes before the previous batch of pipes is bundled or the pipes not being unloaded in time. If the trigger interval time collected by the processor is not less than the third preset time, the previous batch of pipes has been unloaded and bundled.
[0131] In addition, when determining whether the current spatio-temporal parameters of the push plate meet the expected spatio-temporal parameters, the following steps are also included:
[0132] The processor calculates the front light duration;
[0133] The processor determines whether the calculated front light duration is less than the safety time. If it is less, the front light image is not collected.
[0134] Among them, the current space-time parameters of the push plate include the positive light duration, and the expected space-time parameters include the safety time. Since there are problems with the unstable light intensity when the backlight source is just turned off and the front light source is just turned on, in order to avoid the problem of unstable light intensity affecting the image captured by the camera, the processor needs to determine whether the positive light duration is less than the safety time. The positive light duration refers to the time when the front light source is turned on and the backlight source is turned off. The safety time refers to the minimum reasonable time required for the light intensity to become stable after the front light source is turned on and the backlight source is turned off, and the safety time can be preset in the processor. In actual use, the processor first controls the front light source to turn on and the backlight source to turn off, and then calculates the positive light duration based on the time when the front light source is turned on and the backlight source is turned off. If the positive light duration calculated by the processor is not less than the safety time, the light intensities of the front light source and the backlight source become stable. If the positive light duration calculated by the processor is less than the safety time, the light intensities of the front light source and the backlight source are unstable. At this time, the processor does not collect the positive light image to avoid collecting an image affected by the unstable light intensities of the front light source and the backlight source.
[0135] In this embodiment, both the front light source and the backlight source use white-light LED lights, and the safety time is 10 ms.
[0136] In this embodiment, the processor first collects the backlight image and then the positive light image. When the push plate conveys the pipe to above the background board, the processor controls the backlight source to be in the on state and the positive light source to be in the off state.
[0137] In summary, in the step of collecting the pipe image captured by the camera under backlight as the backlight image, it specifically includes:
[0138] If the current position of the push plate is within the trigger area, the mis-trigger time is not less than the first preset time, the delay trigger time is not less than the second preset time, and the trigger interval time is not less than the third preset time, then collect the pipe image captured by the camera under backlight as the backlight image.
[0139] When the processor finishes collecting the pipe image captured by the camera as the backlight image, it controls the backlight source to turn off and the front light source to turn on. When the backlight source is turned off and the front light source is turned on, the processor proceeds to the step of collecting the pipe image captured by the camera under positive light as the positive light image.
[0140] In summary, in the step of collecting the pipe image captured by the camera under positive light as the positive light image, it specifically includes:
[0141] If the current position of the push plate is within the triggering area, the mis-triggering time is not less than the first preset time, the delay triggering time is not less than the second preset time, the triggering interval time is not less than the third preset time, and the positive light duration is not less than the safety time, then the pipe image captured by the camera under positive light is collected as the positive light image.
[0142] In the present invention, by setting the mis-triggering time, delay triggering time, and interval triggering time of the photoelectric switch, and by detecting the position of the push plate and the positive light duration, the system misprocessing that may occur during the feeding process is avoided. Therefore, the present invention has the advantage of reliable operation.
[0143] As Figures 3-1 to 3-8 shown, the positive light image refers to the image of the pipe captured by the camera when the front light source is on and the back light source is off. The image captured under positive light alone can clearly show the surface information such as the color and texture of the foreground, but it is not easy to distinguish the outline of the foreground. The surface information of the foreground in the positive light image can be used to detect whether there are defects such as hot breakage and color difference on the surface of the pipe.
[0144] As Figures 4-1 to 4-7 shown, the backlight image refers to the image of the pipe captured when the front light source is off and the back light source is on. The backlight image captured under backlight alone can clearly show the outline of the foreground. The outline of the foreground in the backlight image can be used to detect whether the size of the pipe exceeds the tolerance, whether the end face is deformed, and whether there is retraction and other defects.
[0145] The foreground in this embodiment includes the pipe and the push plate. The background includes the background board. In order to better distinguish the foreground and background from the positive light image and the backlight image. The background board is a translucent white, the front light source and the back light source both emit white light, the front light source is fixed above the background board, the back light source is fixed below the background board, and the camera is fixed above the background board so that the camera can use the background board as the background every time it takes a picture. The pipe and the push plate are not white and have a large color difference from the background board. Specifically, the color of the pipe includes red, yellow, green, and blue, and the color of the push plate includes black, so that the camera can capture an image with a greater difference between the foreground and the background.
[0146] As Figure 7 shown, after the step of the processor collecting the pipe image captured by the camera under backlight as the backlight image, in order to ensure the accuracy of the position of the pipe transported above the background board, it can be judged by detecting whether the position of the push plate is accurate after the pipe is transported above the background board. Specifically, when the pipe image captured by the camera under backlight is collected as the backlight image, the following steps are further included:
[0147] The processor obtains the outline of the push plate in the backlight image;
[0148] The processor generates a matching degree by comparing the pusher profile and the standard pusher profile;
[0149] The processor determines whether the matching degree is not greater than the safety matching degree. If it is not greater, the processor determines that the pipe is in an abnormal position.
[0150] If it is greater, the processor obtains the matching angle of the current pusher profile according to the pusher profile and the standard pusher profile.
[0151] The processor determines whether the matching angle is less than the safety matching angle. If it is not less, the processor determines that the pipe is in an abnormal position. If it is less, the processor determines that the pipe is in a normal position.
[0152] Among them, when the processor obtains the pusher profile in the backlight image, it means that the processor first processes the backlight image into a grayscale image, and then obtains the pusher profile in the grayscale image. In the grayscale image converted from the backlight image, the background is white, the pusher, as the foreground in the backlight image, is black, and the junction between the pusher and the background gradually changes from black to white. In order to obtain an accurate pusher profile in the grayscale image, the edge of the pusher is obtained in the grayscale image through an edge search method, and then the edge of the pusher is processed through edge point processing to obtain the pusher profile.
[0153] Since there is a problem that the pusher profile obtained by the processor may not be the pusher when the processor uses the edge straight line search method to obtain the pusher profile in the backlight image, the processor determines whether the matching degree is not greater than the safety matching degree and determines whether the matching angle is not less than the safety matching angle. The matching degree refers to the similarity between the shape of the pusher profile and the shape of the standard pusher profile. The safety matching degree refers to the minimum value allowed for the matching degree, and the safety matching degree can be preset in the processor. The standard pusher profile refers to the profile indicating the pusher in the backlight image collected when the pusher accurately conveys the pipe above the background plate during normal use, and the standard pusher profile can be preset in the processor. In actual use, if the matching degree is not greater than the safety matching degree, it proves that the foreground indicated by the pusher profile is unlikely to be the pusher or the pusher has a large offset, and thus it is determined that the pipe is in an abnormal position; if the matching degree is greater than the safety matching degree, it proves that the shape of the pusher profile and the shape of the standard pusher profile are more similar; if the matching degree is greater than the safety matching degree, it proves that the foreground indicated by the pusher profile is basically the pusher. Therefore, the processor determines that the pusher profile is the pusher, and then executes the step of the processor obtaining the matching angle according to the pusher profile and the standard pusher profile. And.
[0154] Since the processor needs to verify whether the push plate in the backlight image is offset, it needs to determine whether the matching angle is less than the safe matching angle. The matching angle refers to the degree of coincidence between the position of the push plate contour and the position of the standard push plate contour. The safe matching angle refers to the maximum value allowed for the matching angle, and the safe matching angle can be preset in the processor. If the matching angle is not less than the safe matching angle, the push plate has a significant position offset, and the processor determines that the push plate is in an abnormal position. When it is determined that the push plate is in an abnormal position, the processor aborts the defect detection of the pipe and triggers an alarm, thereby reminding the user to handle the problem and avoiding affecting subsequent detections. The smaller the matching angle is compared with the safe matching angle, the closer the position of the push plate contour is to the position of the standard push plate contour. If the matching angle is less than the safe matching angle, the processor determines that the push plate is in a normal position, the push plate has not undergone a position offset or has only undergone a minor position offset, and further the processor determines that the pipe is in a normal position. If the processor determines that the pipe is accurately conveyed above the background plate, distortion correction processing is performed on the front light image and the backlight image.
[0155] In the step of the processor performing distortion correction processing on the front light image and the backlight image, due to the influence of the imaging system of the camera, the captured images have image distortion. The distortion of the front light image and the backlight image includes radial distortion and perspective distortion. In order to improve the accuracy of subsequent graphic data detection of the flared section of the pipe, it is necessary to eliminate the above-mentioned image distortion.
[0156] In this embodiment, the step of performing distortion correction processing on the front light image and the backlight image specifically includes:
[0157] The processor acquires the image of the calibration plate placed above the background plate captured by the camera as the calibration plate image;
[0158] The processor performs distortion correction on the calibration plate image and generates a distortion calibration file;
[0159] The processor performs distortion correction on the front light image and the backlight image according to the distortion calibration file.
[0160] Among them, the height of the calibration plate above the background plate is the same as the height of the pipe above the background plate, so as to avoid errors caused by different heights of the calibration plate and the pipe. The processor performing distortion correction on the calibration plate image means that the processor adjusts the horizontal and vertical spacings between the individual checkerboards in the calibration plate image to be basically the same. In the distortion-corrected calibration plate image, the horizontal and vertical spacings between its individual checkerboards are basically the same, and the ratio of the pixel spacing of each checkerboard to the actual physical spacing of the checkerboard is generated, and this ratio is the distortion calibration file. The processor performs distortion correction on the front light image and the backlight image according to the distortion calibration file, thereby obtaining the front light image and the backlight image with eliminated distortion.
[0161] Before the pipe is processed by the flaring production line, there may be defects in the pipe itself. The defects include that its own pipe diameter exceeds the dimensional tolerance. In order to detect such defects, the processor calculates the graphic data of the unflared section in the backlight image, and then determines whether the graphic data of the unflared section is within the range of safe unflared graphic parameters. In this step, the graphic data of the unflared section refers to the graphic data used to indicate the unflared section of the pipe in the backlight image. The unflared graphic data includes the pipe diameter of the unflared section of the pipe and the quantity of the pipes. The range of safe unflared section graphic parameters includes the dimensional tolerance of this type of pipe and the range where the quantity is greater than 0. By determining whether the graphic data of the unflared section is within the range of safe unflared graphic parameters, the processor can determine whether there are dimensional defects in the pipe in the backlight image before flaring and whether there are pipes, so as to reject the defective products of this part and determine whether there are pipes to be detected in this system.
[0162] As Figure 8 shown, the steps for the processor to calculate the graphic data of the unflared section in the backlight image, determine whether the graphic data of the unflared section is within the range of safe unflared section graphic parameters, and if not, determine that the pipe has defects specifically include:
[0163] The processor obtains the edge straight lines of the unflared section in the backlight image through an edge detection method;
[0164] The processor determines the pipe diameter and the quantity of the pipes according to the edge straight lines of the unflared section;
[0165] The processor determines that the quantity of the pipes is 0. If it is 0, it determines that the pipe triggers an alarm;
[0166] The processor determines whether the pipe diameter of the unflared section is not within the dimensional tolerance of the pipe. If not, it triggers an alarm.
[0167] The distance between adjacent edge straight lines of the unflared section is the pipe diameter of the unflared section. The processor calculates the distance between the edge straight lines of the unflared section to determine the pipe diameter of the unflared section. The number of edge straight lines of the unflared section is twice the quantity of the pipes. The processor calculates the number of edge straight lines of the unflared section to determine the quantity of the pipes. Since the quantity of the pipes is a natural number, the processor determines whether there are pipes in the backlight image by determining whether the quantity of the pipes is 0, and then determines whether to trigger an alarm. Since there is a dimensional tolerance for the pipes in the backlight image, the dimensional tolerance can be preset in the processor. The processor determines whether the pipe diameter of the unflared section is not within the dimensional tolerance to determine whether there are defects in the pipes in the backlight image, and then determines whether to trigger an alarm.
[0168] In this embodiment, the pipe graphics in the backlight image are vertical, and the unflared section in the pipe graphics is located in the lower half of the pipe graphics. The processor determines the number of pipes by detecting the number of edge lines of the unflared section in the backlight image, and determines the pipe diameter of the unflared section by detecting the spacing between the edge lines of the unflared section in the backlight image. Thus, this method can perform defect detection on multiple pipes at one time.
[0169] To eliminate the interference of other contours in the backlight image, the length of the edge lines of the unflared section to be searched is constrained, and it is required to be not less than a certain threshold. For example, this threshold can be 500 pixel lengths. The processor determines whether the length of the obtained edge line is not less than 500 pixels. If it is not less than, it determines that the edge line is the edge line of the unflared section. If it is less than, it determines that the edge line is not the edge line of the unflared section.
[0170] Since the backlight image is taken with the backlight source turned on and the front light source turned off, the graphics indicating the unflared section in the backlight image are black, and the graphics indicating the background board are also black. Therefore, the edge search method is used to obtain the edge lines of the unflared section in the order from black to white and from white to black. Among them, the number of edge lines of the unflared section obtained in the order from white to black is used to determine the number of pipes, and the edge lines of the unflared section obtained in the order from white to black and from black to white can be used to determine the pipe diameter.
[0171] If the number of pipes is 0, the alarm is triggered to prompt the user that there are no pipes in this detection. The system records this detection and waits for the next batch of pipes to be loaded. If the number of pipes is not 0, the alarm is not triggered and the system remains in normal operation. If the pipe diameter of the unflared section is not within the dimensional tolerance of the pipe, the processor triggers the alarm to prompt the user that there are problems such as pipes of other models being mixed in during this detection or the quality of the pipes themselves being defective. If the pipe diameter of the unflared section is within the dimensional tolerance of the pipe, the alarm is not triggered and the system proceeds to the next step.
[0172] The above system proceeding to the next step specifically means that the processor obtains the flared contour in the backlight image.
[0173] Among them, the flared contour refers to the contour of the flared section graphics in the backlight image. The processor can obtain the flared contour on the backlight image through the edge search method.
[0174] As Figure 9 shown, in this embodiment, the edge search method specifically includes the following steps:
[0175] Divide the backlight image into several sub-regions;
[0176] For each sub-region, perform edge point extraction in the direction from white pixel points to black pixel points;
[0177] Successively store the edge points with different horizontal coordinate components extracted in the first group into different edge point sets;
[0178] Successively compare the edge points extracted in the remaining groups with the edge points extracted in the first group, and put the edge points that meet the condition that the absolute value of the difference in the horizontal coordinate components of the corresponding edge points between the two groups is less than the set threshold into the corresponding edge point sets established in the previous step. Each edge point set is the left edge information of each pipe, and the horizontal coordinate is the X-axis.
[0179] According to the above steps, edge search can also be performed on the push plate and the unflared section in the backlight image.
[0180] Such as Figure 10 shown, the method for edge point processing specifically includes the following steps:
[0181] Perform projection processing on the sub-region to generate projection lines, calculate the average concentration of each projection line, and obtain the projection line average concentration waveform;
[0182] Perform differential processing on the projection line average concentration waveform to obtain a differential waveform;
[0183] Filter the differential waveform to filter out peaks smaller than the set threshold;
[0184] Find the projection waveform points corresponding to each peak in the filtered differential waveform, and then find the corresponding sub-regions in the detection area according to each projection waveform point. The number of rows of each sub-region is the same as the number of rows of the detection area, and the number of columns is 2;
[0185] Traverse each row of each sub-region in ascending order of the vertical coordinate, compare the two columns in each row, and the row corresponding to the largest absolute value of the difference is the vertical coordinate of the required edge point. The horizontal coordinate of the required edge point is the average value of the horizontal coordinate components corresponding to the two columns of the sub-region, and the vertical coordinate is the Y-axis.
[0186] In the above, the projection processing refers to vertical scanning relative to the detection direction.
[0187] In this embodiment, in order to improve the contrast between the pipes and the background on the backlight image, the following steps are also included:
[0188] Perform sharpening processing and exclusive OR operation processing on the backlight image.
[0189] Among them, the processor sharpens the backlight image to increase the clarity of its edges, making the transition band at the contour edge narrower, thereby enhancing the contrast of the backlight image. In addition, since there are more than two pipes that are close to or even in contact with each other, through the sharpening process, the edges of the above-mentioned close pipes can be separated, facilitating the extraction of the flaring contours of the close pipes respectively. Then, an exclusive OR operation is performed on the sharpened backlight image and the original image to further improve the contrast between the pipe edge and the background. The background image after the exclusive OR operation can be used to obtain the edge straight line or flaring contour of the unflared section or the edge straight line of the unflared section and the flaring contour on the backlight image.
[0190] When the processor obtains the flaring contour, it matches the flaring contour with the first flaring template and generates a matching displacement and a matching angle.
[0191] Among them, the first flaring template can be preset in the processor. Since the flaring widths of pipes of the same model vary little, the same first flaring template can be used for matching.
[0192] When the processor generates a matching displacement and a matching angle, the processor corrects the position of the flaring contour according to the matching displacement and the matching angle and obtains the backlight flared section area.
[0193] Among them, the processor corrects the position of the flaring contour according to the matching position and the matching angle means that the processor rotates and translates the flaring contour according to the matching displacement and the matching angle, so as to adjust and set the flaring contour at the position where the backlight flared section area can be obtained.
[0194] When the processor generates the backlight flared section area, the matching displacement and the matching angle, the processor corrects the position of the front light image according to the matching displacement and the matching angle.
[0195] Among them, the processor corrects the position of the front light image according to the matching displacement and the matching angle specifically means that the processor rotates and translates the front light image according to the matching displacement and the matching angle, so as to adjust and set the front light image at the position where the front light flared section pattern can be obtained according to the backlight flared section area.
[0196] When the processor receives the position-corrected front light image, the processor obtains the front light flared section pattern according to the backlight flared section area.
[0197] Among them, the front light flaring pattern refers to the pattern indicating the flared section of the pipe on the front light image.
[0198] In the step where the processor generates the flared section pattern data according to the backlight flared section area, the following steps are specifically included:
[0199] The processor uses the straight line fitting method for the backlight flared section area to generate the flared section edge straight line;
[0200] The processor matches the second flaring template on the backlight flaring section area and generates matching point information;
[0201] The processor generates flaring section graphic data based on the flaring section edge straight lines and the matching point information.
[0202] Among them, the flaring section edge straight lines include the left edge line, the right edge line, and the upper edge line of the backlight flaring section area. The left edge line and the right edge line are respectively the edge lines of the side surface of the flaring section, and the upper edge line is the edge line on the end surface of the flaring section. The second flaring template refers to a frame-shaped area. The upper edge line of the second flaring template basically coincides with the upper edge line of the backlight flaring section area. The lower edge line of the second flaring template basically coincides with the left edge line of the backlight flaring section area. The right edge line of the second flaring template basically coincides with the right edge line of the backlight flaring section area. Thus, the lower edge line of the second flaring template is basically located on the boundary line between the flaring section and the non-flaring section. The matching point information refers to the midpoint of the lower edge line of the second flaring template. The graphic data calculated based on the flaring section edge straight lines and the matching point information includes the depth, width, straightness, and angle of the flaring section. The depth of the flaring section is the distance between the matching point information and the upper edge line of the backlight flaring section area. The width of the depth of the flaring section is the distance between the left edge line and the right edge line of the backlight flaring section area. The straightness of the flaring section refers to the fitting degree between the flaring section edge straight lines and the corresponding edges of the backlight flaring section area. The angle of the flaring section refers to the included angle between each flaring section edge straight line.
[0203] In another embodiment, the processor can also obtain the depth of the flaring section by the following steps:
[0204] The processor uses a straight line fitting method for the backlight flaring section area to generate flaring section edge straight lines, and the flaring section edge straight lines include the left edge line, the right edge line, and the upper edge line;
[0205] The processor generates a detection frame on the left edge line. The left edge line is located within the corresponding detection frame. The length of the detection frame is equal to the length of the left edge line plus 100 pixels. The lower end position of the detection frame is 100 pixels lower than the lower end position of the left edge line. The width of the detection frame is 2 pixels;
[0206] The processor obtains edge pixels from top to bottom within the detection frame through an edge detection method, and generates a mutation value and a pixel size based on the edge pixels. The mutation value refers to the brightness difference between the pixel point on the left side of the edge pixel and the pixel point on the right side of the edge pixel. The pixel size refers to the length of continuous edge pixels;
[0207] The processor determines whether the mutation value of the edge pixel is within the mutation threshold. If it is not, the edge pixel is filtered out; if it is, the edge pixel is retained. Since a part of the pipeline itself is intercepted by the detection frame, there may be a problem that the pixels on the pipeline itself have brightness fluctuations and are thus acquired as edge pixels by the processor. Therefore, the processor needs to filter out the edge pixels selected due to brightness fluctuations. When the mutation value of the edge pixel is within the mutation threshold, if the processor determines that the edge pixel is not a pixel with brightness fluctuation on the pipeline itself, the edge pixel is retained. When the mutation value of the edge pixel is not within the mutation threshold, if the processor determines that the edge pixel is a pixel with brightness fluctuation on the pipeline itself, the edge pixel is filtered out. The mutation threshold is a constant and can be preset in the processor;
[0208] The processor determines whether the pixel size of the above-retained edge pixel is greater than the filtering size. If it is greater, the edge pixel is retained; if it is not greater, the edge pixel is filtered out. Since there may be black dots in the background within the detection frame, the processor needs to filter out these black dots selected as edge pixels. When the pixel size of the above-retained edge pixel is greater than the filtering size, the processor determines that the edge pixel is not a black dot on the background and retains the edge pixel. When the pixel size of the above-retained edge pixel is not greater than the filtering size, the processor determines that the edge pixel is a black dot on the background and filters out the edge pixel. The filtering size is a constant and can be preset in the processor;
[0209] The processor calculates the mutation score of the edge pixel according to a mathematical model, and obtains the edge pixel corresponding to the maximum mutation score among the edge pixels as the left-edge strong mutation point. The mathematical model is where M is the mutation score, L is the mutation value of the edge pixel, n1 is the weight coefficient, the range of n1 is (0, 1), h is the pixel size of the edge pixel, and H is the length of the corresponding detection frame. In this embodiment, n1 is 0.5;
[0210] Based on the above steps, the processor processes the right-edge line and obtains the right-edge line strong mutation point;
[0211] The processor obtains a fitting line for the left-edge line strong mutation point and the right-edge line strong mutation point through a line fitting method, and calculates the midpoint of the fitting line;
[0212] The processor calculates the distance between the midpoint of the fitting line and the upper-edge line, and the above distance is the depth of the flared section.
[0213] The steps of generating the flared section graphic data according to the positive-light flared section graphic specifically include:
[0214] The processor converts the positive-light flared section graphic into a grayscale image;
[0215] The processor performs blob analysis on the grayscale image converted from the positive light flaring section pattern and generates the ratio of the grayscale abnormal area.
[0216] The processor performs color analysis on the positive light flaring section pattern and generates the color mean value and color standard deviation.
[0217] Among them, the positive light flaring section pattern is a color RGB pattern. The grayscale abnormal area is used to indicate the area of hot damage on the flaring section of the pipe. There is a grayscale difference between the grayscale value of the area of hot damage on the flaring section of the pipe and the intact part of the flaring section of the pipe. The ratio of the grayscale abnormal area refers to the ratio of the grayscale abnormal area to the entire flaring section pattern of the pipe. The graphic data calculated by the processor based on the positive light flaring section includes the ratio of the grayscale abnormal area, color mean value, and color standard deviation of the flaring section. The ratio of the grayscale abnormal area, color mean value, and color standard deviation are the surface information data in the flaring section graphic data.
[0218] The flaring section graphic data specifically includes the depth, width, angle, the difference between the distance between the two ends of the head of the flaring section and the width of the flaring section, the ratio of the grayscale abnormal area, color mean value, and color standard deviation of the flaring section. Among them, the depth of the flaring section refers to the distance between the head and the end of the flaring section, the width of the flaring section refers to the pipe diameter of the flaring section, and the angle of the flaring section refers to the angle of each end angle of the flaring section.
[0219] The safety flaring section graphic parameter range specifically includes the depth range, width range, angle range, difference range, ratio of the grayscale abnormal area range, color mean value range, and color standard deviation range of the safety flaring section.
[0220] The steps for the processor to determine whether the flaring section graphic data is within the safety flaring section graphic parameter range specifically include the following steps:
[0221] The processor determines whether the depth of the flaring section is within the safety flaring section depth range. If it is not, it determines that the pipe has a defect, thus enabling the processor to detect defects such as too short or too long depth of the flaring section or the flaring section not being flared.
[0222] The processor determines whether the width of the flaring section is within the safety flaring section width range. If it is not, it determines that the pipe has a defect, thus enabling the processor to detect defects such as too narrow or too wide width of the flaring section or the flaring section not being flared. The processor determines whether the angle of the flaring section is within the safety flaring section angle range. If it is not, it determines that the pipe has a defect, thus enabling the processor to detect defects such as abnormal protrusion or bending at the end of the pipe flaring section.
[0223] The processor determines whether the difference between the distances at both ends of the flared section head and the width of the flared section is within the difference range of the safe flared section. If it is not within the range, it is determined that the pipe has a defect, thus enabling the processor to detect the defect of shrinkage in the flared section of the pipe.
[0224] Among them, the difference between the distances at both ends of the flared section head and the width of the flared section refers to the difference between the distance between the two end points of the flared section head and the width in the graphic data of the flared section. The distance between the two end points of the flared section head means that one end point of the flared section head is the intersection of the upper edge line and the left edge line, and the other end point of the flared section head is the intersection of the upper edge line and the right edge line. The width in the graphic data of the flared section is the distance between the upper edge line and the lower edge line. If the above difference exceeds the safe difference range, it is determined that the flared section has a defect of flared shrinkage. If the above difference is within the safe difference range, it is determined that the flared section has no defect of flared shrinkage.
[0225] The processor determines whether the ratio of the gray abnormal area of the flared section is not within the ratio range of the gray abnormal area of the safe flared section. If it is not within the range, it is determined that the pipe has a defect, thus enabling the processor to detect the defect of hot damage in the flared section.
[0226] The processor determines whether the color mean value of the flared section is within the color mean value range of the safe flared section. If it is not within the range, it is determined that the pipe has a defect, thus enabling the processor to detect the defect of color abnormality in the flared section. Among them, the color mean value of the safe flared section can adopt the color mean value of the unflared section.
[0227] The processor determines whether the color difference of the flared section is within the color difference range of the safe flared section. If it is not within the range, it is determined that the pipe has a defect, thus enabling the processor to detect the defect of different colors in the flared section.
[0228] In this embodiment, when the processor determines that the graphic data of the unflared section is within the range of the graphic parameters of the safe unflared section and the graphic data of the flared section is within the range of the graphic parameters of the safe flared section, the following steps are further included:
[0229] If both are within the range, it is determined that the pipe has no defect.
[0230] As Figure 11 shown, in the step of generating the edge straight line of the flared section by using the straight line fitting method for the backlight flared section area, the specific straight line fitting method includes:
[0231] P1: Obtain the ROI region information of the fitting straight line;
[0232] Among them, the ROI region information refers to the set of information of each pixel point within the ROI region. The pixel point information includes the brightness and hue of the pixel point. The ROI region refers to a rectangular region, and the edge of the flared section region is located within this rectangular region. The overall size of the ROI region is 2 * 100 pixels.
[0233] P2: Obtain the point set in the ROI region information according to the edge threshold and polarity parameter;
[0234] Among them, the edge threshold refers to the reasonable value range of the pixel point. The processor determines whether the information of each pixel point is within the edge threshold and the polarity parameter. If so, the pixel point is obtained and a point set is generated. The point set refers to the set of pixel points whose pixel point information is greater than the edge threshold and the polarity parameter.
[0235] P3: Calculate the average value of the abscissa and ordinate of the above point set;
[0236]
[0237]
[0238] Among them, X1...X n refers to the abscissa of each point set, N refers to the number of point sets,.... refers to the average value of the abscissa of the point set, Y1...Y n refers to the ordinate of each point set, refers to the average value of the ordinate of the point set.
[0239] P4: Calculate the sum result of the abscissa and the sum result of the ordinate of the point set;
[0240]
[0241]
[0242] Among them, X1...X n refers to the abscissa of each point set, N refers to the number of point sets, refers to the sum result of the abscissa of the point set, Y1...Y n refers to the ordinate of each point set, refers to the average value of the ordinate of the point set.
[0243] P5: Calculate the sum of the squares of the abscissa of the point set;
[0244]
[0245] Among them, X1 2 ...X n 2It refers to the square of the abscissa of each point set. It refers to the sum of the squares of the abscissas of the point set.
[0246] P6: Calculate the sum of the products of the abscissa and ordinate of the point set;
[0247]
[0248] Among them, X1Y1 + X2Y2 + X3Y3 +... + X n Y n It refers to the product result of the abscissa and ordinate of each point set. It refers to the result of the sum of the products of the abscissa and ordinate.
[0249] P7: Use the above calculation results to obtain the intercept a and slope b of the straight line;
[0250]
[0251]
[0252] Among them, b refers to the slope of the straight line, and a refers to the intercept of the straight line. It refers to the average value of the ordinates of the point set. It refers to the average value of the abscissas of the point set.
[0253] P8: Fit the straight line Y = aX + b, where Y refers to the ordinate of the point set and X refers to the abscissa of the point set;
[0254] P9: Obtain the distance from the point set to the straight line according to the distance formula from a point to a straight line;
[0255] P10: Calculate the average value N1 and standard deviation N2 of the distance from the point set to the straight line;
[0256] P11: Statistically analyze the percentage of the point set with a distance within N1 ± 3 * N2 as the fitting degree of the straight line;
[0257] P12: When the fitting degree of the straight line is lower than 0.7, remove the points outside the range and re-enter step P3 to fit the straight line.
[0258] The processor determines the fitting straight line with a fitting degree of not less than 0.7 as the edge straight line of the flaring section.
[0259] To sum up, the following introduces the detection process of the present invention under backlight and the detection process under front light.
[0260] As Figure 12 shown, the steps of the detection process under front light include:
[0261] M1: Correct the position of the front-light image according to the matching displacement and matching angle, and obtain the front-light flare section pattern through the backlight flare section area;
[0262] M2: The front-light flare section pattern is a color RGB pattern, and convert the front-light flare section pattern into a grayscale image;
[0263] M3: Perform blob analysis on the grayscale image converted from the front-light flare section pattern. Through blob analysis, obtain the grayscale abnormal area of the front-light flare section pattern. If the area of the obtained grayscale abnormal area is less than 50% of the total area of the flare section pattern, it is considered that the defect of the flare section of this pipe is scalding; if the area of the obtained grayscale abnormal area is greater than 50% of the total area of the front-light flare section pattern, then proceed to the next step;
[0264] M4: Perform color analysis on the front-light flare section pattern to generate the color mean value and color standard deviation of the front-light flare section pattern;
[0265] M5: If the color standard deviation exceeds the safe color standard deviation, it is considered that the pipe detected this time is a pipe with abnormal color; if the color standard deviation is within the safe color standard deviation, then proceed to the next step;
[0266] M6: Perform color analysis on the non-flared section pattern of the pipe to obtain the safe color mean value;
[0267] M7: Judge whether the color mean value of the front-light flare section pattern is within the safe color mean value. If so, it is considered that there is no color difference in the flare section of this pipe; if not, there is a color difference in the flare section of this pipe.
[0268] As Figure 13 shown, the steps of the detection process under backlight include:
[0269] C1: When performing backlight detection, it is necessary to ensure that the backlight source is turned on and the front light source is turned off. Collect the backlight image under backlight and process the backlight image to obtain a grayscale image;
[0270] C2: Obtain the flare contour in the backlight image through the edge search method, correct the position of the flare contour according to the matching displacement and matching angle and obtain the backlight flare section area. Use the straight line fitting method on the backlight flare section area to generate the flare section edge straight line. The flare section edge straight line includes the left edge line, right edge line and upper edge line of the flare section;
[0271] C3: Match the second flare template on the backlight flare section area and generate matching point information;
[0272] C4:, Generate the flare section pattern data according to the flare section edge straight line and the matching point information. The obtained flare section pattern data includes the depth, width, straightness and angle of the flare section;
[0273] C5: According to the actual production requirements, preset the graphic data of the safety flaring section, and determine whether the graphic data of the flaring section is within the range of the graphic parameters of the safety flaring section. If so, the pipe is determined to be qualified; if not, the pipe is determined to be abnormal. In the above step S2, if only one edge straight line is fitted when the left and right edge lines of the flaring section are linearly fitted but other detection conditions are all satisfied, it proves that there is an overlapping problem with the pipe.
[0274] Based on the above problems, extract the area of the black area in the ROI region of the above pipe, and then obtain the maximum area among the extracted black area. The maximum area is the overlapping area of the flaring section. Then, determine whether the overlapping area of the flaring section exceeds 50% of the first flaring template. If it exceeds, it is determined that the pipe overlaps with other pipes, and the pipe is not determined as a defective product. If it does not exceed, it is determined that the pipe has a defect of abnormal flaring area.
[0275] When receiving the backlight flaring section area, generate position data according to the backlight flaring section area.
[0276] Among them, the position data is used to indicate the position of the pipe above the background board.
[0277] If it is determined that the pipe has a defect, the defective pipe is sorted according to the position data. If it is determined that the pipe has no defect, the non-defective pipe is sorted according to the position data, so as to achieve the effect of sorting defective pipes and non-defective pipes.
[0278] Such as Figure 5 and Figure 6 shown, an embodiment of the present invention also provides a detection device for pipe defects based on a backlight image, which is implemented by using the above detection method for pipe defects based on a backlight image, and includes:
[0279] A background board, which is used as the background in the pipe image captured by the camera;
[0280] A push plate, which is used to convey the pipe above the background board;
[0281] A light source, which is used to emit light on the front of the pipe as positive light and emit light on the back of the pipe as backlight;
[0282] A camera, which is used to capture an image on the front of the pipe;
[0283] A processor, which is used to determine whether the pipe has a defect according to the positive light image and the backlight image.
[0284] Among them, judging whether there are defects in the pipe according to the front-light image and the back-light image is specifically as follows: The pipe is conveyed above the background board by the pushing plate; when the current space-time parameters of the pushing plate meet the expected space-time parameters, the image of the pipe captured by the camera under the front light is collected as the front-light image, and the image of the pipe captured by the camera under the back light is collected as the back-light image; perform distortion correction processing on the front-light image and the back-light image; calculate the graphic data of the non-flared section in the back-light image; if the graphic data of the non-flared section is not within the range of the safe non-flared section graphic parameters, it is determined that the pipe has defects; obtain the flared contour on the back-light image by the edge search method, match the flared contour with the first flared template to generate the matching displacement and the matching angle; perform position correction on the flared contour according to the matching displacement and the matching angle to obtain the back-light flared section area, perform position correction on the front-light image according to the matching displacement and the matching angle, and obtain the front-light flared section graphic in the position-corrected front-light image according to the back-light flared section area; generate the flared section graphic data according to the back-light flared section area and the front-light flared section graphic; if the flared section graphic data is not within the range of the safe flared section graphic parameters, it is determined that the pipe has defects.
[0285] In actual use, the pushing plate conveys the pipe above the background board, the light source can control the light on the front and back of the pipe, the camera can take pictures on the front of the pipe, and the processor processes the captured front-light image and back-light image, and then the processor controls output devices such as alarms, displays, and sorting devices.
[0286] In some embodiments, the camera and the front light source are arranged above the background board, and the back light source is arranged below the background board. In actual use, when the pushing plate conveys the pipe above the background board, the pipe is also below the camera and the front light source and above the back light source.
[0287] In some embodiments, the background board is light-transmissive. In actual use, the light emitted by the back light source can pass through the background board and shine on the camera.
[0288] In some embodiments, the background board is opaque. In actual use, the opaque background board is used to prevent the camera from capturing the back light source below the background board.
[0289] In some embodiments, the background board is white. In actual use, the white background board makes the background in the back-light image captured by the camera white and the background in the front-light image captured by the camera also white.
[0290] In some embodiments, the pushing plate is also black. In actual use, the black pushing plate makes the pushing plate black in the back-light image captured by the camera and the pushing plate also black in the front-light image captured by the camera.
[0291] In some embodiments, the light source includes a front light source and a back light source. The front light source is disposed on the front side of the background board, and the back light source is disposed on the back side of the background board. The front light source is used to illuminate the front side of the pipe as the front light, and the back light source is used to illuminate the back side of the pipe as the back light. The push plate slides horizontally above the background board. When the push plate slides above the background board, the pipe can be conveyed above the background board.
[0292] In actual use, the back light source is installed below the background board to provide uniform backlight on the back side of the pipe together with the background board.
[0293] In some embodiments, the processor is further configured to control the front light source switch and the back light source switch. Specifically, the front light source and the back light source are respectively electrically connected to the processor.
[0294] In some embodiments, an optoelectronic switch is further included. The optoelectronic switch is used to detect the position of the push plate. The triggering area of the optoelectronic switch is located above the background board. When the push plate enters the triggering area of the optoelectronic switch, the optoelectronic switch is triggered to generate a trigger signal and send it to the processor. The optoelectronic switch is electrically connected to the processor.
[0295] In some embodiments, an alarm is further included. The alarm is electrically connected to the processor.
[0296] The above embodiments are only the preferred embodiments of the present invention, and do not limit the protection scope of the present invention accordingly. Therefore, all equivalent changes made according to the structure, shape, and principle of the present invention should be covered within the protection scope of the present invention.
Claims
1. A detection method for pipe defects based on backlight images, characterized in that, Including: Judge whether the current space-time parameters of the push plate conform to the expected space-time parameters. If they conform, collect the pipe image captured by the camera under positive light as the positive light image and the pipe image captured by the camera under backlight as the backlight image; if they do not conform, do not collect the pipe image captured by the camera under positive light as the positive light image and the pipe image captured by the camera under backlight as the backlight image; Perform distortion correction processing on the positive light image and the backlight image; Calculate the graphic data of the non-flared section in the backlight image; Judge whether the graphic data of the non-flared section is within the range of the safe non-flared section graphic parameters. If it is not within the range, it is determined that the pipe has defects; Obtain the flared contour on the backlight image through the edge search method, match the flared contour with the first flared template, and generate the matching displacement and matching angle; Perform position correction on the flared contour according to the matching displacement and matching angle to obtain the backlight flared section area; perform position correction on the positive light image according to the matching displacement and matching angle, and obtain the positive light flared section graphic in the position-corrected positive light image according to the backlight flared section area; Generate the flared section graphic data according to the backlight flared section area and the positive light flared section graphic; Judge whether the flared section graphic data is within the range of the safe flared section graphic parameters. If it is not within the range, it is determined that the pipe has defects.
2. The detection method for pipe defects based on backlight images according to claim 1, characterized in that The graphic data of the non-flared section includes the pipe diameter of the non-flared section of the pipe and the quantity of the pipes.
3. The detection method for pipe defects based on backlight images according to claim 2, characterized in that, The step of calculating the graphic data of the non-flared section in the backlight image specifically includes: Obtain the edge straight line of the non-flared section in the backlight image through the edge search method; Determine the pipe diameter of the non-flared section and the quantity of the pipes according to the edge straight line of the non-flared section.
4. A method for detecting pipe defects based on backlight images according to claim 1, characterized in that, The flared section graphic data includes the depth, width, angle of the flared section, and the difference between the distance between the two ends of the head of the flared section and the width of the flared section.
5. The detection method of pipe defects based on backlight images according to claim 1, characterized in that, The range of the safe flared section graphic parameters includes the depth range, width range, angle range, and difference range of the safe flared section.
6. The detection method of pipe defects based on backlight images according to claim 4, characterized in that, The step of judging whether the flared section graphic data is within the range of the safe flared section graphic parameters. If it is not within the range, it is determined that the pipe has defects specifically includes: Judge whether the depth of the flared section is within the range of the safe flared section depth. If it is not within the range, it is determined that the pipe has defects; Judge whether the width of the flared section is within the range of the safe flared section width. If it is not within the range, it is determined that the pipe has defects; Judge whether the angle of the flared section is within the range of the safe flared section angle. If it is not within the range, it is determined that the pipe has defects; Judge whether the difference between the distance between the two ends of the head of the flared section and the width of the flared section is within the range of the safe flared section difference. If it is not within the range, it is determined that the pipe has defects.
7. A method for detecting pipe defects based on backlight images according to claim 1, characterized in that, The step of generating the flared section graphic data according to the backlight flared section area specifically includes: Adopt the straight line fitting method for the backlight flared section area to generate the flared section edge straight line; Match the second flared template on the backlight flared section area and generate the matching point information; Generate the flared section graphic data according to the flared section edge straight line and the matching point information.
8. The detection method for pipe defects based on backlight images according to claim 1, characterized in that, Also including: If the graphic data of the non-flared section is within the range of the safe non-flared section graphic parameters and the graphic data of the flared section is within the range of the safe flared section graphic parameters, it is determined that the pipe has no defects.
9. The detection method for pipe defects based on backlight images according to claim 1, characterized in that, The described edge finding method specifically includes: dividing the backlight image into several sub-regions; Performing edge point extraction processing on each sub-region in the direction from white pixel points to black pixel points; Successively storing the edge points with different horizontal coordinate components extracted in the first group into different edge point sets; Successively comparing the edge points extracted in the remaining groups with the edge points extracted in the first group, and putting the edge points that meet the condition that the absolute value of the difference in the horizontal coordinate components of the corresponding edge points between the two groups is less than the set threshold into the corresponding edge point sets established in the previous step. Each edge point set is the left edge information of each pipe; 10. A detection device for pipe defects based on backlight images, characterized in that, Including: A light source for illuminating the back of the pipe as backlight; A camera for taking images of the front of the pipe; A processor for determining whether the current spatio-temporal parameters of the push plate meet the expected spatio-temporal parameters. If they meet, it collects the pipe image taken by the camera under direct light as the direct light image and the pipe image taken by the camera under backlight as the backlight image; if they do not meet, it does not collect the pipe image taken by the camera under direct light as the direct light image and the pipe image taken by the camera under backlight as the backlight image; Performing distortion correction processing on the direct light image and the backlight image; Calculating the graphic data of the non-flared section in the backlight image. If the graphic data of the non-flared section is not within the range of the safe non-flared section graphic parameters, it is determined that the pipe has a defect. The flared contour is obtained on the backlight image through the edge finding method, and the flared contour is matched with the first flared template to generate the matching displacement and the matching angle; Performing position correction on the flared contour according to the matching displacement and the matching angle to obtain the backlight flared section area, performing position correction on the direct light image according to the matching displacement and the matching angle, and obtaining the direct light flared section graphic from the position-corrected direct light image according to the backlight flared section area; Generating the flared section graphic data according to the backlight flared section area and the direct light flared section graphic; if the flared section graphic data is not within the range of the safe flared section graphic parameters, it is determined that the pipe has a defect.
Citation Information
Patent Citations
Method for omnibearing detection of defect of PET bottle cap antitheft ring
CN104764746A
Cylindrical product appearance online detection system
CN111429453A