A method and device for measuring the flaring size and detecting defects of a pipe
Through the combination of positive light and backlight images, the flared segment graphic data is generated, which solves the problem of online measurement of the pipe flared size and detection of flared defects in the prior art, and achieves efficient and accurate pipe quality control.
Patent Information
- Application Number
- CN202211012403.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-29
- 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 unqualified pipes and economic losses.
The positive and backlight image acquisition combined with edge search method is used to generate matching displacement and angle by matching the flaring template, position correction is performed, and the flaring segment graphic data is generated to determine whether it is within the safe parameter range.
Accurate measurement and defect detection of the flared size of the pipe is realized, which improves the accuracy and reliability of the inspection, and avoids the production of unqualified pipes.
Smart Images

Figure CN115496710B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the detection technology, and particularly relates to a method and device for measuring the flaring size and detecting defects of pipes. Background Art
[0002] Pipes generally refer to plastic pipes extruded by hot pressing after mixing polyvinyl chloride resin with stabilizers, lubricants, etc. After the pipes are flared, they can be used to connect two pipes without the need for a transition pipe, greatly reducing the production cost and construction cost. 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 cannot be used.
[0004] The flaring production line is very likely to produce 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 flaring abnormalities of pipes in a timely manner. It is very likely to cause accidents where a large number of unqualified pipes are processed by the flaring production line, causing huge economic losses to the manufacturer. Summary of the Invention
[0005] To overcome the deficiencies and existing problems of the prior art, the present invention provides a method and device for measuring the flaring size and detecting defects of pipes.
[0006] To achieve the above object, the present invention adopts the following technical solutions:
[0007] A method for measuring the flaring size and detecting defects of pipes, comprising:
[0008] Collecting the pipe image captured by the camera under positive light as the positive light image, and collecting the pipe image captured by the camera under backlight as the backlight image;
[0009] Obtaining the flaring contour on the backlight image through an edge search method, matching the flaring contour with the first flaring template to generate a matching displacement and a matching angle;
[0010] Performing position correction on the flaring contour according to the matching displacement and the matching angle to obtain the backlight flaring section area, performing position correction on the positive light image according to the matching displacement and the matching angle, and obtaining the positive light flaring section graphic in the position-corrected positive light image according to the backlight flaring section area;
[0011] Generating flaring section graphic data according to the backlight flaring section area and the positive light flaring section graphic;
[0012] Determine whether the flare section graphic data is within the range of the safe flare section graphic parameters. If not, it is determined that the pipe has defects.
[0013] Preferably, before the step of collecting 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, the following steps are further included:
[0014] Convey the pipe to above the background board through a push plate, and the camera captures the image of the pipe above the background board.
[0015] Preferably, the step of collecting 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 further includes the following steps:
[0016] Determine whether the current spatio-temporal parameters of the push plate conform to the expected spatio-temporal 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.
[0017] Preferably, when determining whether the current spatio-temporal parameters of the push plate conform to the expected spatio-temporal parameters, the following steps are further included:
[0018] Set a trigger area;
[0019] Determine whether the current position of the push plate is within the trigger area. If not, do not collect the positive light image and the backlight image.
[0020] Preferably, when the current position of the push plate is within the trigger area, further, the following steps are included:
[0021] Collect the mis-trigger time;
[0022] Determine whether the mis-trigger time collected by the processor is less than the first preset time. If it is less, do not collect the positive light image and the backlight image.
[0023] Preferably, when the mis-trigger time is not less than the first preset time, further, the following steps are included:
[0024] Collect the delay trigger time;
[0025] Determine whether the collected delay trigger time is less than the second preset time. If it is less, do not collect the backlight image and the positive light image.
[0026] Preferably, when determining whether the current spatio-temporal parameters of the push plate conform to the expected spatio-temporal parameters, the following steps are further included:
[0027] Collection trigger interval time;
[0028] Judge whether the collected trigger interval time is less than the third preset time. If it is less, do not collect the backlight image and the front light image.
[0029] Preferably, 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:
[0030] Calculate the front light duration;
[0031] Judge whether the calculated front light duration is less than the safety time. If it is less, do not collect the front light image.
[0032] Preferably, in the step of collecting the pipe image captured by the camera under the backlight as the backlight image, it specifically includes:
[0033] 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 the backlight as the backlight image.
[0034] Preferably, in the step of collecting the pipe image captured by the camera under the front light as the front light image, it specifically includes:
[0035] 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, the trigger interval time is not less than the third preset time, and the front light duration is not less than the safety time, then collect the pipe image captured by the camera under the front light as the front light image.
[0036] Preferably, if the pipe image captured by the camera under the backlight is collected as the backlight image, the following steps are further included:
[0037] Obtain the push plate contour in the backlight image;
[0038] Compare the push plate contour with the standard push plate contour to generate a matching degree;
[0039] Judge whether the matching degree is not greater than the safety matching degree. If it is not greater, it is determined that the pipe is in an abnormal position.
[0040] If it is greater, obtain the matching angle of the current push plate contour according to the push plate contour and the standard push plate contour.
[0041] Judge 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.
[0042] Preferably, when the frontlight image and the backlight image are acquired, the following steps are further included:
[0043] Perform distortion correction processing on the frontlight image and the backlight image.
[0044] Preferably, the step of performing distortion correction processing on the frontlight image and the backlight image specifically includes:
[0045] Acquire the calibration plate image;
[0046] Perform distortion correction on the calibration plate image and generate a distortion calibration file;
[0047] Perform distortion correction on the frontlight image and the backlight image according to the distortion calibration file.
[0048] Preferably, the flare section graphic data includes the depth, width, angle of the flare section, the difference between the distance at both ends of the flare section head and the width of the flare section, the ratio of the gray anomaly area, the color mean value, and the color standard deviation.
[0049] Preferably, the step of generating the flare section graphic data according to the backlight flare section area specifically includes:
[0050] Use the line fitting method on the backlight flare section area to generate the flare section edge line;
[0051] Match the second flare template on the backlight flare section area and generate the matching point information;
[0052] Generate the flare section graphic data according to the flare section edge line and the matching point information.
[0053] Preferably, the step of generating the flare section graphic data according to the frontlight flare section graphic specifically includes:
[0054] Convert the frontlight flare section graphic into a grayscale image;
[0055] Perform blob analysis on the grayscale image converted from the frontlight flare section graphic and generate the ratio of the gray anomaly area;
[0056] Perform color analysis on the frontlight flare section graphic and generate the color mean value and the color standard deviation.
[0057] Preferably, the step that the processor calculates the graphic data of the unflared section in the backlight image and determines whether the graphic data of the unflared section is within the range of the safe unflared section graphic parameters, and if not, determines that the pipe has defects specifically includes:
[0058] The processor obtains the edge line of the unflared section in the backlight image through the edge search method;
[0059] The processor determines the pipe diameter of the unflared section and the number of pipes according to the edge straight line of the unflared section;
[0060] The processor determines that the number of pipes is 0. If it is 0, it determines that the pipe triggers the alarm;
[0061] The processor determines whether the pipe diameter of the unflared section is not within the dimensional tolerance of the pipe. If it is not, it triggers the alarm.
[0062] Preferably, the method for edge finding specifically includes the following steps:
[0063] Segment the backlight image into several sub-regions;
[0064] For each sub-region, perform edge point extraction processing in the direction from white pixel points to black pixel points;
[0065] Successively store the edge points with different horizontal coordinate components extracted in the first group into different edge point sets;
[0066] 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.
[0067] Preferably, the step in which the processor determines whether the flared section graphic data is within the range of the safe flared section graphic parameters specifically includes the following steps:
[0068] The processor determines whether the depth of the flared section is within the range of the safe flared section depth. If it is not, it determines that the pipe has defects.
[0069] The processor determines whether the width of the flared section is within the range of the safe flared section width. If it is not, it determines that the pipe has defects, thereby realizing that the processor detects defects such as too narrow, too wide or unflared width of the flared section. The processor determines whether the angle of the flared section is within the range of the safe flared section angle. If it is not, it determines that the pipe has defects.
[0070] The processor determines 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, it determines that the pipe has defects.
[0071] The processor determines whether the ratio of the gray abnormal area of the flared section is not within the range of the ratio of the gray abnormal area of the safe flared section. If it is not, it determines that the pipe has defects.
[0072] The processor determines whether the color mean value of the flared section is within the range of the color mean value of the safe flared section. If it is not, it determines that the pipe has defects.
[0073] 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, it determines that the pipe has defects.
[0074] When the processor determines that the graphic data of the unflared section is within the graphic parameter range of the safe unflared section and the graphic data of the flared section is within the graphic parameter range of the safe flared section, the following steps are further included:
[0075] If both are within, it determines that the pipe has no defects.
[0076] The present invention also provides a device for measuring the flaring size and detecting defects of pipes, which is implemented by using the above-mentioned method for measuring the flaring size and detecting defects of pipes, and includes:
[0077] A background board;
[0078] A light source, which is used to illuminate the front of the pipe as the front light and illuminate the back of the pipe as the backlight;
[0079] A camera, which is used to capture images on the front of the pipe;
[0080] A processor, which is used to collect the pipe image captured by the camera under the front light as the front light image, collect the pipe image captured by the camera under the backlight as the backlight image, obtain the flaring contour on the backlight image through the edge finding method, match the flaring contour with the first flaring template to generate the matching displacement and matching angle, correct the position of the flaring contour according to the matching displacement and matching angle to obtain the backlight flared section area, correct the position of the front light image according to the matching displacement and matching angle, obtain the front light flared section graphic in the position-corrected front light image according to the backlight flared section area, generate the flared section graphic data according to the backlight flared section area and the front light flared section graphic. If the flared section graphic data is not within the graphic parameter range of the safe flared section, it determines that the pipe has defects.
[0081] Preferably, the light source includes a front light source and a back light source. The front light source is used to illuminate the front of the pipe as the front light, and the back light source is used to illuminate the back of the pipe as the backlight.
[0082] Preferably, it further includes a background board, which is used as the background in the pipe image captured by the camera.
[0083] Preferably, the background board is white and light-transmissive.
[0084] Preferably, it further includes a push plate, which is used to convey the pipe above the background board.
[0085] Preferably, the push plate can slide horizontally above the background board.
[0086] Preferably, it further includes a photoelectric switch for detecting the position of the push plate.
[0087] Preferably, the triggering area of the photoelectric switch is located above the background plate.
[0088] Preferably, the camera and the front light source are arranged above the background plate, and the back light source is arranged below the background plate.
[0089] The prominent and beneficial technical effects of the present invention compared with the prior art are:
[0090] (1) In the present invention, the graphic data of the unflared section and the flared section of the pipe can be generated according to the images of the unflared section and the flared section of the pipe. According to the graphic data of the unflared section, the type and degree of defects in the unflared section can be accurately judged, and according to the graphic data of the flared section and the data obtained in combination with the unflared section, the type and degree of defects in the flared section can be accurately judged.
[0091] (2) In the present invention, the graphic data of the flared section is jointly generated by the front light image and the back light image. The front light image has clear color expression but unclear contour, and the back light image has clear contour but cannot display the surface information of the pipe. The above images are combined and their respective advantages are utilized to generate the graphic data of the flared section, improving the accuracy of the detection of the graphic data of the flared section.
[0092] (3) In the present invention, distortion correction processing is performed on the front light image and the back light image, thereby eliminating the distortion caused by the imaging system of the camera and improving the image restoration degree.
[0093] (4) In the present invention, by setting the false triggering time, delayed 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 is avoided. Therefore, the present invention has the advantage of reliable operation. Description of the Drawings
[0094] Figure 1 is a schematic flow chart of the steps of the method for measuring the flaring size and detecting defects of the pipe of the present invention;
[0095] 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;
[0096] 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;
[0097] Figures 4-1 to 4-7 is a schematic diagram of the back light image of the defect types of each pipe of the present invention;
[0098] Figure 5It is a schematic structural diagram of a flaring size measurement and defect detection device for the pipe of the present invention;
[0099] Figure 6 It is a schematic structural diagram of the present invention applied with a flaring size measurement and defect detection device for a pipe;
[0100] Figure 7 It is a schematic step - flow diagram for detecting the position of the detection push plate of the present invention;
[0101] Figure 8 It is a schematic step - flow diagram for detecting the unflared section of the pipe of the present invention;
[0102] Figure 9 It is a schematic step - flow diagram of the edge finding method of the present invention;
[0103] Figure 10 It is a schematic step - flow diagram of the edge point processing method of the present invention;
[0104] Figure 11 It is a schematic step - flow diagram of the straight - line fitting method of the present invention;
[0105] Figure 12 It is a schematic step - flow diagram for detecting under positive light of the present invention;
[0106] Figure 13 It is a schematic step - flow diagram for detecting under backlight of the present invention;
[0107] In the figure: 1 - background plate, 2 - push plate, 3 - front light source, 4 - back light source, 5 - camera, 6 - processor, 7 - photoelectric switch, 8 - pipe, 81 - flared section, 82 - unflared section. Specific embodiments
[0108] 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.
[0109] 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 achieve the effect of connecting two pipes together, avoiding the use of an adapter to connect 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 an unflared section, and the unflared section and the flared section are connected in sequence.
[0110] As Figures 2-1 to 2-8 shown, according to the feedback from pipe manufacturers and on - site research on 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-2Among them, the surface of the flared section of the pipe is scalded and damaged; (3) Figure 2-3 Among them, 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; (4) Figure 2-4 Among them, the pipe is not flared; (5) Figure 2-5 Among them, the front end face of the flared section of the pipe is uneven, and the uneven end face includes concave surface, convex surface and special shape; (6) Figure 2-6 Among them, the flared section of the pipe shows a retracted situation; (7) Figure 2-7 Among them, the pipe is not flared and the pipe body is flattened. (8) Figure 2-8 Among them, there are obvious color differences and uneven surface colors in the flared section of the pipe.
[0111] In order to detect the defects of the flared pipe and sort out the pipes with defects, such as Figure 1 As shown, this embodiment provides a method for measuring the flared size and detecting defects of pipes, which is executed by using a device for measuring the flared size and detecting defects of pipes provided by the present invention, and includes the following steps:
[0112] S1: Convey the pipe to above the background board through the push plate;
[0113] S2: Judge whether the current space-time parameters of the push plate meet the expected space-time 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;
[0114] S3: Perform distortion correction processing on the positive light image and the backlight image;
[0115] S4: Calculate the graphic data of the non-flared section in the backlight image;
[0116] S5: Judge whether the graphic data of the non-flared section is within the range of the graphic parameters of the safe non-flared section. If it is not, it is determined that the pipe has defects;
[0117] S6: Obtain the flared contour on the backlight image by the edge search method, match the flared contour with the first flared template, and generate the matching displacement and matching angle;
[0118] S7: Correct the position of the flared contour according to the matching displacement and matching angle to obtain the backlight flared section area, correct the position of 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;
[0119] S8: Generate the graphic data of the flared section according to the backlight flared section area and the positive light flared section graphic;
[0120] S9: Determine whether the flaring section graphic data is within the range of the safe flaring section graphic parameters. If not, it is determined that the pipe has defects.
[0121] In the present invention, based on the images of the non-flared section and the flared section of the pipe, the non-flared section graphic data and the flared section graphic data can be generated. According to the non-flared section graphic data, the types and degrees of defects in the non-flared section can be accurately judged, and according to the flared section graphic data and combined with the data obtained from the non-flared section, the types and degrees of defects in the flared section can be accurately judged.
[0122] In the present invention, the front light image and the backlight image are jointly used to generate the flaring section graphic data. The front 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 flaring section graphic data, the accuracy of detecting the flaring section graphic data is improved.
[0123] In the present invention, distortion correction processing is performed on the front light image and the backlight image, thereby eliminating the distortion caused by the imaging system of the camera and improving the image restoration degree.
[0124] In the above step of transporting the pipe to above the background plate through the push plate, the processor can control the motor to drive the push plate to transport the pipe to above the background plate. When the push plate transports the pipe to above the background plate, if the push plate is also above the background plate, the camera can capture an image with the pipe and the push plate.
[0125] 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:
[0126] Set a trigger area;
[0127] Judge whether the current position of the push plate is within the trigger area. If not, the front light image and the backlight image are not collected.
[0128] 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 plate 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. If the current position of the push plate is not within the trigger area, the push plate has not transported the pipe to above the background plate, the photoelectric switch does not generate a trigger signal, and the processor does not receive the trigger signal of the photoelectric switch. If the processor does not receive the trigger signal, the images captured by the camera are not collected as the front light image and the backlight image. The trigger signal refers to the part where the edge jumps in the level signal generated by the photoelectric switch.
[0129] When the current position of the push plate is within the trigger area, further, the following steps are also included:
[0130] The processor collects the false trigger time;
[0131] The processor determines whether the false trigger time collected by the processor is less than the first preset time. If it is less, the front light image and the backlight image are not collected.
[0132] Among them, the current space-time parameter of the push plate includes the false trigger time, and the expected space-time parameter includes 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 allow the camera to take pictures of the push plate when it is stable, the processor needs to determine whether the false trigger time is less than the first preset time. The false trigger time refers to the time when the trigger signal is maintained when the photoelectric switch is triggered, and the time when the trigger signal is maintained is the false 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, when 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 when the trigger signal is maintained is collected as the false trigger time. If the false 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 false trigger time is not less than the first preset time, the push plate has been stable above the background plate.
[0133] When the false trigger time is not less than the first preset time, further, the following steps are also included:
[0134] The processor collects the delay trigger time;
[0135] The processor determines whether the collected delay trigger time is less than the second preset time. If it is less, the backlight image and the front light image are not collected.
[0136] Among them, the current space-time parameters of the push plate include the delay trigger time, and the expected space-time 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.
[0137] In addition, the judgment of whether the current space-time parameters of the push plate meet the expected space-time parameters further includes the following steps:
[0138] The processor collects the trigger interval time;
[0139] The processor judges whether the collected trigger interval time is less than the third preset time. If it is less, the backlight image and the front light image are not collected.
[0140] Among them, the current space-time parameters of the push plate include the trigger interval time, and the expected space-time 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 trigger of the photoelectric switch and the next trigger 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.
[0141] In addition, when determining whether the current space-time parameters of the push plate meet the expected space-time parameters, the following steps are also included:
[0142] The processor calculates the front light duration;
[0143] 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.
[0144] Among them, the current spatio-temporal parameters of the push plate include the positive light duration, and the expected spatio-temporal parameters include the safety time. Since there are instability problems in the 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 judge 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 be turned on and the backlight source to be turned off, and then calculates the positive light duration according to the time when the front light source is turned on and the backlight source is turned off. When 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. When 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 the processor collecting an image affected by the unstable light intensities of the front light source and the backlight source.
[0145] In this embodiment, both the front light source and the backlight source adopt white-light LED lamps, and the safety time is 10 ms.
[0146] In this implementation manner, the processor first collects the backlight image and then collects the positive light image. When the push plate conveys the pipe 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.
[0147] In summary, in the step of collecting the pipe image captured by the camera under the backlight as the backlight image, it specifically includes:
[0148] 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 the backlight as the backlight image.
[0149] When the processor finishes collecting the pipe image captured by the camera as the backlight image, it controls the backlight source to be turned off and the front light source to be turned 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 the positive light as the positive light image.
[0150] In summary, in the step of collecting the pipe image captured by the camera under the positive light as the positive light image, it specifically includes:
[0151] 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, the trigger 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.
[0152] In the present invention, by setting the mis-trigger time, delay trigger time, and interval trigger time of the optoelectronic 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.
[0153] 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 the 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 burns, color differences, etc. on the surface of the pipe.
[0154] 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 the 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, whether there is retraction, etc.
[0155] 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 colors of the pipe include 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.
[0156] 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 collecting the pipe image captured by the camera under backlight as the backlight image, the following steps are further included:
[0157] The processor obtains the push plate contour in the backlight image;
[0158] The processor generates a matching degree by comparing the pusher profile and the standard pusher profile;
[0159] The processor determines whether the matching degree is not greater than the safety matching degree. If it is not greater than, the processor determines that the pipe is in an abnormal position.
[0160] If it is greater than, the processor obtains the matching angle of the current pusher profile according to the pusher profile and the standard pusher profile.
[0161] The processor determines whether the matching angle is less than the safety 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.
[0162] 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 the edge search method, and then the edge of the pusher is processed through edge point processing to obtain the pusher profile.
[0163] 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 deviation, 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 this 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.
[0164] Since the processor needs to verify whether the push plate in the backlight image is offset, the processor 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 to 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 had a position offset or has only had a minor position offset, and then 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.
[0165] In the step where the processor performs 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.
[0166] In this embodiment, the step of performing distortion correction processing on the front light image and the backlight image specifically includes:
[0167] The processor acquires the image of the calibration plate placed above the background plate captured by the camera as the calibration plate image;
[0168] The processor performs distortion correction on the calibration plate image and generates a distortion calibration file;
[0169] The processor performs distortion correction on the front light image and the backlight image according to the distortion calibration file.
[0170] 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, thereby avoiding 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.
[0171] Since the pipe may have defects before being processed by the flaring production line, and the defects include that its own pipe diameter exceeds the dimensional tolerance. In order to detect such defects, a processor calculates the graphic data of the non-flared section in the backlight image, and then determines whether the graphic data of the non-flared section is within the range of safe non-flared graphic parameters. In this step, the graphic data of the non-flared section refers to the graphic data used to indicate the non-flared section of the pipe in the backlight image. The non-flared graphic data includes the pipe diameter of the non-flared section of the pipe and the quantity of the pipes. The range of safe non-flared section graphic parameters includes the dimensional tolerance of this type of pipe and a range where the quantity is greater than 0. By determining whether the graphic data of the non-flared section is within the range of safe non-flared 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 eliminate the defective products of this part and determine whether there are pipes to be detected in this system.
[0172] As Figure 8 shown, the steps for the processor to calculate the graphic data of the non-flared section in the backlight image, determine whether the graphic data of the non-flared section is within the range of safe non-flared section graphic parameters, and if not, determine that the pipe has defects, specifically include:
[0173] The processor obtains the edge straight lines of the non-flared section in the backlight image through an edge detection method;
[0174] The processor determines the pipe diameter of the non-flared section and the quantity of the pipes according to the edge straight lines of the non-flared section;
[0175] The processor determines that the quantity of the pipes is 0, and if it is 0, it determines that the pipe triggers an alarm;
[0176] The processor determines whether the pipe diameter of the non-flared section is not within the dimensional tolerance of the pipe. If not, it triggers an alarm.
[0177] The distance between adjacent edge straight lines of the non-flared section is the pipe diameter of the non-flared section. The processor calculates the distance between the edge straight lines of the non-flared section to determine the pipe diameter of the non-flared section. The number of edge straight lines of the non-flared section is twice the quantity of the pipes. The processor calculates the number of edge straight lines of the non-flared 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 further 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 non-flared section is not within the dimensional tolerance to determine whether there are defects in the pipes in the backlight image, and further determines whether to trigger an alarm.
[0178] In this embodiment, in the backlight image, the pipe pattern is vertical, and the unflared section in the pipe pattern is located in the lower half of the pipe pattern. 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 distance 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.
[0179] To eliminate the interference of other contours in the backlight image, the length of the edge line 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.
[0180] Since the backlight image is taken with the backlight source turned on and the front light source turned off, the pattern indicating the unflared section in the backlight image is black, and the pattern indicating the background board is 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 respectively. 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.
[0181] 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 other types of pipes 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 starts the next step of work.
[0182] The above system starting the next step of work specifically means that the processor obtains the flared contour in the backlight image.
[0183] Among them, the flared contour refers to the contour of the flared section pattern in the backlight image. The processor can obtain the flared contour on the backlight image through the edge search method.
[0184] As Figure 9 shown, in this embodiment, the edge search method specifically includes the following steps:
[0185] Divide the backlight image into several sub-regions;
[0186] For each sub-region, edge points are extracted in the direction from white pixel points to black pixel points;
[0187] The edge points with different horizontal coordinate components extracted in the first group are sequentially stored in different edge point sets;
[0188] The edge points extracted in the remaining groups are sequentially compared with the edge points extracted in the first group, and the edge points that satisfy 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 are put 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.
[0189] According to the above steps, edge search can also be performed on the pusher plate and the unflared section in the backlight image.
[0190] Such as Figure 10 shown, the method for edge point processing specifically includes the following steps:
[0191] Perform projection processing on the sub-region to generate projection lines, calculate the average concentration of each projection line, and obtain the average concentration waveform of the projection lines;
[0192] Perform differential processing on the average concentration waveform of the projection lines to obtain a differential waveform;
[0193] Filter the differential waveform to filter out peaks smaller than the set threshold;
[0194] 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;
[0195] For each of the above sub-regions, traverse each row 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.
[0196] In the above, the projection processing refers to vertical scanning relative to the detection direction.
[0197] In this embodiment, in order to improve the contrast between the pipes and the background on the backlight image, the following steps are further included:
[0198] Perform sharpening processing and exclusive OR operation processing on the backlight image.
[0199] Among them, the processor sharpens the backlight image to increase the sharpness of its edges, making the transition band of the contour edge narrower, thereby enhancing the contrast of the backlight image. In addition, due to the situation where more than two pipes are close to or even fit together, through the sharpening process, the edges of the above-mentioned close pipes can be separated, facilitating the extraction of the flare profiles of the close pipes respectively. Then, the XOR 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 XOR operation can be used to obtain the edge straight line or flare profile of the unflared section or the edge straight line of the unflared section and the flare profile on the backlight image.
[0200] When the processor obtains the flare profile, it matches the flare profile with the first flare template and generates a matching displacement and a matching angle.
[0201] Among them, the first flare template can be preset in the processor. Since the flare widths of pipes of the same model vary little, the same first flare template can be used for matching.
[0202] When the processor generates a matching displacement and a matching angle, the processor corrects the position of the flare profile according to the matching displacement and the matching angle and obtains the backlight flare section area.
[0203] Among them, the processor corrects the position of the flare profile according to the matching position and the matching angle means that the processor rotates and translates the flare profile according to the matching displacement and the matching angle, so as to adjust and set the flare profile at the position where the backlight flare section area can be obtained.
[0204] When the processor generates the backlight flare 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.
[0205] 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 flare section pattern can be obtained according to the backlight flare section area.
[0206] When the processor receives the position-corrected front light image, the processor obtains the front light flare section pattern according to the backlight flare section area.
[0207] Among them, the front light flare pattern refers to the pattern indicating the flare section of the pipe on the front light image.
[0208] In the step where the processor generates the flare section pattern data according to the backlight flare section area, the following steps are specifically included:
[0209] The processor uses the linear fitting method for the backlight flare section area to generate the flare section edge straight line;
[0210] The processor matches the second flaring template on the backlight flaring section area and generates matching point information;
[0211] The processor generates flaring section graphic data according to the flaring section edge straight lines and the matching point information.
[0212] 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 on the sides of the flaring section, and the upper edge line is the edge line on the end face 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 according to 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.
[0213] In another embodiment, the processor can also obtain the depth of the flaring section by the following steps:
[0214] 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;
[0215] 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;
[0216] 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 according to 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;
[0217] 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 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;
[0218] 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;
[0219] 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 strong mutation point of the left edge line. 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;
[0220] Based on the above steps, the processor processes the right edge line and obtains the strong mutation point of the right edge line;
[0221] The processor obtains a fitting line for the strong mutation point of the left edge line and the strong mutation point of the right edge line by the linear fitting method, and calculates the midpoint of the fitting line;
[0222] 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 flaring section.
[0223] The specific steps in generating the flaring section graphic data according to the positive-light flaring section graphic include:
[0224] The processor converts the positive-light flaring section graphic into a grayscale image;
[0225] 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.
[0226] The processor performs color analysis on the positive light flaring section pattern and generates the color mean and color standard deviation.
[0227] Among them, the positive light flaring section pattern is a color RGB pattern. The grayscale abnormal area is used to indicate the burned and damaged area on the flaring section of the pipe. There is a grayscale difference between the grayscale value of the burned and damaged area 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, the color mean, and the color standard deviation of the flaring section. The ratio of the grayscale abnormal area, the color mean, and the color standard deviation are the surface information data in the flaring section graphic data.
[0228] 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, the color mean, and the 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.
[0229] 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 range, and color standard deviation range of the safety flaring section.
[0230] The steps for the processor to judge whether the flaring section graphic data is within the safety flaring section graphic parameter range specifically include the following steps:
[0231] The processor judges whether the depth of the flaring section is within the safety flaring section depth range. If not, it determines that the pipe has a defect, thus realizing that the processor detects defects such as too short or too long depth of the flaring section or the flaring section not being flared.
[0232] The processor judges whether the width of the flaring section is within the safety flaring section width range. If not, it determines that the pipe has a defect, thus realizing that the processor detects defects such as too narrow or too wide width of the flaring section or the flaring section not being flared. The processor judges whether the angle of the flaring section is within the safety flaring section angle range. If not, it determines that the pipe has a defect, thus realizing that the processor detects defects such as abnormal protrusion or bending at the end of the pipe flaring section.
[0233] 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 range of the difference 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 the retraction of the flared section of the pipe.
[0234] 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 point between the upper edge line and the left edge line, and the other end point of the flared section head is the intersection point between 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 range of the safe difference, it is determined that the flared section has the defect of flared retraction. If the above difference is within the range of the safe difference, it is determined that the flared section does not have the defect of flared retraction.
[0235] The processor determines whether the ratio of the gray abnormal area of the flared section is not within the range of the ratio 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 breakage of the flared section.
[0236] The processor determines whether the color mean value of the flared section is within the range of the color mean value 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 of the flared section. Among them, the color mean value of the safe flared section can adopt the color mean value of the unflared section.
[0237] The processor determines whether the color difference of the flared section is within the range of the color difference 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 of the flared section.
[0238] 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:
[0239] If both are within the range, it is determined that the pipe has no defect.
[0240] Such as Figure 11 As 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:
[0241] P1: Obtain the ROI region information of the fitting straight line;
[0242] Among them, the ROI region information refers to the set of information of each pixel point within the ROI region. Pixel point information includes the brightness and hue of the pixel point. The ROI region refers to a frame-shaped region, and the edge of the flaring section region is located within this frame-shaped region. The overall size of the ROI region is 2 * 100 pixels.
[0243] P2: Obtain the point set in the ROI region information according to the edge threshold and the polarity parameter;
[0244] 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.
[0245] P3: Calculate the average value of the abscissa and ordinate of the above point set;
[0246]
[0247]
[0248] 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.
[0249] P4: Calculate the sum result of the abscissa and the sum result of the ordinate of the point set;
[0250]
[0251]
[0252] 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.
[0253] P5: Calculate the sum of the squares of the abscissa of the point set;
[0254]
[0255] Among them, X1 2 ...X n 2Refers to the square of the abscissa of each point set. Refers to the sum of the squares of the abscissas of the point set.
[0256] P6: Calculate the sum of the products of the abscissa and ordinate of the point set.
[0257]
[0258] Among them, X1Y1 + X2Y2 + X3Y3 +... + X n Y n Refers to the product result of the abscissa and ordinate of each point set. Refers to the result of the sum of the products of the abscissa and ordinate.
[0259] P7: Use the above calculation results to obtain the intercept a and slope b of the straight line.
[0260]
[0261]
[0262] Among them, b refers to the slope of the straight line, and a refers to the intercept of the straight line. Refers to the average value of the ordinates of the point set. Refers to the average value of the abscissas of the point set.
[0263] 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.
[0264] P9: Calculate the distance from the point set to the straight line according to the distance formula from a point to a straight line.
[0265] P10: Calculate the average value N1 and standard deviation N2 of the distances from the point set to the straight line.
[0266] P11: Statistically calculate the percentage of the point set with distances within N1 ± 3 * N2 as the fitting degree of the straight line.
[0267] 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.
[0268] 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.
[0269] To sum up, the following introduces the detection process of the present invention under backlight and the detection process under front light.
[0270] As Figure 12 shown, the steps of the detection process under front light include:
[0271] 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;
[0272] M2: The front-light flare section pattern is a color RGB pattern, and convert the front-light flare section pattern into a grayscale image;
[0273] 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;
[0274] M4: Perform color analysis on the front-light flare section pattern to generate the color mean and color standard deviation of the front-light flare section pattern;
[0275] 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;
[0276] M6: Perform color analysis on the non-flare section pattern of the pipe to obtain the safe color mean;
[0277] M7: Judge whether the color mean of the front-light flare section pattern is within the safe color mean. 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.
[0278] As Figure 13 shown, the steps of the detection process under backlight include:
[0279] C1: During 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;
[0280] 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, and 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;
[0281] C3: Match the second flare template on the backlight flare section area and generate matching point information;
[0282] C4:, Generate 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;
[0283] C5: According to the actual production requirements, the graphic data of the safety flaring section is preset, and it is judged 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 judged to be qualified; if not, the pipe is judged to be abnormal. In the above step S2, if only one edge straight line is fitted when the left edge line and the right edge line 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.
[0284] Based on the above problems, the area of the black area in the ROI region of the above pipe is extracted, and then the maximum area in the extracted black area is obtained. The maximum area is the overlapping area of the flaring section. Then it is judged whether the overlapping area of the flaring section exceeds 50% of the first flaring template. If it exceeds, it is judged that the pipe overlaps with other pipes, and the pipe is not judged as a defective product. If it does not exceed, it is judged that the pipe has a defect of abnormal flaring area.
[0285] When the backlight flaring section area is received, position data is generated according to the backlight flaring section area.
[0286] Among them, the position data is used to indicate the position of the pipe above the background board.
[0287] If it is judged that the pipe has a defect, the defective pipe is sorted according to the position data. If it is judged 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 the defective pipes and the non-defective pipes.
[0288] Such as Figure 5 and Figure 6 shown, an embodiment of the present invention also provides a device for measuring the flaring size and detecting defects of pipes, which is implemented by using the above method for measuring the flaring size and detecting defects of pipes, and includes:
[0289] A background board, which is used as the background in the pipe image captured by the camera;
[0290] A push plate, which is used to convey the pipe above the background board;
[0291] 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;
[0292] A camera, which is used to capture an image on the front of the pipe;
[0293] A processor, which is used to judge whether the pipe has a defect according to the positive light image and the backlight image.
[0294] Among them, determining 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 through a 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 through an edge search method, match the flared contour with the first flared template to generate a matching displacement and a 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 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.
[0295] 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.
[0296] 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.
[0297] In some embodiments, the background board is light-transmissive. In actual use, the light emitted by the backlight source can pass through the background board and shine on the camera.
[0298] 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.
[0299] 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.
[0300] 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.
[0301] 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 of the background board, and the back light source is disposed on the back of the background board. The front light source is used to illuminate the front of the pipe as the front light, and the back light source is used to illuminate the back 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.
[0302] In actual use, the back light source is installed below the background board to provide uniform backlight on the back of the pipe together with the background board.
[0303] 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.
[0304] In some embodiments, an optoelectronic switch is further included. The optoelectronic switch is used to detect the position of the push plate, and 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 triggering signal and send it to the processor. The optoelectronic switch is electrically connected to the processor.
[0305] In some embodiments, an alarm is further included. The alarm is electrically connected to the processor.
[0306] The above embodiments are only 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 method for measuring the flaring size and detecting defects of a pipe, characterized in that, Including: Collecting the pipe image captured by the camera under front light as the front light image, and collecting the pipe image captured by the camera under back light as the back light image; Obtaining the flared contour on the back light image through edge detection method, matching the flared contour with the first flared template, and generating the matching displacement and matching angle; Performing position correction on the flared contour according to the matching displacement and matching angle to obtain the back light flared section area, performing position correction on the front light image according to the matching displacement and matching angle, and obtaining the front light flared section graphic in the position-corrected front light image according to the back light flared section area; Generating the flared section graphic data according to the back light flared section area and the front light flared section graphic; The step of generating the flared section graphic data according to the back light flared section area specifically includes: Adopting a straight line fitting method for the back light flared section area to generate the flared section edge straight line; Matching the second flared template on the back light flared section area and generating the matching point information; Generating the flared section graphic data according to the flared section edge straight line and the matching point information; The step of generating the flared section graphic data according to the front light flared section graphic specifically includes: Converting the front light flared section graphic into a grayscale image; Performing blob analysis on the grayscale image converted from the front light flared section graphic and generating the ratio of the grayscale abnormal area; Performing color analysis on the front light flared section graphic and generating the color mean and color standard deviation; Judging whether the flared section graphic data is within the range of the safe flared section graphic parameters, and if not, determining that the pipe has defects.
2. The flaring size measurement and defect detection method for a kind of pipe material according to claim 1, characterized in that Also including: Performing distortion correction processing on the front light image and the back light image.
3. A method for measuring the flaring size and detecting defects of a pipe according to claim 2, characterized in that, The step of performing distortion correction processing on the front light image and the back light image specifically includes: Collecting the calibration plate image; Performing distortion correction on the calibration plate image and generating the distortion calibration file; Performing distortion correction on the front light image and the back light image according to the distortion calibration file.
4. A method for measuring the flaring size and detecting defects of a pipe according to claim 2, characterized in that, The step of performing distortion correction processing on the front light image and the back light image specifically includes: Collecting the calibration plate image; Performing distortion correction on the calibration plate image and generating the distortion calibration file; Performing distortion correction on the front light image and the back light image according to the distortion calibration file.
5. A flaring size measurement and defect detection device for a pipe, characterized in that, Including: A light source for illuminating the front of the pipe as the front light and illuminating the back of the pipe as the back light; A camera for capturing images on the front of the pipe; A processor for collecting the pipe image captured by the camera under front light as the front light image, collecting the pipe image captured by the camera under back light as the back light image, obtaining the flared contour on the back light image through edge detection method, matching the flared contour with the first flared template, generating the matching displacement and matching angle, performing position correction on the flared contour according to the matching displacement and matching angle to obtain the back light flared section area, performing position correction on the front light image according to the matching displacement and matching angle, obtaining the front light flared section graphic in the position-corrected front light image according to the back light flared section area, generating the flared section graphic data according to the back light flared section area and the front light flared section graphic, judging whether the flared section graphic data is within the range of the safe flared section graphic parameters, and if not, determining that the pipe has defects; Generating the flared section graphic data according to the back light flared section area includes: Generate the straight line of the flaring section edge by using the straight line fitting method for the backlight flaring section area; Match the second flaring template on the backlight flaring section area and generate the matching point information; Generate the flaring section graphic data according to the straight line of the flaring section edge and the matching point information; Generating the flaring section graphic data according to the front light flaring section graphic includes: Convert the front light flaring section graphic into a grayscale image; Perform blob analysis on the grayscale image converted from the front light flaring section graphic and generate the ratio of the grayscale abnormal area; Perform color analysis on the front light flaring section graphic and generate the color mean and color standard deviation.
6. The flaring size measuring and defect detecting device for a pipe according to claim 5, characterized in that, The light source includes a front light source and a back light source. The front light source is used to illuminate the front of the pipe as the front light, and the back light source is used to illuminate the back of the pipe as the back light.
7. An apparatus for measuring the flaring size and detecting defects of a pipe according to claim 5 or 6, characterized in that, It also includes a background board, which is used as the background in the pipe image captured by the camera.
8. The flaring size measurement and defect detection device for a pipe according to claim 7, characterized in that The camera and the front light source are arranged above the background board, and the back light source is arranged below the background board.
Citation Information
Patent Citations
Paper label character defect detection method
CN109934809A
Image inpainting method, image inpainting system and flat panel detector thereof
US20210295477A1