CN115471455A - Method and device for detecting pipe defects based on backlight image - Google Patents

Method and device for detecting pipe defects based on backlight image Download PDF

Info

Publication number
CN115471455A
CN115471455A CN202211012259.9A CN202211012259A CN115471455A CN 115471455 A CN115471455 A CN 115471455A CN 202211012259 A CN202211012259 A CN 202211012259A CN 115471455 A CN115471455 A CN 115471455A
Authority
CN
China
Prior art keywords
flaring
backlight
pipe
section
image
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211012259.9A
Other languages
Chinese (zh)
Inventor
林建宇
潘凌锋
张一航
陈浙泊
江芸
陈龙威
余建安
陈一信
叶雪旺
陈镇元
吴荻苇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Research Institute of Zhejiang University Taizhou
Original Assignee
Research Institute of Zhejiang University Taizhou
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Research Institute of Zhejiang University Taizhou filed Critical Research Institute of Zhejiang University Taizhou
Publication of CN115471455A publication Critical patent/CN115471455A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • G06T7/0004Industrial image inspection
    • G06T5/80
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/11Region-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/13Edge detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/80Analysis of captured images to determine intrinsic or extrinsic camera parameters, i.e. camera calibration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30244Camera pose

Abstract

The invention discloses a method and a device for detecting defects of a pipe based on a backlight image, wherein the method comprises the steps of collecting a pipe image shot by a camera under backlight as the backlight image, calculating un-flaring section graphic data in the backlight image, judging whether the un-flaring section graphic data are in a safe un-flaring section graphic parameter range, judging that the pipe has defects if the un-flaring section graphic data are not in the safe un-flaring section graphic parameter range, obtaining a flaring profile on the backlight image by an edge searching method, matching the flaring profile with a first flaring template to generate a matching displacement and a matching angle, carrying out position correction on the flaring profile according to the matching displacement and the matching angle to obtain a backlight flaring section area, generating flaring section graphic data according to the backlight flaring section area, judging whether the flaring section graphic data are in the safe flaring section graphic parameter range or not, and judging that the pipe has defects if the flaring section graphic data are not in the safe flaring section graphic parameter range.

Description

Method and device for detecting pipe defects based on backlight image
Technical Field
The invention belongs to a detection technology, and particularly relates to a method and a device for detecting pipe defects based on a backlight image.
Background
The pipe is generally a plastic pipe formed by compounding polyvinyl chloride resin with a stabilizer, a lubricant and the like and then performing extrusion molding by a hot pressing method. After the pipe is flared, the pipe can be used for realizing the connection of two pipes without connecting through a transfer pipe, and the production cost and the construction cost are greatly reduced. The flaring process of the pipe generally adopts a high-temperature iron rod to be inserted into one end of the pipe, so that the flaring effect of the end part of the pipe is achieved.
However, when two pipes are connected through the flaring, extremely high requirements are placed on the depth, width, angle, flaring quality and the like of the flaring, once the indexes do not meet the requirements, the pipes can be connected in a problem, and the produced pipes cannot be used.
The flaring production line is very easy to be caused by the problems of wrong parameter setting of the flaring equipment, abnormal equipment and the like, so that the quality of produced pipes is unqualified, the current technology capable of measuring the flaring size of the pipes on line and detecting the flaring defects is lacked, the flaring abnormality of the pipes cannot be detected in time, the accident that the large-batch unqualified pipes are processed by the flaring production line is probably caused, and huge economic loss is caused for manufacturers.
Disclosure of Invention
In order to overcome the defects and problems in the prior art, the invention provides a method and a device for detecting the defects of a tube based on a backlight image.
In order to achieve the purpose, the invention adopts the following technical scheme:
a method for detecting tube defects based on backlight images comprises the following steps:
collecting a pipe image shot by a camera under backlight as a backlight image;
calculating un-flared section graphic data in the backlight image;
judging whether the graphical data of the un-flared section is located in the graphical parameter range of the safe un-flared section, and if not, judging that the pipe has defects;
acquiring a flaring profile on the backlight image by an edge searching method, matching the flaring profile with a first flaring template, and generating a matching displacement and a matching angle;
correcting the position of the flaring profile according to the matching displacement and the matching angle to obtain a backlight flaring section area;
generating flaring section graphic data according to the backlight flaring section area;
and judging whether the flaring segment graphic data are located in the safe flaring segment graphic parameter range, and if not, judging that the pipe has defects.
Preferably, the un-flared section graphic data includes the pipe diameter of the un-flared section of the pipe and the number of the pipes.
Preferably, the step of calculating the un-flared section pattern data in the backlight image specifically includes:
obtaining an edge straight line of an unexpanded section in the backlight image by an edge searching method;
and determining the pipe diameter of the non-flared section and the number of the pipes according to the edge straight line of the non-flared section.
Preferably, the flare section graphic data includes a depth, a width, an angle of the flare section, and a difference between a distance across a head of the flare section and a width of the flare section.
Preferably, the safety flaring section graphic parameter range comprises a depth range, a width range, an angle range and a difference range of the safety flaring section.
Preferably, the step of judging whether the flaring segment graphic data is located within the safe flaring segment graphic parameter range, and if not, judging that the pipe has a defect specifically comprises the following steps:
judging whether the depth of the flaring section is within the depth range of the safe flaring section or not, and if not, judging that the pipe has defects;
judging whether the width of the flaring section is within the width range of the safe flaring section or not, and if not, judging that the pipe has defects;
judging whether the angle of the flaring section is within the angle range of the safe flaring section or not, and if not, judging that the pipe has defects;
and judging whether the difference between the distance between the two ends of the head of the flaring section and the width of the flaring section is within the range of the difference of the safe flaring section, and if not, judging that the pipe has defects.
Preferably, the step of generating flare map data according to the backlight flare region specifically includes:
generating a flaring section edge straight line by adopting a straight line fitting method for a backlight flaring section area;
matching a second flaring template on the backlight flaring section area and generating matching point information;
and generating flaring segment graphic data according to the flaring segment edge straight line and the matching point information.
Preferably, the method further comprises the following steps:
and if the graphical data of the un-flared section is located in the graphical parameter range of the safe un-flared section and the graphical data of the flared section is located in the graphical parameter range of the safe flared section, judging that the pipe does not have defects.
Preferably, the edge searching method specifically includes:
dividing the backlight image into a plurality of sub-regions;
extracting edge points from white pixel points to black pixel points for each subregion;
sequentially storing the edge points of the first group of extracted different transverse coordinate components into different edge point sets;
and sequentially comparing the extracted edge points in all the other groups with the extracted edge points in the first group, and putting the edge points meeting the condition that the absolute value of the difference between the transverse coordinate components of the corresponding edge points between the two groups is smaller than a set threshold value into the corresponding edge point set established in the last step, wherein each edge point set is the left edge information of each pipe.
Preferably, before the step of taking the tube image shot by the camera under the backlight as the backlight image, the method further comprises the following steps:
the pipe is conveyed to the upper part of the background plate through the push plate, and the camera shoots the image of the pipe above the background plate.
Preferably, the step of collecting the tube image shot by the camera under backlight as the backlight image further comprises the following steps:
and judging whether the current space-time parameters of the push plate accord with the expected space-time parameters or not, if so, collecting the pipe image shot by the camera under the backlight as a backlight image, and if not, not collecting the pipe image shot by the camera under the backlight as a front light image and the pipe image shot by the camera under the backlight as a backlight image.
Preferably, when judging whether the current space-time parameter of the push plate accords with the expected space-time parameter, the method further comprises the following steps:
setting a trigger area;
and judging whether the current position of the push plate is located in the trigger area or not, and if not, displaying the backlight image.
Preferably, if the current position of the push plate is located in the trigger area, the method further comprises the following steps:
the processor collects false triggering time;
the processor judges whether the false triggering time acquired by the processor is less than a first preset time, and if the false triggering time acquired by the processor is less than the first preset time, the backlight image is not acquired.
Preferably, if the false triggering time is not less than the first preset time, the method further includes the following steps:
the processor collects delay triggering time;
the processor judges whether the acquired delay triggering time is less than a second preset time, and if so, the backlight image is not acquired.
Preferably, the method for judging whether the current spatiotemporal parameters of the push plate conform to the expected spatiotemporal parameters further comprises the following steps:
the processor collects trigger interval time;
the processor judges whether the acquired trigger interval time is less than a third preset time, and if so, the backlight image is not acquired.
Preferably, the step of collecting a tube image shot by a camera under backlight as a backlight image specifically comprises:
and if the current position of the push plate is located in the trigger area, the false 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, acquiring a pipe image shot by the camera under backlight as a backlight image.
Preferably, if the tube image shot by the camera under the backlight is collected as the backlight image, the method further comprises the following steps:
the processor acquires the push plate outline in the backlight image;
the processor compares the push plate profile with the standard push plate profile to generate matching degree;
the processor judges whether the matching degree is not greater than the safe matching degree, if not, the processor judges that the pipe is in an abnormal position,
if the current push plate contour is larger than the standard push plate contour, the processor acquires the matching angle of the current push plate contour according to the push plate contour and the standard push plate contour;
the processor judges whether the matching angle is smaller than the safe matching angle or not, if not, the processor judges that the pipe is in an abnormal position, and if so, the processor judges that the pipe is in a normal position.
Preferably, when the backlight image is collected, the method further comprises the following steps:
and carrying out distortion correction processing on the backlight image.
Preferably, the step of performing distortion correction processing on the backlight image specifically includes:
collecting a calibration plate image;
carrying out distortion correction on the calibration plate image and generating a distortion calibration file;
and carrying out distortion correction on the backlight image according to the distortion calibration file.
The invention also provides a device for detecting the defects of the tube based on the backlight image, which is realized by adopting the method for detecting the defects of the tube based on the backlight image and comprises the following steps:
a light source for lighting the back surface of the tube as a backlight;
the camera is used for shooting images on the front surface of the pipe;
the processor is used for collecting a pipe image shot by the camera under backlight to serve as a backlight image, calculating image data of an un-flared section in the backlight image, judging that the pipe has a defect if the image data of the un-flared section is not in a safe un-flared section image parameter range, obtaining a flared contour on the backlight image through an edge searching method, matching the flared contour with a first flared template to generate a matching displacement and a matching angle, correcting the position of the flared contour according to the matching displacement and the matching angle to obtain a backlight flared section area, generating flared section image data according to the backlight flared section area, and judging that the pipe has a defect if the image data of the flared section is not in a safe flared section image parameter range.
Preferably, the light source comprises a back light source, and the back light source is used for polishing the back surface of the tube to be used as a backlight.
Preferably, the pipe cutting machine further comprises a background plate which is used as a background in the pipe image shot by the camera
Preferably, the background plate is white and light-transmissive.
Preferably, the device further comprises a push plate for conveying the pipe above the background plate.
Preferably, the push plate is laterally slidable over the background plate.
Preferably, the device further comprises an optoelectronic switch, and the optoelectronic switch is used for detecting the position of the push plate.
Preferably, the trigger area of the photoelectric switch is located above the background plate.
Preferably, the camera is disposed above the background plate, and the back light source is disposed below the background plate.
Compared with the prior art, the invention has the outstanding and beneficial technical effects that:
(1) According to the invention, the un-flared section graphic data and the flared section graphic data can be generated according to the backlight images of the un-flared section and the flared section of the pipe, the defect type and the defect degree of the un-flared section can be accurately judged according to the un-flared section graphic data, and the defect type and the defect degree of the flared section can be accurately judged according to the flared section graphic data and by combining the data obtained by the un-flared section.
(2) In the invention, the flaring segment graphic data are generated by adopting the backlight image, and the backlight image has the characteristic of clear outline, thereby improving the accuracy of detecting the flaring segment graphic data.
(3) In the invention, by setting the false triggering time, the delayed triggering time and the interval triggering time of the photoelectric switch and setting the position detection of the push plate, the system error processing which is possibly generated in the feeding process is avoided, so the invention has the advantage of reliable work.
Drawings
FIG. 1 is a schematic flow chart illustrating the steps of the method for detecting defects of a tube based on a backlight image according to the present invention;
FIGS. 2-1 through 2-8 are pictorial illustrations of various types of pipe defects in accordance with the present invention;
3-1 through 3-8 are schematic illustrations of orthographic images of various pipe defect types of the present invention;
4-1 through 4-7 are schematic illustrations of backlight images of various tube defect types of the present invention;
FIG. 5 is a schematic structural diagram of a tube defect detection device based on a backlight image according to the present invention;
FIG. 6 is a schematic structural diagram of a tube defect detection device applied with a backlight image according to the present invention;
FIG. 7 is a flow chart illustrating the steps of detecting the position of the push plate according to the present invention;
FIG. 8 is a schematic flow chart of the steps of the present invention for detecting an unexpanded section of tubing;
FIG. 9 is a flowchart illustrating the steps of the edge finding method of the present invention;
FIG. 10 is a flowchart illustrating the steps of the edge point processing method according to the present invention;
FIG. 11 is a flow chart illustrating the steps of the line fitting method of the present invention;
FIG. 12 is a flow chart illustrating the steps of detection under positive light according to the present invention;
FIG. 13 is a flow chart illustrating the steps of detecting under backlight according to the present invention;
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-flaring segment and 82-non-flaring segment.
Detailed Description
To facilitate understanding of those skilled in the art, the present invention is further described below in conjunction with the accompanying drawings and the specific embodiments.
To facilitate understanding of those skilled in the art, the present invention is further described below in conjunction with the accompanying drawings and the specific embodiments.
It should be noted that when the pipe is processed by the flaring production line, a flaring section is formed at the end of the pipe, and the flaring section can be used for inserting the root of another pipe, so that the effect of connecting the two pipes together is achieved, and the connecting pipe is prevented from being used for connecting the two pipes. The flared section design greatly reduces costs in terms of production, assembly, and construction. The pipe processed by the flaring production line also comprises a non-flaring section, and the non-flaring section and the flaring section are sequentially connected together.
As shown in fig. 2-1 to 2-8, according to the feedback from the tube manufacturer and the field investigation on the flaring production line, the types of defects found in the flaring of the tube include: (1) 2-1, the end of the flared section of tubing exhibits an abnormal bulge or bend; (2) in fig. 2-2, the surface of the flaring segment of the pipe is damaged by ironing; (3) In FIGS. 2-3, the depth of the flared section of the tubing is not within tolerance, and the depth is too short or too long; (4) in FIGS. 2-4, the tubing is not flared; (5) In fig. 2-5, the front end face of the flaring segment of the pipe is uneven, and the uneven end face comprises a concave surface, a convex surface and a special shape; (6) in FIGS. 2-6, the flared section of the tubing is shown retracted; (7) In fig. 2-7, the tubing is not flared and the shaft is flattened. (8) In fig. 2-8, the flaring of the tube has the defects of obvious color difference and uneven surface color.
In order to perform defect detection on a flared tube and sort the tube with defects, as shown in fig. 1, the embodiment provides a method for detecting defects of a tube based on a backlight image, which is performed by using the device for detecting defects of a tube based on a backlight image, and comprises the following steps:
s1: conveying the pipe to the upper part of the background plate through the push plate;
s2: judging whether the current time-space parameters of the push plate accord with the expected time-space parameters or not, if so, collecting a pipe image shot by a camera under the positive light as a positive light image and a pipe image shot by a camera under the backlight as a backlight image; if not, not collecting the pipe image shot by the camera under the positive light as the positive light image and the pipe image shot by the camera under the backlight as the backlight image;
s3: carrying out distortion correction processing on the positive light image and the negative light image;
s4: calculating un-flared section graphic data in the backlight image;
s5: judging whether the graphical data of the un-flared section is positioned in the graphical parameter range of the safe un-flared section, and if not, judging that the pipe has defects;
s6: acquiring a flaring profile on the backlight image by an edge searching method, matching the flaring profile with a first flaring template, and generating a matching displacement and a matching angle;
s7, correcting the position of the flaring profile according to the matching displacement and the matching angle to obtain a backlight flaring section area, correcting the position of the backlight image according to the matching displacement and the matching angle, and obtaining a backlight flaring section graph from the corrected backlight image according to the backlight flaring section area;
s8, generating flaring segment graphic data according to the backlight flaring segment area and the positive light flaring segment graphic;
s9: and judging whether the flaring section graphic data are positioned in the safe flaring section graphic parameter range, and if not, judging that the pipe has defects.
According to the method and the device, the image data of the un-flared section and the image data of the flared section of the pipe can be generated, the defect type and the defect degree of the un-flared section can be accurately judged according to the image data of the un-flared section, and the defect type and the defect degree of the flared section can be accurately judged according to the image data of the flared section and the data obtained by combining the un-flared section.
In the invention, the flaring segment graphic data is generated by adopting the front light image and the backlight image together, the front light image has clear color expression but unclear outline, the backlight image has clear outline but can not display the surface information of the pipe, the images are combined and the flaring segment graphic data is generated by utilizing the respective advantages, and the accuracy of the flaring segment graphic data detection is improved.
In the invention, distortion correction processing is carried out on the positive light image and the negative light image, thereby eliminating distortion brought by an imaging system of a camera and improving the restoration degree of the images.
In the step of conveying the pipe to the upper part of the background plate through the push plate, the processor can control the motor to drive the push plate to convey the pipe to the upper part of the background plate. If the push plate conveys the pipe to the upper part of the background plate, the push plate is also positioned above the background plate, and the camera can shoot the image with the pipe and the push plate.
When judging whether the current space-time parameters of the push plate accord with the expected space-time parameters, the method further comprises the following steps:
setting a trigger area;
and judging whether the current position of the push plate is located in the trigger area, and if not, not collecting the positive light image and the backlight image.
Wherein the current spatiotemporal parameters of the push plate comprise a current position of the push plate and the expected spatiotemporal parameters comprise a trigger region. The trigger area is photoelectric switch's induction zone, and the trigger area adopts photoelectric switch setting in the top of background board, and the photoelectric switch is connected to the treater electricity, can carry out data communication between photoelectric switch and the treater. If the current position of the push plate is not located in the trigger area, the push plate does not convey the pipe to the upper side of 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. And if the processor does not receive the trigger signal, not collecting the image shot by the camera as the front light image and the backlight image. The trigger signal refers to a portion of the level signal generated by the photoelectric switch where an edge transition occurs.
If the current position of the push plate is located in the trigger area, further comprising the following steps:
the processor collects false triggering time;
the processor judges whether the false triggering time acquired by the processor is less than a first preset time, and if the false triggering time acquired by the processor is less than the first preset time, the positive light image and the backlight image are not acquired.
The current time-space parameters of the push plate comprise false triggering time, and the expected time-space parameters comprise first preset time. When the push plate just triggers the photoelectric switch, the push plate is likely not to be stably stopped above the background plate, and in order to enable the camera to shoot the push plate in a stable state, the processor is required to judge whether the false triggering time is less than a first preset time. The false triggering time refers to the time for keeping the trigger signal when the photoelectric switch is triggered, and the time for keeping the trigger signal is the false triggering time. The first preset time refers to the minimum reasonable time required for the push plate to be stably stopped when the photoelectric switch is triggered, and the first preset time can be preset in the processor. In actual use, if the current position of the push plate is located in the trigger area, the photoelectric switch generates a trigger signal, and if the processor receives the trigger signal, the time kept by the trigger signal is collected to serve as false trigger time. If the false triggering time acquired by the processor is less than the first preset time, the push plate is likely not to be stopped above the background plate, and the processor does not acquire the positive light image and the backlight image. And if the false triggering time is not less than the first preset time, the push plate is already stopped and stabilized above the background plate.
If the false triggering time is not less than the first preset time, further comprising the following steps:
the processor collects delay triggering time;
the processor judges whether the acquired delay triggering time is less than a second preset time, and if so, the backlight image and the front light image are not acquired.
The current time-space parameter of the push plate comprises delay triggering time, and the expected time-space parameter comprises second preset time. After the push plate is stably stopped above the background plate, the tube still may not be stably stopped above the background plate, and in order to avoid collecting an image when the tube is not stably stopped as a backlight image, the processor is required to judge whether the delay triggering time is less than a second preset time. The delay triggering time refers to the time for keeping the triggering signal after the false triggering time reaches the first preset time, and the difference value between the time for keeping the triggering signal and the first preset time is the delay triggering time. The second preset time refers to the minimum reasonable time required for the push plate to be stably stopped above the background plate and then for the pipe to be stably stopped above the background plate, and the second preset time can be preset in the processor. In actual use, if the false triggering time reaches the first preset time, the processor collects the delay triggering time, and the processor judges whether the collected delay triggering time is less than the second preset time. If the delay triggering time is less than the second preset time, the tube is likely not to be stably stopped above the background plate, and the processor does not acquire the image shot by the camera as the backlight image. And if the delay triggering time is not less than the second preset time, stopping the pipe above the stable background plate.
In addition, the method for judging whether the current space-time parameters of the push plate accord with the expected space-time parameters further comprises the following steps:
the processor collects trigger interval time;
the processor judges whether the acquired trigger interval time is less than a third preset time, and if so, the backlight image and the front light image are not acquired.
Wherein the current spatiotemporal parameter of the push plate comprises a trigger interval time, and the expected spatiotemporal parameter comprises a third preset time. After the system detects a batch of pipes, the batch of pipes need to be bundled after being discharged, and a next batch of pipes need to be loaded after the batch of pipes are bundled, so that the system needs to reserve enough bundling time between the discharging of the previous batch of pipes and the feeding of the next batch of pipes, the feeding of the pipes refers to the pipes being conveyed to the upper part of the background plate, and the discharging of the pipes refers to the pipes being unloaded from the upper part of the background plate. In order to allow the system to have enough strapping time between the previous batch of pipe blanking and the next batch of pipe feeding, the processor needs to determine whether the trigger interval time is less than a third preset time. The triggering interval time refers to the time interval between the triggering of the last photoelectric switch and the triggering of the next photoelectric switch, and corresponds to the time interval between the blanking of the pipe of the previous batch and the feeding of the pipe of the next batch. The third preset time refers to a minimum reasonable time interval between the last time of blanking and bundling the tubes of the previous batch and the next time of feeding the tubes of the next batch, and the third preset time can be preset in the processor. In actual use, if the pipe is fed in the previous batch and the pipe is fed in the next batch, the processor acquires the trigger interval time. If the trigger interval time collected by the processor is less than the third preset time, the detected pipes are probably not discharged or bundled in time, and the processor does not collect the backlight image and the front light image at the moment, namely the system does not detect the next batch of pipes, so that the problem that the next batch of pipes are detected or the pipes are not discharged in time because the previous batch of pipes are not bundled is solved. And if the triggering interval time acquired by the processor is not less than the third preset time, finishing blanking and bundling the pipes of the previous batch.
In addition, when judging whether the current space-time parameter of the push plate accords with the expected space-time parameter, the method also comprises the following steps:
the processor calculates the duration of the positive light;
the processor judges whether the duration time of the positive light obtained by calculation is less than the safety time or not, and if the duration time of the positive light is less than the safety time, the positive light image is not collected.
Wherein the current spatiotemporal parameters of the push plate include a positive light duration, and the expected spatiotemporal parameters include a safety time. Because the illumination intensity of the back light source is unstable when the back light source is just turned off and the front light source is just turned on, in order to avoid the problem that the light intensity is unstable to influence the image shot by the camera, the processor is needed to judge whether the duration time of the front light is less than the safe time. The front light duration refers to the time that the front light source is on and the back light source is off. The safe time refers to the minimum reasonable time required for the illumination intensity to become stable after the front light source is turned on and the back light source is turned off, and the safe time can be preset in the processor. In actual use, the processor controls the front light source to be turned on and the back light source to be turned off, and then calculates the duration time of the front light according to the time of turning on the front light source and the time of turning off the back light source. And if the duration time of the front light calculated by the processor is not less than the safety time, the illumination intensity of the front light source and the back light source becomes stable. If the duration time of the front light calculated and obtained by the processor is less than the safety time, the illumination intensity of the front light source and the back light source is unstable, and at the moment, the processor does not collect the front light image, so that the processor is prevented from collecting the image influenced by the unstable illumination intensity of the front light source and the back light source.
In this embodiment, the front light source and the back light source both use white light emitting LED lamps, and the safety time is 10ms.
In this embodiment, the processor collects the backlight image first and then collects the front light image. If the push plate conveys the pipe to the upper part of the background plate, the processor controls the back light source to be in an opening state and the front light source to be in a closing state.
To sum up, in the step of collecting the tube image shot by the camera under backlight as the backlight image, the method specifically comprises the following steps:
and if the current position of the push plate is located in the trigger area, the false 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, acquiring a pipe image shot by the camera under backlight as a backlight image.
And if the processor collects the pipe image shot by the camera as a backlight image, controlling the back light source to be closed and the front light source to be opened. And if the back light source is turned off and the front light source is turned on, the processor collects the pipe image shot by the camera under the front light as a front light image.
To sum up, gather under the positive light in the step of the tubular product image of shooting of camera as positive light image, specifically include:
if the current position of the push plate is located in the trigger area, the false 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 duration time of the positive light is not less than the safety time, the tubular product image shot by the camera under the positive light is collected to be used as the positive light image.
In the invention, by setting the false triggering time, the delayed triggering time and the interval triggering time of the photoelectric switch and setting the detection of the position of the push plate and the duration of the positive light, the system error processing which is possibly generated in the feeding process is avoided, so the invention has the advantage of reliable work.
As shown in fig. 3-1 to 3-8, the front light image refers to an image of the tube taken by the camera with the front light source on and the back light source off. An image taken under a single positive light can clearly display surface information such as 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 for detecting whether the surface of the pipe has the defects of ironing damage, chromatic aberration and the like.
As shown in fig. 4-1 through 4-7, the backlight image refers to the tube image taken with the front light source off and the backlight source on. A backlight image photographed under a separate backlight can clearly display the outline of the foreground. The contour of the foreground in the backlight image can be used for detecting whether the size of the pipe exceeds a tolerance, whether the end face is deformed, whether retraction and other defects exist.
The foreground in this embodiment includes tubing and push plates. The background includes a background plate. In order to better distinguish the foreground from the background from the front-lit image and the back-lit image. The background plate is transparent white, the front light source and the back light source both emit white light, the front light source is fixed above the background plate, the back light source is fixed below the background plate, and the camera is fixed above the background plate, so that the background plate can be used as a background when the camera shoots every time. The tube and the push plate are not white and have a large color difference with the background plate, specifically, the tube has a color of red, yellow, green and blue, and the push plate has a color of black, so that the camera can shoot an image containing a foreground and a background which are more different.
As shown in fig. 7, after the step of collecting the tube image shot by the camera under the backlight as the backlight image by the processor, in order to ensure the accuracy of the position of the tube conveyed to the upper side of the background plate, the position of the back pushing plate above the background plate for conveying the tube can be detected to judge whether the position is accurate or not. Specifically, if a tube image shot by a camera under backlight is collected as a backlight image, the method further comprises the following steps:
the processor acquires the outline of the push plate in the backlight image;
the processor compares the push plate profile with the standard push plate profile to generate matching degree;
the processor judges whether the matching degree is not greater than the safe matching degree or not, if not, the processor judges that the pipe is in an abnormal position,
if the push plate profile is larger than the standard push plate profile, the processor acquires the matching angle of the current push plate profile according to the push plate profile and the standard push plate profile;
the processor judges whether the matching angle is smaller than the safe matching angle, if not, the processor judges that the pipe is in an abnormal position, and if so, the processor judges that the pipe is in a normal position.
The processor acquires the push plate contour in the backlight image, namely, the processor processes the backlight image into a gray image and acquires the push plate contour in the gray image. In the gray scale image converted from the backlight image, the background is white, the foreground of the push plate as the backlight image is black, the boundary of the push plate and the background is gradually changed from black to white, in order to obtain an accurate push plate profile in the gray scale image, the edge of the push plate is obtained in the gray scale image through an edge searching method, and the edge of the push plate is processed through edge point processing to obtain the push plate profile.
The processor acquires the push plate profile in the backlight image by adopting an edge straight line searching method, so that the problem that the push plate profile acquired by the processor is possibly not a push plate exists, and the processor judges whether the matching degree is not greater than the safe matching degree and whether the matching angle is not less than the safe matching angle. The degree of match refers to how similar the shape of the blade profile is to the shape of a standard blade profile. The safe matching degree refers to the minimum value allowed by the matching degree, and the safe matching degree can be preset in the processor. The standard push plate profile refers to the profile of the push plate in the collected backlight image when the push plate accurately conveys the pipe above the background plate in normal use, and the standard push plate profile can be preset in the processor. In actual use, if the matching degree is not greater than the safe matching degree, the fact that the foreground indicated by the push plate outline is unlikely to be the push plate or the push plate is greatly deviated is proved, and then the pipe is judged to be in an abnormal position; if the matching degree is higher than the safe matching degree, the more similar the push plate outline and the shape are proved to be to the shape of the standard push plate outline; if the matching degree is greater than the safe matching degree, the foreground indicated by the push plate profile is basically the push plate, so that the processor judges the push plate profile to be the push plate, and then the processor acquires the matching angle according to the push plate profile and the standard push plate profile. And then.
Because the processor needs to verify whether the push plate in the backlight image is deviated or not, the processor needs to judge whether the matching angle is smaller than the safe matching angle or not. The match angle refers to the degree of coincidence of the position of the blade profile and the position of the standard blade profile. The safe matching angle refers to the maximum value allowed by the matching angle, and the safe matching angle can be preset in the processor. And if the matching angle is not smaller than the safe matching angle, the push plate is obviously deviated in position, and the processor judges that the push plate is in an abnormal position. If the push plate is judged to be in the abnormal position, the processor stops the defect detection of the pipe and triggers the alarm, so that a user is reminded to process the problem and subsequent detection is prevented from being influenced. If the matching angle is smaller than the safe matching angle, the closer the position of the push plate outline is to the position of the standard push plate outline is proved. If the matching angle is smaller than the safe matching angle, the processor judges that the push plate is not subjected to position deviation or only subjected to position deviation with small influence on the normal position of the push plate, and then the processor judges that the pipe is in the normal position. And if the processor judges that the pipe is accurately conveyed to the upper part of the background plate, distortion correction processing is carried out on the front light image and the back light image.
In the step of performing distortion correction processing on the front light image and the back light image by the processor, image distortion exists in a shot image due to the influence of an imaging system of the camera. The distortion of the positive light image and the backlight image comprises radial distortion and perspective distortion, and in order to improve the accuracy of the graphic data detection of the subsequent pipe flaring segment, the image distortion needs to be eliminated.
In this embodiment, the step of performing distortion correction processing on the backlight image and the backlight image specifically includes:
the processor collects an image of the calibration plate, which is shot by the camera and is placed above the background plate, as an image of the calibration plate;
the processor performs distortion correction on the calibration plate image and generates a distortion calibration file;
and the processor performs distortion correction on the front light image and the backlight image according to the distortion calibration file.
The height of the calibration plate above the background plate is consistent with that of the pipe above the background plate, so that errors caused by different heights of the calibration plate and the pipe are avoided. Distortion correction of the calibration board image by the processor means that the processor adjusts the lateral spacing and the longitudinal spacing between the respective checkerboards in the calibration board image to be substantially the same. In the calibration board image after distortion correction, the transverse spacing and the longitudinal spacing between each checkerboard 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 the ratio is the distortion calibration file. And the processor performs distortion correction on the front light image and the backlight image according to the distortion calibration file, so as to obtain the front light image and the backlight image with distortion eliminated.
In order to detect the defect, a processor is adopted to calculate graphical data of the un-flared section in a backlight image and then judge whether the graphical data of the un-flared section is positioned in a safe un-flared section parameter range. In this step, the un-flared section graphic data refers to graphic data indicating an un-flared section of the tube in the backlight image. The un-flared graphical data includes the pipe diameter of the un-flared section of the pipe and the number of pipes. The safe non-flared section pattern parameter ranges include the range where the dimensional tolerance and number of such tubing is greater than O. The processor can determine whether the tubing in the backlight image has size defects and whether the tubing exists before flaring by judging whether the graphics data of the flaring-free section are positioned in the safe flaring-free graphics parameter range, so that the defective products can be removed and whether the tubing to be detected exists in the system can be judged.
As shown in fig. 8, the step of calculating, by the processor, un-flared section graphic data in the backlight image, determining whether the un-flared section graphic data is located within a safe un-flared section graphic parameter range, and if not, determining that the pipe has a defect specifically includes:
the processor obtains the edge straight line of the non-flaring section in the backlight image by an edge searching method;
the processor determines the pipe diameter of the non-flared section and the number of pipes according to the edge straight line of the non-flared section;
the processor judges that the number of the pipes is O, and if the number of the pipes is 0, the pipes are judged to trigger an alarm;
the processor judges whether the pipe diameter of the section without flaring is not positioned in the dimensional tolerance of the pipe, and if not, the alarm is triggered.
The distance between the edge straight lines of the adjacent non-flaring sections is the pipe diameter of the non-flaring sections, and the processor calculates the distance between the edge straight lines of the non-flaring sections so as to determine the pipe diameter of the non-flaring sections. The number of straight edge lines of the unexpanded section is twice the number of tubes, and the processor calculates the number of straight edge lines of the unexpanded section to determine the number of tubes. Because the number of the tubes is a natural number, the processor determines whether the tubes exist in the backlight image by judging whether the number of the tubes is 0 or not, and further determines whether the alarm is triggered or not. Because the pipe in the backlight image has the size tolerance, the size tolerance can be preset in the processor, and the processor judges whether the pipe diameter of the section which is not flared is not positioned in the size tolerance, so that whether the pipe in the backlight image has defects or not is determined, and whether the alarm is triggered or not is further determined.
In this embodiment, the tube pattern is vertical in the backlight image, and the un-flared section in the tube pattern is located at the lower half of the tube pattern. The processor determines the number of the pipes by detecting the number of edge straight lines of the non-flared section in the backlight image, and can determine the pipe diameter of the non-flared section by detecting the distance between the edge straight lines of the non-flared section in the backlight image, so that the method can detect a plurality of pipes at one time.
In order to eliminate the interference of other contours in the backlight image, the length of the straight line of the edge of the un-flared section to be searched is constrained to be not less than a certain threshold, for example, the threshold may be 500 pixels in length. The processor judges whether the length of the obtained edge straight line is not less than 500 pixels, if not, the edge straight line is judged to be the edge straight line of the un-flared section, and if not, the edge straight line is judged not to be the edge straight line of the un-flared section.
Because the backlight image is shot under the state that the back light source is turned on and the front light source is turned off, the graph of the indicated un-flared section in the backlight image is black, and the graph of the indicated background plate is also black, the edge searching method respectively adopts the sequence from black to white and from white to black to obtain the edge straight line of the un-flared section. Wherein the number of straight lines of the edge of the non-flared section obtained from white to black in sequence is used for determining the number of pipes, and the straight lines of the edge of the non-flared section obtained from white to black and black to white in sequence can be used for determining the pipe diameter.
If the number of the pipes is O, the alarm is triggered to prompt a user that no pipe exists in the current detection, and the system records the current detection and waits for the feeding of the pipes of the next batch. If the number of the pipes is not O, the alarm is not triggered, and the system keeps working normally. If the pipe diameter of the section without flaring is not within the size tolerance of the pipe, the processor triggers the alarm to prompt a user that the quality of the pipe or the quality of the pipe mixed with other types in the detection process is defective. If the pipe diameter of the section without flaring is positioned in the size tolerance of the pipe, the alarm is not triggered, and the system starts to work next step.
The system starts to work next specifically, the processor acquires the flaring contour in the backlight image.
Wherein, the flaring contour refers to the contour of the flaring segment graph in the backlight image. The processor may obtain the flare profile on the backlight image by an edge finding method.
As shown in fig. 9, in this embodiment, the method for edge finding specifically includes the following steps:
dividing the backlight image into a plurality of sub-regions;
extracting edge points from white pixel points to black pixel points for each subregion;
sequentially storing the edge points of the first group of extracted different transverse coordinate components into different edge point sets;
and sequentially comparing the extracted edge points in all the other groups with the extracted edge points in the first group, and putting the edge points meeting the condition that the absolute value of the difference between the transverse coordinate components of the corresponding edge points between the two groups is smaller than a set threshold value into the corresponding edge point set established in the last step, wherein each edge point set is the left edge information of each pipe, and the transverse coordinate is the X axis.
According to the steps, the edge searching can be carried out on the push plate and the un-flared section in the backlight image.
As shown in fig. 10, the method for processing edge points specifically includes the following steps:
performing projection processing on the sub-regions to generate projection lines, and calculating the average concentration of each projection line to obtain a projection line average concentration waveform;
carrying out differential processing according to the projection line average concentration waveform to obtain a differential waveform;
filtering the differential waveform to filter a peak value smaller than a set threshold value;
finding projection waveform points corresponding to each peak value in the filtered differential waveform, and finding corresponding sub-areas in the detection area according to the projection waveform points, wherein the row number of each sub-area is the same as that of the detection area, and the column number is 2;
traversing each row of each subarea from small to large according to the longitudinal coordinate, comparing the two rows in each row, wherein the row corresponding to the maximum absolute value of the difference is the longitudinal coordinate of the edge point, the transverse coordinate of the edge point is the transverse coordinate component mean value corresponding to the two rows of the subarea, and the longitudinal coordinate is the Y axis.
In the above, the projection processing refers to performing vertical scanning with respect to the detection direction.
In this embodiment, in order to improve the contrast between the tube and the background on the backlight image, the method further includes the following steps:
and carrying out sharpening processing and XOR operation processing on the backlight image.
The processor sharpens the backlight image to increase the definition of the edge of the backlight image, so that the transition band of the contour edge is narrowed, and the contrast of the backlight image is enhanced. In addition, because the condition that more than two pipes are close to or even attached to each other exists, the edges of the close pipes can be separated in a sharpening processing mode, and therefore flaring outlines of the close pipes can be conveniently extracted respectively. And then carrying out XOR operation on the sharpened backlight image and the original image, and further improving the contrast ratio of the edge of the tube and the background. The background image subjected to the exclusive-or operation can be used for acquiring an edge straight line or a flared contour of the non-flared section or an edge straight line and a flared contour of the non-flared section on the backlight image.
And if the processor acquires the flaring contour, matching the flaring contour with the first flaring template, and generating a matching displacement and a matching angle.
Wherein the first flaring template can be preset in the processor. Because the difference of the flaring widths of the pipes of the same type is small, the same first flaring die plate can be used for matching.
And if the processor generates the matching displacement and the matching angle, the processor corrects the position of the flaring profile according to the matching displacement and the matching angle and acquires a backlight flaring section area.
The processor corrects the position of the flaring profile according to the matching position and the matching angle, namely the processor performs rotation translation on the flaring profile according to the matching displacement and the matching angle, so that the flaring profile is adjusted and arranged at the position where the backlight flaring section area can be obtained.
And if the processor generates the backlight flaring segment area, the matching displacement and the matching angle, the processor corrects the position of the backlight image according to 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, specifically, the processor performs rotation and translation on the front light image according to the matching displacement and the matching angle, so that the front light image is aligned and arranged at a position where a front light flaring segment graph can be obtained according to the backlight flaring segment area.
And if the processor receives the positive light image after the position correction, the processor acquires a positive light flaring section graph according to the backlight flaring section area.
Wherein, the positive light flaring graph refers to a graph which indicates the flaring section of the pipe on the positive light image.
The step of generating flaring segment graphic data according to the backlight flaring segment area by the processor specifically comprises the following steps:
the processor generates a flaring section edge straight line by adopting a straight line fitting method for the backlight flaring section area;
the processor is matched with the second flaring template in the backlight flaring section area and generates matching point information;
and the processor generates flaring segment graphic data according to the flaring segment edge straight line and the matching point information.
The flaring segment edge straight line comprises a left edge line, a right edge line and an upper edge line of the backlight flaring segment area. The left edge line and the right edge line are respectively edge lines of the side face of the flaring section, and the upper edge line is an edge line on the end face of the flaring section. The second flaring die plate is referred to as a frame-shaped area, the upper edge line of the second flaring die plate is basically superposed on the upper edge line of the backlight flaring section area, the lower edge line of the second flaring die plate is basically superposed on the left edge line of the backlight flaring section area, the right edge line of the second flaring die plate is basically superposed on the right edge line of the backlight flaring section area, and therefore the lower edge line of the second flaring die plate is basically positioned 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 flared template. And the graphic data calculated according to the straight line of the edge of the flaring segment and the matching point information comprises the depth, the width, the straightness and the angle of the flaring segment. The depth of the flared section is the distance between the matching point information and the upper edge line of the backlight flared section area. The width of the depth of the flared section is the distance between the left edge line and the right edge line of the backlit flared section area. The straightness of the flaring segment refers to the fitting degree of the edge straight line of the flaring segment and the corresponding edge of the backlight flaring segment area. The angle of the flared section refers to the angle between the straight lines of the edges of the respective flared sections.
In another embodiment, the processor may further obtain the depth of the flared section by:
the processor generates a flaring section edge straight line by adopting a straight line fitting method for the backlight flaring section area, wherein the flaring section edge straight line comprises a left edge line, a right edge line and an upper edge line;
the processor generates a detection frame on the left edge line, the left edge line is positioned in 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, and the width of the detection frame is 2 pixels;
the processor acquires edge pixels from top to bottom in the detection frame through an edge detection method, generates a mutation value and a pixel size according to the edge pixels, wherein the mutation value refers to a brightness difference value between pixel points on the left side of the edge pixels and pixel points on the right side of the edge pixels, and the pixel size refers to the length of continuous edge pixels;
the processor judges whether the mutation value of the edge pixel is within the mutation threshold value, if not, the edge pixel is filtered, and if so, the edge pixel is reserved; since the detection block intercepts a part of the pipeline itself, pixels on the pipeline itself may have brightness fluctuation and thus are acquired as edge pixels by the processor, and therefore the processor needs to filter out the edge pixels selected due to the brightness fluctuation. If the abrupt change value of the edge pixel is within the abrupt change threshold value, the processor judges that the edge pixel is not a pixel with fluctuating brightness on the pipeline, and the edge pixel is retained. If the abrupt change value of the edge pixel is not within the abrupt change threshold value, the processor judges that the edge pixel is a pixel with fluctuating brightness on the pipeline, and the edge pixel is filtered. The mutation threshold is a constant and can be preset in the processor;
the processor judges whether the pixel size of the reserved edge pixel is larger than the filtering size or not, and if so, the edge pixel is reserved; if not, filtering the edge pixel. Since the background within the detection box may have a black dot problem, the processor needs to filter out these black dots that are selected as edge pixels. If the size of the reserved edge pixel is larger than the filtering size, the processor judges that the edge pixel is not a black point on the background and reserves the edge pixel. If the size of the reserved edge pixel is not larger than the filtering size, the processor judges that the edge pixel is a black point on the background and filters the edge pixel. The filtering size is a constant, and the filtering size can be preset in the processor;
the processor calculates the sudden change fraction of the edge pixels according to a mathematical model, obtains the edge pixels corresponding to the maximum sudden change fraction in the edge pixels as the strong sudden change points of the left edge, and the mathematical model is
Figure BDA0003811040880000131
Wherein M is mutation score, L is mutation value of edge pixel, n 1 Is a weight coefficient, n 1 H is the pixel size of the edge pixel, and H is the length of the corresponding detection frame (0,1). In the present embodiment, n 1 Is 0.5;
based on the steps, the processor processes the right margin line and obtains a strong mutation point of the right margin line;
the processor obtains a fitting straight line from the left edge line strong mutation point and the right edge line strong mutation point by a straight line fitting method, and calculates the middle point of the fitting straight line;
the processor calculates the distance between the midpoint of the fitted straight line and the upper edge line, which is the depth of the flared section.
The step of generating flaring segment graphic data according to the positive light flaring segment graphic specifically comprises the following steps:
the processor converts the positive light flaring segment graph into a gray scale graph;
the processor performs blob analysis on a gray scale image converted from the light flaring segment graph and generates a gray scale abnormal region occupation ratio;
the processor performs color analysis on the bright flare segment graph and generates a color mean and a color standard deviation.
Wherein, the positive light flaring segment graph is a colorful RGB graph. The gray abnormal area is used for indicating the hot damaged area on the flaring section of the pipe. The gray value of the hot damaged area on the pipe flaring section has gray difference with the intact part on the pipe flaring section, and the ratio of the gray abnormal area is the ratio of the gray abnormal area to the whole pipe flaring section graph. The graphic data calculated by the processor according to the positive light flaring segment comprises the gray abnormal area occupation ratio, the color mean value and the color standard deviation of the flaring segment. The gray scale abnormal region occupation ratio, the color mean value and the color standard deviation are surface information data in the flaring segment graphic data.
The flaring segment graphic data specifically comprises the depth, the width and the angle of the flaring segment, the difference between the distance between the two ends of the head of the flaring segment and the width of the flaring segment, the proportion of abnormal gray scale areas, the color mean value and the color standard deviation. The depth of the flaring section refers to the distance between the head and the tail 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.
The safety flaring section graphic parameter range specifically comprises a depth range, a width range, an angle range, a difference value range, a gray scale abnormal area ratio range, a color mean value range and a color standard deviation range of the safety flaring section.
The method comprises the following steps that the processor judges whether flaring segment graphic data are located in a safe flaring segment graphic parameter range, and specifically comprises the following steps:
the processor judges whether the depth of the flaring section is within the depth range of the safe flaring section, and if not, the pipe is judged to have defects, so that the processor detects that the depth of the flaring section is too short or too long or the flaring section is not flared.
The processor judges whether the width of the flaring section is within the width range of the safe flaring section or not, and if not, the pipe is judged to have defects, so that the processor detects that the width of the flaring section has the defects of over-narrow or over-wide or no flaring. The processor judges whether the angle of the flaring section is within the angle range of the safe flaring section, and if not, the pipe is judged to have defects, so that the processor detects the defects that the tail end of the flaring section of the pipe is abnormally convex and bent.
The processor judges whether the difference between the distance between the two ends of the head of the flaring section and the width of the flaring section is within the range of the difference of the safe flaring section, and if not, the processor judges that the pipe has defects, thereby realizing the defect that the flaring section of the pipe retracts when the processor detects the pipe.
Wherein the difference between the distance across the flared section head and the flared section width refers to the difference between the distance across the flared section head and the width in the flared section graphics data. The distance between the two end points of the flaring section head refers to the fact that one end point of the flaring section head is an intersection point between the upper edge line and the left edge line, the other end point of the flaring section head is an intersection point between the upper edge line and the right edge line, the width in the flaring section graphic data is the distance between the upper edge line and the lower edge line, if the difference value exceeds the safety difference value range, the flaring section is judged to have the defect of flaring retraction, and if the difference value is within the safety difference value range, the flaring section is judged to have no defect of flaring retraction.
The processor judges whether the gray scale abnormal area occupation ratio of the flaring section is not in the gray scale abnormal area occupation ratio range of the safe flaring section, and if not, the pipe is judged to have defects, so that the processor detects the defects that the flaring section is damaged due to scalding.
The processor judges whether the color mean value of the flaring section is within the color mean value range of the safety flaring section or not, and if not, the pipe is judged to have defects, so that the processor detects the defect that the flaring section has abnormal color. Wherein, the color mean value of the safe flaring segment can adopt the color mean value of the non-flaring segment.
The processor judges whether the color difference of the flaring section is within the color difference range of the safe flaring section or not, and if not, the pipe is judged to have a defect, so that the processor detects the defect that the flaring section has different colors.
In this embodiment, when the processor determines whether the graph data of the un-flared section is located within the graph parameter range of the safe un-flared section and the graph data of the flared section is located within the graph parameter range of the safe flared section, the method further includes the following steps:
if the pipe is located, judging that the pipe has no defects.
As shown in fig. 11, in the step of generating the flare section edge straight line by using the straight line fitting method for the backlight flare section region, the straight line fitting method specifically includes:
p1: obtaining ROI (region of interest) area information of a fitting straight line;
the ROI area information refers to a set of information of each pixel point in the ROI area. The pixel point information includes the brightness and hue of the pixel point. The ROI region refers to a frame-shaped region in which the edge of the flare segment region is located, and the overall size of the ROI region is 2 × 100 pixels.
P2: acquiring a point set in ROI (region of interest) region information according to the edge threshold and the polarity parameter;
the processor judges whether the information of each pixel point is located in the edge threshold and the polarity parameter, and if yes, the pixel point is obtained and a point set is generated. The point set refers to a set of pixel points of which the pixel point information is greater than an edge threshold and a polarity parameter.
P3: calculating the average value of the horizontal coordinate and the vertical coordinate of the point set;
Figure BDA0003811040880000141
Figure BDA0003811040880000142
wherein, X 1 ...X n Refers to the abscissa of each point set, and N refers to the number of point sets.
Figure BDA0003811040880000143
Means of the abscissa, Y, of the set of points 1 ...Y n Refers to the ordinate of the respective set of points,
Figure BDA0003811040880000144
refers to the average of the ordinate of the set of points.
P4: calculating the abscissa summation result and the ordinate summation result of the point set;
Figure BDA0003811040880000145
Figure BDA0003811040880000151
wherein X 1 ...X n Refers to the abscissa of each point set, N refers to the number of point sets,
Figure BDA0003811040880000152
refers to the result of summing the abscissas of the set of points, Y 1 ...Y n Refers to the ordinate of the respective set of points,
Figure BDA0003811040880000153
refers to the average of the ordinate of the set of points.
P5: calculating the square of the abscissa of the point set and summing;
Figure BDA0003811040880000154
wherein, X 1 2 ...X n 2 Refers to the square of the abscissa of each set of points,
Figure BDA0003811040880000155
refers to the result of summing the squares of the abscissas of the set of points.
P6: calculating the product of the abscissa and the ordinate of the point set and summing the products;
Figure BDA0003811040880000156
wherein X 1 Y 1 +X 2 Y 2 +X 3 Y 3 +...+X n Y n Refers to the product of the abscissa and ordinate of each set of points,
Figure BDA0003811040880000157
refers to the result of multiplying the abscissa and the ordinate and summing.
P7: calculating the intercept a and the slope b of the straight line by using the calculation result;
Figure BDA0003811040880000158
Figure BDA0003811040880000159
where b refers to the slope of the line, a refers to the intercept of the line,
Figure BDA00038110408800001510
refers to the average of the ordinate of the set of points,
Figure BDA00038110408800001511
refers to the average of the abscissa of the set of points.
P8: fitting a straight line Y = aX + b, wherein Y refers to the ordinate of the set of points and X refers to the abscissa of the set of points;
p9: solving the distance from the point set to the straight line according to a distance solving formula from the point to the straight line;
p10: calculating an average value N1 and a standard deviation N2 of the distances from the point set to the straight line;
p11: counting the percentage of the point sets with the distance of N1 +/-3 N2 as the fitting degree of the straight line;
p12: and when the degree of fit of the straight line is lower than 0.7, removing points outside the range, and reentering the step P3 to fit the straight line.
And the processor judges the fitting straight line with the straight line fitting degree not lower than 0.7 as the edge straight line of the flaring segment.
In summary, the following describes the detection process under backlight and the detection process under positive light according to the present invention.
As shown in fig. 12, the steps of the detection flow under the positive light include:
m1: correcting the position of the positive light image according to the matching displacement and the matching angle, and obtaining a positive light flaring segment graph through a backlight flaring segment area;
m2: the positive light flaring segment graph is a color RGB graph and is converted into a gray level graph;
m3: performing blob analysis on a gray scale image formed by converting the graph of the positive light flaring segment, and obtaining a gray scale abnormal region of the graph of the positive light flaring segment through the blob analysis, wherein if the area of the obtained gray scale abnormal region is less than 50% of the total area of the graph of the flaring segment, the defect of the flaring segment of the pipe is considered as scald; if the area of the obtained gray abnormal area is larger than 50% of the total area of the positive light flaring segment graph, carrying out next processing;
m4: carrying out color analysis on the positive light flaring segment graph to generate a color mean value and a color standard deviation of the positive light flaring segment graph;
m5: if the color standard deviation exceeds the safe color standard deviation, the detected pipe is considered to be a pipe with abnormal color; if the color standard deviation is within the safe color standard deviation, carrying out the next processing;
m6: carrying out color analysis on the graph of the non-flaring section of the pipe to obtain a safe color mean value;
m7: judging whether the color mean value of the positive light flaring segment graph is within the safe color mean value or not, and if so, determining that the pipe flaring segment has no color difference; if not, the flaring section of the pipe has color difference.
As shown in fig. 13, the steps of the detection flow under the backlight include:
c1, during backlight detection, a back light source is required to be opened, a front light source is required to be closed, a backlight image is collected under backlight, and the backlight image is processed to obtain a gray scale image;
c2, acquiring a flaring profile in the backlight image by an edge searching method, correcting the position of the flaring profile according to the matching displacement and the matching angle, acquiring a backlight flaring section area, and generating a flaring section edge straight line by adopting a straight line fitting method on the backlight flaring section area, wherein the flaring section edge straight line comprises a left edge line, a right edge line and an upper edge line of the flaring section;
c3, matching a second flaring template on the backlight flaring section area and generating matching point information;
c4, generating flaring segment graphic data according to the flaring segment edge straight line and the matching point information, wherein the obtained flaring segment graphic data comprises the depth, the width, the straightness and the angle of the flaring segment;
and C5, presetting safety flaring section graphic data according to actual production requirements, judging whether the flaring section graphic data are within the safety flaring section graphic parameter range, if so, judging that the pipe is qualified, and if not, judging that the pipe is abnormal. In the step S2, if only one edge straight line is fitted when the straight line fitting is performed on the left edge line and the right edge line of the flaring segment, but other detection conditions are all true, it is proved that the pipe has the problem of overlapping.
Based on the problems, black area extraction of the ROI area is carried out on the pipe, the maximum area in the extracted black area is obtained, the maximum area is the overlap area of the flaring section, whether the overlap area of the flaring section exceeds 50% of the first flaring template or not is judged, if yes, the pipe is judged to be overlapped with other pipes, the pipe is not judged to be a defective product, and if not, the pipe is judged to have the defect of abnormal flaring area.
And if the backlight flaring segment area is received, generating position data according to the backlight flaring segment area.
Wherein the position data is indicative of the position of the tubing over the background plate.
If the pipes are judged to have defects, the pipes with the defects are sorted according to the position data, and if the pipes are judged to have no defects, the pipes without the defects are sorted according to the position data, so that the effect of sorting the pipes with the defects and the pipes without the defects is achieved.
As shown in fig. 5 and 6, an embodiment of the present invention further provides a device for detecting defects of a tube based on a backlight image, which is implemented by the method for detecting defects of a tube based on a backlight image, and includes:
the background plate is used as a background in a pipe image shot by the camera;
the push plate is used for conveying the pipe to the upper part of the background plate;
a light source for polishing the front surface of the tube as a front light and the back surface of the tube as a back light;
the camera is used for shooting images on the front surface of the pipe;
and the processor is used for judging whether the pipe has defects according to the positive light image and the backlight image.
Wherein, judging whether the pipe has defects according to the positive light image and the backlight image specifically comprises the following steps: conveying the pipe to the upper part of the background plate through the push plate; if the current time-space parameters of the push plate accord with the expected time-space parameters, collecting a pipe image shot by a camera under the positive light as a positive light image, and collecting a pipe image shot by a camera under the backlight as a backlight image; carrying out distortion correction processing on the positive light image and the negative light image; calculating un-flared section graphic data in the backlight image; if the graphical data of the non-flaring segment is not within the graphical parameter range of the safe non-flaring segment, determining that the pipe has defects; acquiring a flaring profile on the backlight image by an edge searching method, matching the flaring profile with a first flaring template, and generating a matching displacement and a matching angle; performing position correction on the flaring profile according to the matching displacement and the matching angle to obtain a backlight flaring section area, performing position correction on the backlight image according to the matching displacement and the matching angle, and obtaining a front light flaring section graph in the front light image after the position correction according to the backlight flaring section area; generating flaring section graphic data according to the backlight flaring section area and the positive light flaring section graphic; and if the flaring section graphic data are not in the safe flaring section graphic parameter range, judging that the pipe has defects.
In actual use, the push plate conveys the pipe to the upper side of the background plate, the light source can control illumination on the front side and the back side of the pipe, the camera can shoot on the front side of the pipe, the processor processes the shot front light image and the shot back light image, and the processor controls output equipment such as an alarm, a display and a sorting device.
In some embodiments, the camera and front light source are disposed above the background plate and the back light source is disposed below the background plate. In practical use, when the push plate conveys the tube to the position above the background plate, the tube is positioned below the camera and the front light source and is positioned above the back light source.
In some embodiments, the background plate is light transmissive. In actual use, light emitted by the backlight source can penetrate through the background plate and irradiate the camera.
In some embodiments, the background plate is opaque. In practical use, the opaque background plate is used to prevent the camera from shooting the back light source below the background plate.
In some embodiments, the background plate is white. In actual use, the white background plate makes the background white in the backlight image taken by the camera and white in the positive light image taken by the camera.
In some embodiments, the push plate is also black. In practical use, the black push plate makes the push plate appear black in the backlight image shot by the camera and black in the positive light image shot by the camera.
In some embodiments, the light source comprises a front light source and a back light source, the front light source is disposed on the front side of the background plate, the back light source is disposed on the back side of the background plate, the front light source is used for lighting the front side of the tube as front light, and the back light source is used for lighting the back side of the tube as back light. The push plate slides transversely above the background plate, and if the push plate slides above the background plate, the pipe can be conveyed to the upper side of the background plate.
In practical use, the back light source is arranged below the background plate, and provides uniform backlight on the back of the tube together with the background plate.
In some embodiments, the processor is further configured to control the front light switch and the back light switch. Specifically, the front light source and the back light source are respectively electrically connected to the processor.
In some embodiments, the device further comprises an optoelectronic switch, wherein the optoelectronic switch is used for detecting the position of the push plate, and the trigger area of the optoelectronic switch is positioned above the background plate. And if the push plate enters the trigger area of the photoelectric switch, triggering the photoelectric switch to generate a trigger signal and sending the trigger signal to the processor. The photoelectric switch is electrically connected to the processor.
In some embodiments, the system further comprises an alarm, wherein the alarm is electrically connected to the processor.
The above embodiments are only preferred embodiments of the present invention, and the protection scope of the present invention is not limited thereby, so: all equivalent changes made according to the structure, shape and principle of the invention are covered by the protection scope of the invention.

Claims (10)

1. A method for detecting defects of a tube based on a backlight image is characterized by comprising the following steps:
collecting a pipe image shot by a camera under backlight as a backlight image;
calculating un-flared section graphic data in the backlight image;
judging whether the graphical data of the un-flared section is located in the graphical parameter range of the safe un-flared section, and if not, judging that the pipe has defects;
acquiring a flaring profile on the backlight image by an edge searching method, matching the flaring profile with a first flaring template, and generating a matching displacement and a matching angle;
performing position correction on the flaring profile according to the matching displacement and the matching angle to obtain a backlight flaring section area;
generating flaring segment graphic data according to the backlight flaring segment area;
and judging whether the flaring section graphic data are positioned in the safe flaring section graphic parameter range, and if not, judging that the pipe has defects.
2. The method for detecting the defects of the tube based on the backlight image as claimed in claim 1, wherein the graphical data of the un-flared sections comprises the tube diameter of the un-flared sections of the tube and the number of the tubes.
3. The method for detecting the defects of the pipe based on the backlight image as claimed in claim 2, wherein the step of calculating the pattern data of the un-flared sections in the backlight image specifically comprises:
obtaining an edge straight line of an unexpanded section in the backlight image by an edge searching method;
and determining the pipe diameter of the non-flared section and the number of the pipes according to the edge straight line of the non-flared section.
4. The method for detecting the defects of the pipe based on the backlight image as claimed in claim 1, wherein the flaring segment graphic data comprises the depth, the width and the angle of the flaring segment and the difference between the distance between the two ends of the head of the flaring segment and the width of the flaring segment.
5. The method for detecting the pipe defects based on the backlight image as claimed in claim 1, wherein the ranges of the safety flaring segment graphic parameters include a depth range, a width range, an angle range and a difference range of the safety flaring segment.
6. The method for detecting the defects of the tube based on the backlight image as claimed in claim 4, wherein the step of judging whether the flaring segment graphic data is within the safe flaring segment graphic parameter range or not, and if not, judging that the tube has the defects specifically comprises the steps of:
judging whether the depth of the flaring section is within the depth range of the safe flaring section or not, and if not, judging that the pipe has defects;
judging whether the width of the flaring section is within the width range of the safe flaring section or not, and if not, judging that the pipe has defects;
judging whether the angle of the flaring section is within the angle range of the safe flaring section or not, and if not, judging that the pipe has defects;
and judging whether the difference between the distance between the two ends of the head of the flaring section and the width of the flaring section is within the range of the difference of the safe flaring section, and if not, judging that the pipe has defects.
7. The method for detecting the defects of the tube based on the backlight image as claimed in claim 1, wherein the step of generating flaring segment graphic data according to the backlight flaring segment area specifically comprises:
generating a flaring section edge straight line by adopting a straight line fitting method for a backlight flaring section area;
matching a second flaring template on the backlight flaring section area and generating matching point information;
and generating flaring segment graphic data according to the flaring segment edge straight line and the matching point information.
8. The method for detecting the tube defects based on the backlight image as claimed in claim 1, further comprising:
and if the graphical data of the un-flared section is located in the graphical parameter range of the safe un-flared section and the graphical data of the flared section is located in the graphical parameter range of the safe flared section, judging that the pipe does not have defects.
9. The method for detecting the defects of the tube based on the backlight image as claimed in claim 1, wherein the edge searching method specifically comprises:
dividing the backlight image into a plurality of sub-regions;
extracting edge points from white pixel points to black pixel points for each subarea;
sequentially storing the edge points of the first group of extracted different transverse coordinate components into different edge point sets;
and sequentially comparing the extracted edge points in all the other groups with the extracted edge points in the first group, and putting the edge points meeting the condition that the absolute value of the difference between the transverse coordinate components of the corresponding edge points between the two groups is smaller than a set threshold value into the corresponding edge point set established in the last step, wherein each edge point set is the left edge information of each pipe.
10. A tube defect detection device based on backlight images is characterized by comprising:
a light source for lighting the back surface of the tube as a backlight;
the camera is used for shooting images on the front surface of the pipe;
the processor is used for collecting a pipe image shot by the camera under backlight to serve as a backlight image, calculating un-flared section graphic data in the backlight image, judging that the pipe has defects if the un-flared section graphic data is not in a safe un-flared section graphic parameter range, obtaining a flared contour on the backlight image through an edge searching method, matching the flared contour with a first flared template to generate a matching displacement and a matching angle, correcting the position of the flared contour according to the matching displacement and the matching angle to obtain a backlight flared section area, generating flared section graphic data according to the backlight flared section area, and judging that the pipe has defects if the flared section graphic data is not in the safe flared section graphic parameter range.
CN202211012259.9A 2022-04-28 2022-08-23 Method and device for detecting pipe defects based on backlight image Pending CN115471455A (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN2022104714999 2022-04-28
CN202210471499 2022-04-28

Publications (1)

Publication Number Publication Date
CN115471455A true CN115471455A (en) 2022-12-13

Family

ID=84366001

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211012259.9A Pending CN115471455A (en) 2022-04-28 2022-08-23 Method and device for detecting pipe defects based on backlight image

Country Status (1)

Country Link
CN (1) CN115471455A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116071357A (en) * 2023-03-07 2023-05-05 飞杨电源技术(深圳)有限公司 High-power charger surface defect detection method

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116071357A (en) * 2023-03-07 2023-05-05 飞杨电源技术(深圳)有限公司 High-power charger surface defect detection method

Similar Documents

Publication Publication Date Title
CN105067638B (en) Tire fetal membrane face character defect inspection method based on machine vision
CN115115644B (en) Vehicle welding defect detection method based on artificial intelligence
CN105046700A (en) Brightness correction and color classification-based fruit surface defect detection method and system
CN105046697B (en) A kind of beer bottleneck localization method assessed based on multiple random loop truss and degree of fitting
CN112819844B (en) Image edge detection method and device
CN104122271A (en) Automated optical inspection (AOI)-based bullet apparent defect detection method
CN115471455A (en) Method and device for detecting pipe defects based on backlight image
CN109801322B (en) Light leakage detection method and device
CN104537367A (en) VIN code checking method
CN115082410A (en) Clamp spring defect detection method based on image processing
CN115294116B (en) Method, device and system for evaluating dyeing quality of textile material based on artificial intelligence
CN112581452A (en) Industrial accessory surface defect detection method and system, intelligent device and storage medium
CN104112123A (en) Defect characteristic extraction and identification method of AOI system used for bullet apparent defect detection
CN115494065A (en) Pipe flaring defect judgment method and device based on positive light image
CN109920010A (en) The method that a kind of pair of polyphaser visual detection equipment is demarcated
CN115496710A (en) Pipe flaring size measurement and flaw detection method and device
CN109614868A (en) Automobile tire decorative pattern graph line identifying system
CN107240109B (en) Automatic detection method for instrument scale mark position
CN110060231A (en) A kind of piston ring image rapid counting method
CN114820622A (en) Interlayer foreign matter detection method and device
CN110335243A (en) A kind of tire X-ray defect detection method based on texture comparison
CN108335296B (en) Polar plate identification device and method
CN107552415B (en) A kind of orange petal method for sorting applied to orange petal sorter
CN207636505U (en) A kind of shoes mould surface damage detection device
CN110864881B (en) Indicator lamp correctness detection method based on visual system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination