A method for detecting deformation defects of a galvanized round-to-square pipe based on machine vision

CN122887889APending Publication Date: 2026-10-09TIANJIN TONGFU STEEL CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611189243.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-06
Publication Date
2026-10-09

AI Technical Summary

Technical Problem

[0005]本发明的目的是为了解决现有技术中的问题而提出的一种基于机器视觉的镀锌圆改方管材变形缺陷检测方法

Benefits of technology

[0013]本发明利用低角度暗场照明的特殊光学特性,配合直线激光发生器,在同一幅灰度图像中同时获取激光轮廓线和缺陷漫反射光斑,实现了几何变形检测与表面缺陷检测的一体化同步采集,无需两套独立的成像系统,大幅降低硬件成本、节省产线安装空间,同时,两类缺陷的检测数据天然对齐于同一采集时刻,为后续的缺陷联合判定提供了精确的数据基础。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122887889A_ABST
    Figure CN122887889A_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of machine vision detection, and discloses a galvanized round-to-square pipe deformation defect detection method based on machine vision, which comprises the following steps: making the pipe to be detected pass through a detection area provided with a linear laser generator and low-angle dark-field illumination, collecting an original image, extracting a one-dimensional cross-section contour sequence based on the laser contour line area in the image and performing signal mutation analysis, identifying bending deformation, extracting a candidate defect area based on the diffuse reflection area and analyzing fluctuation characteristics, identifying skin buckling and axial cracking, converting defect time into defect position information based on the pre-calibration ratio of the camera frame rate and the pipe speed, and marking the pipe surface according to the defect position information. The present application can simultaneously detect geometric deformation and surface defects by using only a single camera and a single laser, the algorithm can be deployed on a lightweight embedded platform, the intuitive transmission of defect information is realized through color separation physical marking, and the present application is suitable for low-cost online full detection of a galvanized pipe production line.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of machine vision inspection technology, and in particular to a method for detecting deformation defects in galvanized round-to-square pipes based on machine vision. Background Technology

[0002] Galvanized round-to-square pipes are prone to various deformation defects during forming and galvanizing processes. These defects not only affect the appearance quality and dimensional accuracy of the pipes but also directly impact the assembly reliability and load-bearing safety of downstream applications such as building structures and machinery manufacturing. Current solutions primarily rely on contact gauge sampling or online laser profile scanners for detecting geometric deformation of the pipes. However, contact sampling is inefficient and has insufficient coverage. While laser profile scanners can acquire cross-sectional shape data, they are costly and require strict installation precision. For surface defects, area array cameras combined with specific light sources are often used to acquire two-dimensional images, followed by deep learning algorithms for defect identification. However, the high reflectivity of the galvanized layer makes defect features easily obscured, resulting in poor detection stability. Furthermore, the training and inference of deep learning solutions require significant computing power, making them difficult to deploy in industrial settings.

[0003] Another challenge in the field of galvanized pipe inspection is that geometric deformation inspection and surface defect inspection often require two independent systems, each with its own independent imaging unit, light source, and data processing channel. This not only increases equipment investment and production line space, but also makes it difficult to accurately correlate the inspection data of the two types of defects in time and space, thus limiting the comprehensive judgment capability of the inspection system.

[0004] Furthermore, existing online inspection systems have significant shortcomings in defect location and marking. Positioning schemes based on encoders or speed measuring wheels typically employ open-loop proportional conversion. When the conveyor speed fluctuates or the rollers slip, the positioning error accumulates along the length of the pipe, causing the defect location information to deviate from the actual location. This affects the accuracy of subsequent cutting and sorting. Most systems only output inspection results in the form of electrical signals or data records. Personnel in subsequent processes cannot quickly and intuitively identify the type and location of defects on the actual pipe. The efficiency of defect information transmission is low, making it difficult to meet the requirements of lean production management. Summary of the Invention

[0005] The purpose of this invention is to propose a machine vision-based method for detecting deformation defects in galvanized round-to-square pipes in order to solve the problems in the prior art.

[0006] To achieve the above objectives, the present invention adopts the following technical solution: a method for detecting deformation defects in galvanized round-to-square pipes based on machine vision, comprising the following steps:

[0007] S1, the pipe to be tested is passed through a detection area with a linear laser generator and low-angle dark field illumination, and the original image of the surface of the pipe to be tested is acquired by a camera. The original image includes the laser contour area and the diffuse reflection area.

[0008] S2, Based on the original image of the laser contour line region, extract a one-dimensional cross-sectional contour sequence along the laser line extension direction and perform signal mutation analysis. If a local reverse deflection of the signal waveform is detected and the deflection amplitude exceeds the preset bending threshold, it is determined that there is bending deformation, and the corresponding acquisition time is recorded as the first defect time.

[0009] S3. Based on the original image of the diffuse reflection area, the pixel area with gray value exceeding the preset gray value threshold is extracted as the candidate defect area. Gray value projection is performed on each row of pixels in the candidate defect area along the pipe conveying direction to generate a one-dimensional row projection signal. Its fluctuation characteristics are extracted. If the axial span of the fluctuation characteristics is less than the preset span threshold and the amplitude exceeds the preset intensity threshold, it is determined that there is peeling or axial cracking. The corresponding acquisition time is recorded as the second defect time.

[0010] S4, based on the pre-calibrated ratio between the camera's frame rate and the pipe conveying speed, the first defect time and the second defect time are converted into the position information of each defect in the pipe length direction.

[0011] S5, based on the type and corresponding location information of each defect, marks the defects on the surface of the pipe through the marking execution device.

[0012] The beneficial effects of the technical solution provided by this invention include at least the following:

[0013] This invention utilizes the special optical characteristics of low-angle dark field illumination, combined with a linear laser generator, to simultaneously acquire laser contour lines and diffuse reflection spots of defects in the same grayscale image. This achieves integrated synchronous acquisition of geometric deformation detection and surface defect detection, eliminating the need for two independent imaging systems, significantly reducing hardware costs and saving production line installation space. Furthermore, the detection data of the two types of defects are naturally aligned with the same acquisition time, providing an accurate data foundation for subsequent joint defect determination.

[0014] This invention reduces two-dimensional image analysis to one-dimensional signal mutation detection. After extracting a one-dimensional cross-sectional contour sequence from the laser contour line, it performs first-order difference and dynamic sliding window threshold analysis, and achieves accurate detection of bending deformation through sign reversal judgment. After performing row-oriented grayscale projection on the diffuse reflection area, it extracts a one-dimensional fluctuation signal, and achieves automatic classification of peeling and axial cracking through axial span threshold. The entire detection process does not require deep learning training or three-dimensional point cloud registration, has extremely low computational load, and can run in real time on embedded processors, fully adapting to the high temperature and limited power supply environment of galvanized pipe production plants.

[0015] This invention deploys a rotary encoder at the end of the pipe conveying roller shaft. While the camera captures each frame of image, it simultaneously reads the cumulative pulse count value, accurately linking the defect acquisition time with the physical position of the pipe. Based on this, by comparing the actual pulse frequency within a preset number of frames near the defect time with the theoretical pulse frequency under calibration, the pre-calibration ratio coefficient is dynamically corrected in real time. This effectively suppresses the impact of conveying speed fluctuations and roller slippage on positioning accuracy, fully meeting the accuracy requirements of production line sorting and cutting.

[0016] This invention employs a physical marking strategy based on defect type and color coding. The marking device automatically selects the corresponding color spraying mechanism to spray color markings onto the pipe surface according to different defect types. This solidifies the defect type information onto the pipe in the form of color codes, allowing personnel in subsequent sorting, cutting, and quality inspection processes to directly identify the defect type and location visually without the need for electronic terminals or inspection reports. This significantly shortens the defect information transmission chain and improves the overall efficiency and quality management level of the production line. Attached Figure Description

[0017] To more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 This is a flowchart of a method provided in an embodiment of the present invention. Detailed Implementation

[0019] To further illustrate the technical means and effects adopted by the present invention to achieve its intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation, structure, features, and effects of a machine vision-based method for detecting deformation defects in galvanized round-to-square pipes according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.

[0020] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0021] The following examples are for illustrative purposes only and are not intended to limit the scope of the invention.

[0022] The following description, in conjunction with the accompanying drawings, details a specific scheme for a machine vision-based method for detecting deformation defects in galvanized round-to-square pipes provided by this invention.

[0023] Please see Figure 1 The diagram illustrates a flowchart of a machine vision-based method for detecting deformation defects in galvanized round-to-square pipes, according to an embodiment of the present invention. The method includes the following steps:

[0024] S1, the pipe to be tested is passed through the detection area with a linear laser generator and low-angle dark field illumination, and the camera acquires the original image of the surface of the pipe to be tested, including the laser contour area and the diffuse reflection area.

[0025] S2, Based on the original image of the laser contour region, extract a one-dimensional cross-sectional contour sequence along the extension direction of the laser line and perform signal mutation analysis. If a local reverse deflection of the signal waveform is detected and the deflection amplitude exceeds the preset bending threshold, it is determined that there is bending deformation, and the corresponding acquisition time is recorded as the first defect time.

[0026] S3. Based on the original image of the diffuse reflection area, the pixel area with gray value exceeding the preset gray value threshold is extracted as the candidate defect area. Gray value projection is performed on each row of pixels in the candidate defect area along the pipe conveying direction to generate a one-dimensional row projection signal. Its fluctuation characteristics are extracted. If the axial span of the fluctuation characteristics is less than the preset span threshold and the amplitude exceeds the preset intensity threshold, it is determined that there is peeling or axial cracking. The corresponding acquisition time is recorded as the second defect time.

[0027] S4, based on the pre-calibrated ratio between the camera's acquisition frame rate and the pipe conveying speed, convert the first defect time and the second defect time into the position information of each defect in the pipe length direction.

[0028] S5, based on the type and corresponding location information of each defect, marks the defects on the surface of the pipe through the marking execution device.

[0029] In one embodiment of the present invention, the step of dividing the original image into a laser contour region and a diffuse reflection region includes:

[0030] A monocular area array camera and a single linear laser generator are deployed above the pipe conveying line. The single linear laser generator projects obliquely at a preset angle to the normal of the surface of the pipe to be tested. The laser contour line obtained by projection extends along the width of the pipe in the image field of the camera and the horizontal pixel position is fixed.

[0031] Before the detection begins, a calibration image containing the laser contour line is acquired. A rectangular area of ​​a preset width is set as the laser contour line area, with the pixel column coordinates where the center line of the laser contour line in the calibration image is located as the center, and the area outside the laser contour line area is set as the diffuse reflection area.

[0032] During the detection process, the camera continuously acquires raw images at a preset frame rate, and each raw image is divided into regions according to the laser contour area and the diffuse reflection area.

[0033] It should be noted that in this embodiment, both the camera and the linear laser generator are fixedly mounted on a rigid bracket at the inspection station. During the inspection process, their relative positions remain unchanged. Meanwhile, the pipe under test moves at a constant speed only in the conveying direction. Its lateral position in the image field of view is limited by the guide wheels on the conveying rollers, and the lateral swing amplitude is controlled within a preset tolerance range. Under the above conditions, the lateral pixel coordinates of the center line of the laser contour in the image field of view remain constant after calibration.

[0034] The method for setting the rectangular area of ​​the preset width is as follows: scan the gray value of each pixel in the calibration image column by column along the extension direction of the laser line, record the position of the pixel with the largest gray value in each column to obtain the initial center line point set, then perform straight line fitting on the initial center line point set, take the average pixel column coordinates of each point on the fitted line as the pixel column coordinates where the center line is located, and then expand the column width to the left and right by a preset number of pixels (for example, expand by 50 pixels each) with the column coordinates as the center, thereby defining the rectangular area of ​​the preset width.

[0035] In the camera's image field of view, the remaining pixel area, excluding the rectangular area of ​​the laser contour line and corresponding to the imaging range of the pipe surface under test, is designated as the diffuse reflection area, which is used for subsequent analysis of diffuse reflection spots caused by defects such as cracking and peeling.

[0036] The above calibration procedure does not require repeated calibration during batch continuous testing of pipes of the same specification. The division of the laser contour area and the diffuse reflection area remains unchanged. It is only re-executed when the installation position of the camera or laser generator changes, or when different specifications of pipes are replaced, resulting in a significant change in the imaging range.

[0037] Furthermore, it should be clarified that the original image contains both laser contour line signals and diffuse reflection spot signals. These are not two physically separated independent images, but rather spatially separated within the same grayscale image through the aforementioned region division. The purpose of this region division step is to provide different image data sources for subsequent steps.

[0038] Those skilled in the art should understand that the above-mentioned region division does not involve the identification or judgment of defects in the image content, but is only a spatial segmentation method for data preprocessing, and is independent of the subsequent defect detection steps in terms of function and timing.

[0039] In one embodiment of the present invention, the step of extracting a one-dimensional cross-sectional contour sequence along the laser line extension direction includes:

[0040] Scan each column of pixels in the original image of the laser contour region along the direction perpendicular to the laser line extension, record the pixel with the largest gray value in each column and its sub-pixel coordinates, and obtain the initial center line point set;

[0041] Taking each column of pixels in the initial centerline point set as the center, the gray values ​​of each pixel in its preset width neighborhood are taken as weights, and the gray-weighted centroid coordinates are calculated. The corresponding sub-pixel coordinates in the initial centerline point set are replaced with the gray-weighted centroid coordinates to obtain the corrected centerline point set.

[0042] The corrected centerline point set is subjected to median filtering along the laser line extension direction to remove outliers whose gray values ​​deviate from the mean of their neighborhood by more than a preset outlier threshold, thus obtaining the final centerline point set.

[0043] Extract the lateral coordinates and corresponding longitudinal offsets of each point in the final centerline point set to form a one-dimensional cross-sectional profile sequence.

[0044] It should be noted that, in this embodiment, the laser line extension direction refers to the direction in which the laser outline extends along the width of the pipe in the image field of view, and the direction perpendicular to it is the cross-sectional direction of the laser line in the image, that is, the direction of height change on the surface of the pipe.

[0045] The sub-pixel coordinates are obtained by performing a second parabolic interpolation on the gray value of the peak pixel and one adjacent pixel to its left and right near the gray value peak of each column of pixels, and taking the position of the vertex of the interpolated parabola as the sub-pixel level column coordinates of the center of the laser line.

[0046] The specific calculation method for grayscale weighted centroid coordinates is as follows: take the pixel with the largest grayscale value in each column as the center, take the grayscale values ​​of each pixel in a preset width neighborhood (e.g., 5 pixels on the left and right, the specific width can be set according to the actual width of the laser line in the image) as weights, and perform a weighted average on the coordinates of all pixels in the neighborhood. The resulting weighted average value is the grayscale weighted centroid coordinate of the column, which serves as the precise position of the center of the laser line in that column.

[0047] In this embodiment, a sliding window of a preset length is set along the extension direction of the laser line. The vertical coordinate values ​​of each point in the window are sorted sequentially, and the median value is taken as the filtering result of that point to eliminate outlier jump points caused by local reflections or tiny impurities on the galvanized surface. The preset outlier threshold can be set according to the actual imaging quality and the fluctuation range of the laser line width, preferably 1.5 to 3 times the standard deviation of the vertical coordinates in the window.

[0048] Those skilled in the art should understand that, in this embodiment, the specific parameters of grayscale peak scanning combined with grayscale weighted centroid correction, such as neighborhood width, median filter window length, outlier threshold multiple, etc., can be determined through a limited number of experiments based on actual imaging conditions.

[0049] In one embodiment of the present invention, after obtaining the one-dimensional cross-sectional profile sequence, the method further includes a step of performing signal abrupt change analysis:

[0050] A first-order difference operation is performed on each point in the one-dimensional cross-sectional profile sequence along the width direction of the pipe to obtain a difference sequence;

[0051] A sliding window of preset length is used to traverse the difference sequence along the width of the pipe. The mean and standard deviation of the difference values ​​within the range covered by the sliding window are calculated. The sum of the mean and the standard deviation of the preset multiple is used as the dynamic mutation threshold.

[0052] When any difference value of the difference sequence within the sliding window exceeds the dynamic mutation threshold, the sampling point corresponding to that difference value in the one-dimensional cross-sectional profile sequence is recorded as the mutation start point.

[0053] Starting from the mutation start point, check the sign of each subsequent difference value in the increasing direction of the sampling points. If a preset number of difference values ​​appear consecutively within the preset search range and their signs are opposite to those of the difference values ​​at the mutation start point, it is determined that the signal waveform has undergone local reverse deflection.

[0054] The difference between the contour value at the mutation initiation point and the contour value at the first extreme point after the judgment is calculated as the amplitude value of the local reverse deflection. When the amplitude value exceeds the preset bending threshold, it is determined that there is bending deformation in the current section.

[0055] It should be noted that the contour sequence of a normal, flat pipe surface is approximately a horizontal straight line, and its difference value fluctuates slightly around zero. However, when there is bending deformation on the pipe surface, the contour sequence of the deformed area experiences local undulations, and the difference value at the corresponding position will show significant positive or negative peaks.

[0056] The surface of galvanized pipes has slight undulations and imaging noise caused by the manufacturing process. Using a fixed threshold can easily lead to false detections or missed detections. In this embodiment, the local mean and standard deviation are calculated by sliding window, and then a dynamic threshold is set that is adaptively adjusted according to the reference height and roughness of different areas of the pipe surface. This effectively suppresses false detections while ensuring the detection rate.

[0057] The mutation initiation point refers to the sampling point where the difference value first exceeds the dynamic mutation threshold. Physically, it represents the initial boundary position of the bending deformation region. Starting from the mutation initiation point, the search proceeds along the increasing direction of the sampling points. The first local maximum or local minimum point that appears after the reverse deflection is determined is the extreme value type, which is determined by the deflection direction at the mutation initiation point. That is, if the difference value at the mutation initiation point is positive, the first extreme point after the reverse deflection is a local maximum; if the difference value at the mutation initiation point is negative, the first extreme point after the reverse deflection is a local minimum.

[0058] In a preferred embodiment, if the difference value at the mutation start point is positive, then a preset number (e.g., 3 consecutive) of negative difference values ​​must subsequently appear before the signal waveform is considered to have completed the reverse deflection from rising to falling, and vice versa. This judgment rule is used to exclude isolated symbol fluctuations caused by noise, and to ensure that the detected reverse deflection has sufficient persistence and physical significance. In addition, the difference between the contour value at the mutation start point and the difference value at the extreme point reflects the actual depth or height of the bending deformation.

[0059] In one embodiment of the present invention, the image acquisition process further includes a step of dynamically controlling the gain of dark field illumination:

[0060] After the pipe under test passes through the detection area, the grayscale mean of the image of all its diffuse reflection areas is calculated. If the grayscale mean is lower than the preset lower brightness threshold, a first gain adjustment signal is generated to control the increase of the driving current of the low-angle dark field illumination source. If the grayscale mean is higher than the preset upper brightness threshold, a second gain adjustment signal is generated to control the decrease of the driving current of the low-angle dark field illumination source.

[0061] It should be noted that the surface reflectivity of the galvanized layer of the same pipe is relatively uniform along its length. However, the surface reflectivity of different pipes may vary due to differences in raw material batches, fluctuations in galvanizing process parameters, or cooling conditions. Therefore, in this embodiment, the dynamic gain control step is triggered after each pipe under test has completely passed through the detection area, rather than being adjusted in real time during the detection of a single pipe. The illumination brightness is slowly adjusted by the feedback of the grayscale average value after each pipe is detected, so that the imaging brightness of subsequent pipes remains within a stable range.

[0062] In this embodiment, the "preset lower limit threshold" and the "preset upper limit threshold" are fixed parameters that are preset during the system debugging phase based on the dynamic range of the imaging sensor and the minimum requirements for image contrast in the subsequent grayscale segmentation steps. Together, they constitute the allowable brightness range.

[0063] The first gain adjustment signal and the second gain adjustment signal are used to control the output current of the light source driving circuit. They are preferably analog voltage signals or PWM signals, and those skilled in the art can adapt them according to the interface type of the selected LED light source driver.

[0064] Preferably, the single adjustment step size of the drive current is set to no more than 5% of the current drive current. At the same time, this dynamic gain control step only targets the low-frequency slow changes in light source brightness caused by heat decay due to long-term operation, changes in ambient temperature, or batch fluctuations in the reflectivity of the pipe surface. It is not a non-permanent feedback control loop and does not require high real-time response. When continuously testing pipes of the same specification in batches and under stable lighting conditions, those skilled in the art can choose to skip this step according to the actual situation of the production line.

[0065] In one embodiment of the present invention, the step of extracting its wave characteristics, and determining the presence of peeling or axial cracking if the axial span of the wave characteristics is less than a preset span threshold and the amplitude exceeds a preset intensity threshold includes:

[0066] The overall trend term of the one-dimensional row projection signal is extracted by using moving average filtering. The overall trend term is then subtracted from the one-dimensional row projection signal to obtain the zero-mean fluctuation signal.

[0067] Extract the local maxima points in the zero-mean fluctuation signal where the amplitude exceeds a preset intensity threshold. Using the pixel row position corresponding to each local maxima point as the center, search forward and backward along the pipe conveying direction until the fluctuation signal amplitude drops below a preset proportion of the preset intensity threshold. Mark them as the start point and end point respectively, and use the axial distance between them as the axial span of the fluctuation feature.

[0068] If the axial span is less than the preset span threshold, the fluctuation feature is determined to correspond to a peeling defect; if the axial span is greater than or equal to the preset span threshold, the fluctuation feature is determined to correspond to an axial cracking defect.

[0069] It should be noted that, in this embodiment, the one-dimensional row projection signal is a one-dimensional signal obtained by accumulating or averaging the gray values ​​of each row of pixels in the candidate defect region along the pipe conveying direction. Its horizontal axis corresponds to the pixel row position in the pipe length direction, and its vertical axis corresponds to the cumulative gray value of all candidate defect pixels at that pixel row position.

[0070] The window length of the moving average filter can be determined according to the pipe conveying speed and the camera frame rate, preferably set to 11 pixel rows. The window slides point by point on the one-dimensional row projection signal, and the average value of each point in the window is used as the trend term of that point. This trend term represents the low-frequency variation component caused by factors such as uneven overall brightness of the pipe, gradual change in the thickness of the galvanized layer, or uneven distribution of the lighting field. Subtracting it from the original signal can eliminate interference components and highlight the local fluctuations caused by defects.

[0071] In this embodiment, the preset ratio is a positive number less than 1, preferably 0.3, that is, when the fluctuation amplitude is less than 30% of the preset intensity threshold, the boundary of the fluctuation feature is considered to terminate; wherein, during the forward and backward search process, if no point satisfying the above termination condition is found within the search range, the boundary of the search range is used as the starting point or the ending point to ensure that each fluctuation feature has a definite boundary.

[0072] Axial span is the distance the fluctuation feature extends along the length of the pipe, calculated by combining the difference in the number of pixel rows between the end point and the start point with camera calibration parameters, and is measured in millimeters. Peeling defects are usually localized in the form of dots or patches, with a shorter axial span, for example, less than 20 mm. Axial cracking defects, on the other hand, extend continuously along the length of the pipe, with a longer axial span, for example, greater than or equal to 20 mm.

[0073] In this embodiment, the wave feature extraction and determination process uses only one-dimensional projection signals and does not involve morphological reconstruction of defect areas in two-dimensional images or classifier training, which can run in real time on low-cost embedded processors.

[0074] For those skilled in the art, moving average filtering and zero-mean processing are well-known signal preprocessing techniques. The preset values ​​of their window length and termination conditions can be obtained through a limited number of experiments, without the need for creative effort.

[0075] In one embodiment of the present invention, before extracting candidate defect regions, a step of adaptively adjusting a preset grayscale threshold based on illumination intensity is further included:

[0076] After each frame of the original image is acquired, a background grayscale image is acquired with only the low-angle dark field illumination source turned on and the linear laser generator turned off.

[0077] Calculate the mean and standard deviation of the grayscale values ​​of the background grayscale image, and then calculate the preset grayscale threshold for the current frame using the following formula:

[0078] ;

[0079] in, The preset ratio coefficient and the preset threshold are limited to a preset range. If the upper or lower limit of the preset range is exceeded, the corresponding upper or lower limit value is taken.

[0080] It should be noted that in this embodiment, the background grayscale image and the original image are not acquired simultaneously, but are acquired in a time-division manner within the same detection period. The time interval between the two is determined by the frame interval of the camera. Within this time interval, the displacement of the pipe along the conveying direction is much smaller than the physical size corresponding to one pixel. Therefore, the background grayscale image and the original image can be regarded as corresponding to the same surface area of ​​the pipe.

[0081] The linear laser generator is controlled by digital I / O signals, with a response time in the microsecond range (less than 1 second). The time interval is much shorter than the camera's frame interval (20ms to 50ms). Therefore, it is entirely feasible in terms of time to complete the operation of turning off the laser, acquiring the background image, turning the laser back on, and acquiring the original image in the next frame between two adjacent frames.

[0082] Preset scaling factor The value is pre-calibrated by a person skilled in the art based on the actual object being tested (the grayscale contrast statistical characteristics of peeling and cracking defects) and the dynamic range of the imaging system, and is usually between 2 and 5.

[0083] In one embodiment of the present invention, the step of converting the first defect time and the second defect time into the position information of each defect along the pipe length direction based on the pre-calibrated ratio between the camera's frame rate and the pipe conveying speed includes:

[0084] A rotary encoder is provided and installed on the end of the pipe conveying roller. The rotary encoder generates pulse signals as the conveying roller rotates. The frequency of the pulse signals is proportional to the conveying speed of the pipe to be tested.

[0085] While the camera is acquiring each frame of raw image, the cumulative pulse count value of the rotary encoder at the current moment is read and stored synchronously, and associated with the acquisition time of that frame of image.

[0086] Before the test begins, a calibration procedure is performed: a pipe to be tested is made to pass through the test area at a known speed at a constant speed, and the time interval corresponding to the acquisition frame rate of the camera and the pulse increment of the rotary encoder within the corresponding time interval are recorded simultaneously. Based on this, the pre-calibration ratio coefficient between the cumulative pulse count value and the displacement of the pipe to be tested is calculated.

[0087] During the detection process, the first cumulative pulse count value associated with the first defect time and the second cumulative pulse count value associated with the second defect time are read respectively;

[0088] Multiply the first and second cumulative pulse count values ​​by the pre-calibrated scaling factor to obtain the position information of the corresponding defect along the length of the pipe to be tested.

[0089] It should be noted that, in this embodiment, the displacement of the pipe to be measured... The specific calculation method is as follows: the time interval corresponding to the camera's capture frame rate (i.e., inter-frame time, denoted as...) Multiply by the known velocity (denoted as) ),Right now

[0090] At the same time, the pulse increment of the rotary encoder within the same time interval is recorded (denoted as...). Then the pre-calibration ratio coefficient Its physical meaning is the pipe displacement corresponding to each pulse (unit: mm / pulse).

[0091] Preferably, during the calibration process, samples can be collected multiple times at different time intervals. and The average of multiple sets of calculation results is taken as the final pre-calibration ratio coefficient to reduce the impact of single measurement error on calibration accuracy.

[0092] It should be further explained that, at the same time that the external trigger signal of the camera takes effect and the camera begins exposure, the current count value of the rotary encoder is synchronously latched through hardware interrupt or latch, and the count value is stored in the image data as the timestamp information of the frame image, ensuring that the cumulative pulse count value and the image frame have a strict correspondence at the same moment.

[0093] Furthermore, those skilled in the art should understand that the resolution (i.e., the number of pulses per revolution) of the rotary encoder should be selected based on the conveying speed of the pipe to be tested and the required positioning accuracy. For square pipe deformation defect detection scenarios, a conventional incremental encoder (such as 1024 or 2048 pulses per revolution) is preferred in conjunction with the conveyor roller diameter calculation. This is during the encoder pulse signal acquisition process.

[0094] In one embodiment of the present invention, before multiplying the first cumulative pulse count value and the second cumulative pulse count value by the pre-calibrated proportional coefficient, a dynamic speed compensation correction step is further included:

[0095] Using the frame containing the first defect moment or the second defect moment as a reference, calculate the actual pulse frequency within a preset number of frames prior to that frame;

[0096] Based on the time interval corresponding to the camera's acquisition frame rate obtained in the calibration step and the pulse increment of the rotary encoder within the corresponding time interval, the theoretical pulse frequency is calculated.

[0097] The instantaneous velocity correction coefficient is obtained by comparing the actual pulse frequency with the theoretical pulse frequency.

[0098] Multiply the pre-calibrated proportional coefficient by the instantaneous speed correction coefficient to obtain the corrected proportional coefficient, and replace the pre-calibrated proportional coefficient.

[0099] It should be noted that in this embodiment, the frame containing the first defect moment or the second defect moment is taken as the reference frame. The cumulative pulse count value of the N consecutive frames preceding the frame is taken, the total pulse increment within the time span of the N frames is calculated, and then divided by the time span corresponding to the N frames to obtain the actual pulse frequency at that moment.

[0100] The theoretical pulse frequency is a reference frequency calculated based on the data recorded during the calibration process. The calculation formula is as follows:

[0101] Theoretical pulse frequency = pulse increment during calibration / inter-frame time interval during calibration;

[0102] The theoretical pulse frequency corresponds to the pipe conveying speed under calibrated conditions, that is, the pulse frequency corresponding to the ideal, preset conveying speed.

[0103] The formula for calculating the instantaneous velocity correction factor is:

[0104] Instantaneous velocity correction factor = Actual pulse frequency / Theoretical pulse frequency;

[0105] The instantaneous speed correction factor reflects the degree of deviation between the actual conveying speed and the calibrated speed. If it is equal to 1, it means that the actual speed is consistent with the calibrated speed and no correction is required. If it is greater than 1, it means that the actual speed is higher than the calibrated speed and the corrected proportional coefficient should be increased appropriately. If it is less than 1, it means that the actual speed is lower than the calibrated speed and the corrected proportional coefficient should be decreased appropriately.

[0106] The formula for calculating the corrected proportional coefficient is:

[0107] Corrected proportional coefficient = Pre-calibrated proportional coefficient × (Actual pulse frequency / Theoretical pulse frequency);

[0108] The corrected proportional coefficient reflects the actual pipe displacement corresponding to each pulse under the current actual speed conditions.

[0109] When calculating the actual pulse frequency, the selection of the preset frame number N should take into account both response speed and stability. Those skilled in the art can optimize the setting based on encoder resolution, transmission speed, and camera frame rate. Preferably, N is set to 1. frame.

[0110] Those skilled in the art should understand that the dynamic velocity compensation correction step is triggered only when a defect is detected (i.e., the first defect moment or the second defect moment), rather than performing the correction for every frame of the image, in order to avoid unnecessary computational overhead; for image frames where no defect is detected, there is no need to perform velocity compensation correction.

[0111] Because the positioning accuracy requirement for detecting deformation defects in square tubes is usually... The fluctuation in production line conveyor speed is generally within Therefore, the positioning error can be controlled within an acceptable range through dynamic speed compensation correction.

[0112] As one embodiment of the present invention, the step of marking defects on the pipe surface using a marking execution device based on the type and corresponding location information of each defect includes:

[0113] During the transportation of the pipe under test, the current distance between the target position indicated by the location information corresponding to each defect on the pipe under test and the marking execution device is monitored in real time. When the current distance is less than or equal to the preset trigger distance, a trigger signal is generated.

[0114] The marking execution device selects the target spraying mechanism associated with the defect type from at least two different color spraying mechanisms according to the defect type corresponding to the trigger signal, and sends an opening command to the target spraying mechanism;

[0115] In response to the activation command, the target spraying mechanism sprays a color mark matching the defect type onto the corresponding position on the surface of the pipe to be tested.

[0116] It should be noted that in this embodiment, the marking execution device is installed at a fixed position downstream of the camera, and the distance between it and the front end of the pipe is a fixed value after installation. When the pipe moves forward during the conveying process, the position reached by the front end of the pipe is determined in real time by the cumulative pulse count value of the rotary encoder. Based on this, the current distance between the target position of the defect and the marking execution device can be dynamically calculated.

[0117] In different color spraying mechanisms, the mapping relationship between color and defect type is pre-associated and stored in the system. For example, the first color spraying mechanism is associated with inward bending deformation defects (marked in red), and the second color spraying mechanism is associated with peeling or axial cracking defects (marked in yellow). When the defect type is different, the trigger signal contains different identification bit information, and the marking execution device selects the corresponding spraying mechanism for spraying according to the identification bit.

[0118] Preferably, if a defect is detected in multiple consecutive frames and the same defect is marked multiple times, if the difference between the location information of adjacent defects is less than a preset distance threshold, then they are determined to belong to the same defect, and the defect is marked only once.

[0119] The spraying mechanism can use a high-pressure spraying device driven by a pneumatic spray valve or a solenoid valve. The sprayed paint color forms a circular color spot with a diameter of about 10mm to 30mm on the surface of the pipe, which is easy to identify by the naked eye.

[0120] Those skilled in the art should understand that the marking execution device can mark the defect location during the offline process after the pipe inspection is completed, or it can be integrated into the downstream of the inspection area; the color marking method is carried out on the pipe surface by physical marking, which facilitates direct visual identification in subsequent sorting, cutting and quality inspection processes without relying on electronic devices or network communication; in addition, those skilled in the art can determine the specific type selection and color matching scheme of the spraying mechanism with at least two different colors according to actual needs.

[0121] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A machine vision-based method for detecting deformation defects in galvanized round-to-square pipes, characterized in that, The method includes: S1, the pipe to be tested is passed through a detection area with a linear laser generator and low-angle dark field illumination, and the original image of the surface of the pipe to be tested is acquired by a camera. The original image includes the laser contour area and the diffuse reflection area. S2, Based on the original image of the laser contour line region, extract a one-dimensional cross-sectional contour sequence along the laser line extension direction and perform signal mutation analysis. If a local reverse deflection of the signal waveform is detected and the deflection amplitude exceeds the preset bending threshold, it is determined that there is bending deformation, and the corresponding acquisition time is recorded as the first defect time. S3. Based on the original image of the diffuse reflection area, the pixel area with gray value exceeding the preset gray value threshold is extracted as the candidate defect area. Gray value projection is performed on each row of pixels in the candidate defect area along the pipe conveying direction to generate a one-dimensional row projection signal. Its fluctuation characteristics are extracted. If the axial span of the fluctuation characteristics is less than the preset span threshold and the amplitude exceeds the preset intensity threshold, it is determined that there is peeling or axial cracking. The corresponding acquisition time is recorded as the second defect time. S4, based on the pre-calibrated ratio between the camera's frame rate and the pipe conveying speed, the first defect time and the second defect time are converted into the position information of each defect in the pipe length direction. S5, based on the type and corresponding location information of each defect, marks the defects on the surface of the pipe through the marking execution device.

2. The method for detecting deformation defects in galvanized round-to-square pipes based on machine vision according to claim 1, characterized in that: The steps involved in dividing the original image into laser contour regions and diffuse reflection regions include: A monocular area array camera and a single linear laser generator are deployed above the pipe conveying line. The single linear laser generator projects obliquely at a preset angle to the normal of the surface of the pipe to be tested. The laser contour line obtained by projection extends along the width direction of the pipe in the image field of view of the camera and the lateral pixel position is fixed. Before the detection begins, a calibration image containing the laser contour line is acquired. A rectangular area of ​​a preset width is set as the laser contour line area, with the pixel column coordinates where the center line of the laser contour line in the calibration image is located as the center, and the area outside the laser contour line area is set as the diffuse reflection area. During the detection process, the camera continuously acquires original images at a preset frame rate, and each frame of the original image is divided into regions according to the laser contour area and the diffuse reflection area.

3. The method for detecting deformation defects in galvanized round-to-square pipes based on machine vision according to claim 1, characterized in that: The steps for extracting the one-dimensional cross-sectional contour sequence along the laser line extension direction include: The original image of the laser contour region is scanned along each column of pixels perpendicular to the laser line extension direction, and the pixel with the largest gray value in each column and its sub-pixel coordinates are recorded to obtain the initial center line point set. Taking each column of pixels in the initial centerline point set as the center, the gray values ​​of each pixel in its preset width neighborhood are taken as weights, and the gray-weighted centroid coordinates are calculated. The gray-weighted centroid coordinates are then used to replace the corresponding sub-pixel coordinates in the initial centerline point set to obtain the corrected centerline point set. The modified centerline point set is subjected to median filtering along the laser line extension direction to remove outliers whose gray values ​​deviate from the mean of their neighborhood by more than a preset outlier threshold, thus obtaining the final centerline point set. Extract the lateral coordinates and corresponding longitudinal offsets of each point in the final centerline point set to form the one-dimensional cross-sectional profile sequence.

4. The method for detecting deformation defects in galvanized round-to-square pipes based on machine vision according to claim 3, characterized in that: After obtaining the one-dimensional cross-sectional profile sequence, the process also includes a step of signal mutation analysis: A first-order difference operation is performed on each point in the one-dimensional cross-sectional profile sequence along the pipe width direction to obtain a difference sequence; The difference sequence is traversed along the width direction of the pipe using a sliding window of a preset window length. The mean and standard deviation of the difference values ​​within the range covered by the sliding window are calculated. The sum of the mean and the standard deviation by a preset multiple is calculated as the dynamic mutation threshold. When any difference value of the difference sequence within the sliding window exceeds the dynamic mutation threshold, the sampling point corresponding to that difference value in the one-dimensional cross-sectional contour sequence is recorded as the mutation start point. Starting from the mutation start point, check the sign of each subsequent difference value in the increasing direction of the sampling points. If a preset number of difference values ​​appear consecutively within the preset search range and their signs are opposite to those of the difference values ​​at the mutation start point, it is determined that the signal waveform has undergone a local reverse deflection. The difference between the contour value at the mutation initiation point and the contour value at the first extreme point after the determination is calculated as the amplitude value of the local reverse deflection. When the amplitude value exceeds the preset bending threshold, it is determined that the current cross-section has bending deformation.

5. The method for detecting deformation defects in galvanized round-to-square pipes based on machine vision according to claim 1, characterized in that: The image acquisition process also includes a step of dynamically controlling the gain of dark field illumination: After the pipe under test passes through the detection area, the average gray value of the image of all its diffuse reflection areas is calculated. If the average gray value is lower than the preset lower brightness threshold, a first gain adjustment signal is generated to control the increase of the driving current of the low-angle dark field illumination source. If the average gray value is higher than the preset upper brightness threshold, a second gain adjustment signal is generated to control the decrease of the driving current of the low-angle dark field illumination source.

6. The method for detecting deformation defects in galvanized round-to-square pipes based on machine vision according to claim 1, characterized in that: Its fluctuation characteristics are extracted. If the axial span of the fluctuation characteristic is less than a preset span threshold and the amplitude exceeds a preset intensity threshold, the steps to determine whether peeling or axial cracking exists include: The overall trend term of the one-dimensional row projection signal is extracted by using a moving average filter, and the overall trend term is subtracted from the one-dimensional row projection signal to obtain a zero-mean fluctuation signal. Extract the local maxima points in the zero-mean fluctuation signal where the amplitude exceeds a preset intensity threshold. Using the pixel row position corresponding to each local maxima point as the center, search forward and backward along the pipe conveying direction until the fluctuation signal amplitude drops below a preset proportion of the preset intensity threshold. Mark these points as the start point and end point, respectively, and use the axial distance between them as the axial span of the fluctuation feature. If the axial span is less than a preset span threshold, the fluctuation feature is determined to correspond to a peeling defect; if the axial span is greater than or equal to the preset span threshold, the fluctuation feature is determined to correspond to an axial cracking defect.

7. The method for detecting deformation defects in galvanized round-to-square pipes based on machine vision according to claim 1, characterized in that: Before extracting candidate defect regions, the process also includes an adaptive adjustment step of a preset grayscale threshold based on illumination intensity. After each frame of the original image is acquired, a background grayscale image is acquired with only the low-angle dark field illumination source turned on and the linear laser generator turned off. Calculate the mean gray level and standard deviation of the background grayscale image, and then calculate the preset grayscale threshold for the current frame using the following formula: in, The preset threshold is a preset proportional coefficient and is limited to a preset range. If the upper or lower limit of the preset range is exceeded, the corresponding upper or lower limit value is taken.

8. The method for detecting deformation defects in galvanized round-to-square pipes based on machine vision according to claim 1, characterized in that: The step of converting the first defect time and the second defect time into the position information of each defect along the pipe length direction based on the pre-calibrated ratio between the camera's frame rate and the pipe conveying speed includes: A rotary encoder is provided, which is installed on the shaft end of a pipe conveying roller. The rotary encoder generates pulse signals as the conveying roller rotates, and the frequency of the pulse signals is proportional to the conveying speed of the pipe to be tested. While the camera is capturing each frame of the original image, the cumulative pulse count value of the rotary encoder at the current moment is read and stored synchronously, and associated with the capture time of that frame of the image. Before the test begins, a calibration procedure is performed: a pipe to be tested is made to pass through the test area at a known speed at a constant speed, and the time interval corresponding to the acquisition frame rate of the camera and the pulse increment of the rotary encoder within the corresponding time interval are recorded simultaneously. Based on this, the pre-calibration ratio coefficient between the cumulative pulse count value and the displacement of the pipe to be tested is calculated. During the detection process, the first cumulative pulse count value associated with the first defect time and the second cumulative pulse count value associated with the second defect time are read respectively; Multiply the first cumulative pulse count value and the second cumulative pulse count value by the pre-calibration ratio coefficient to obtain the position information of the corresponding defect in the length direction of the pipe to be tested.

9. The method for detecting deformation defects in galvanized round-to-square pipes based on machine vision according to claim 8, characterized in that: Before multiplying the first cumulative pulse count value and the second cumulative pulse count value by the pre-calibrated proportional coefficient, the process also includes a dynamic speed compensation correction step: Using the frame containing the first defect moment or the second defect moment as a reference, calculate the actual pulse frequency within a preset number of frames prior to that frame; Based on the time interval corresponding to the camera's acquisition frame rate obtained in the calibration step and the pulse increment of the rotary encoder within the corresponding time interval, the theoretical pulse frequency is calculated; The actual pulse frequency is compared with the theoretical pulse frequency to obtain the instantaneous velocity correction coefficient; Multiply the pre-calibrated proportional coefficient by the instantaneous velocity correction coefficient to obtain the corrected proportional coefficient, and replace the pre-calibrated proportional coefficient.

10. The method for detecting deformation defects in galvanized round-to-square pipes based on machine vision according to claim 1, characterized in that: The step of marking defects on the pipe surface using a marking device, based on the type and location information of each defect, includes: During the transportation of the pipe under test, the current distance between the target position indicated by the position information corresponding to each defect on the pipe under test and the marking execution device is monitored in real time. When the current distance is less than or equal to the preset trigger distance, a trigger signal is generated. The marking execution device selects a target spraying mechanism associated with the defect type from the at least two different color spraying mechanisms according to the defect type corresponding to the trigger signal, and sends an opening command to the target spraying mechanism; In response to the activation command, the target spraying mechanism sprays a color mark matching the defect type at the corresponding position on the surface of the pipe to be tested.