Background
The metal material loading machine is at the course of the work, and various directions can appear in the raw materials in track transmission, before getting into next process, need judge metal material's direction and "blow" out the track with the unusual metal material of direction to guarantee that the raw materials direction that gets into next process is unanimous. The raw materials with abnormal directions can directly influence the normal operation of the next process, and huge economic loss is brought to a factory. In recent years, a method of determining the direction of a metal material by machine vision has been widely used, in which a picture including the metal material is captured by an industrial camera, and the picture captured by the industrial camera is analyzed by a computer processing technique to determine the direction of the metal material, thereby completing sorting of the metal material.
However, there are many non-ideal situations in the industrial real-world production process, resulting in the quality of the pictures taken by the industrial camera being degraded. For example, the illumination condition in the image acquisition process may change with time, such as a factory that generally gives priority to artificial illumination at night and combines natural light with artificial illumination during the day. This causes the brightness of the captured picture to change. For a metal feeding machine, generally, a feeding track and raw materials are made of metal materials, are very sensitive to illumination and generally have a light reflection phenomenon. This results in an unstable workpiece direction obtained by visual inspection, which brings trouble to the next process.
In consideration of the problems of unstable lighting environment and metal reflection in an industrial scene, some people abandon visual detection and directly judge the direction of the raw material through optical modes such as light diffraction, refraction and reflection, but the light refraction, diffraction and reflection are influenced by the characteristics such as the size, the shape, the color and the like of the metal raw material, so that the direction judgment criterion needs to be adapted to the characteristics of the raw material, once any one attribute of the metal raw material is changed, the judgment criterion of direction sorting needs to be changed along with the change, and the operation is complex and the cost is quite high.
This patent mainly uses actual operational environment and demand as the background, it is easy to be changeful to the illumination environment, the traditional visual sorting method of metal material loading machine is sensitive to the illumination, the current commonly used judgement method based on refraction, diffraction, reflection characteristic of light is complicated to operate, with high costs, a metal material loading visual sorting method of anti visible light interference is given, the outstanding characteristics of this method are, heat metal material, then use thermal imager to get rid of all illumination interference in the imaging process, analyze thermal imager's result, in order to obtain accurate raw materials direction. The method can obviously reduce the error rate of judging the direction of the metal raw material caused by the influence of the illumination environment in visual sorting, overcomes the complex operation and high cost of the method based on light refraction and reflection, and improves the working efficiency and the working quality of the metal feeding machine.
Disclosure of Invention
The invention aims to provide a visual sorting method for metal feeding, which is resistant to visible light interference and aims to solve the problems that the direction of a metal raw material is limited and the error probability is increased due to the fact that metal reflection is aggravated when the metal reflection characteristic and the ambient light change exist in the visual sorting process of the existing metal feeding machine element, and a non-visual detection method is complex in operation and high in cost.
The visible light interference resistant metal feeding visual sorting method comprises the following steps:
step S1: heating the metal raw material by using an incubator;
wherein the heating temperature is in the range of 38 to 42 ℃;
step S2: acquiring a thermal imager image containing metal raw materials at a specified position by using a thermal imager, and calling the thermal imager image as an original image;
step S3: filtering and binarizing the original image, marking pixels corresponding to metal raw materials in the original image, and obtaining a mask;
wherein, the pixel corresponding to the metal raw material represents a target and is marked as T, and the mask is marked as M; the mask obtaining method specifically comprises the following substeps:
step S3-1: performing median filtering on the original image to obtain a filtered image;
the median filtering sets the gray value of each pixel point in the original image as the median of the gray values of all pixel points in a certain neighborhood window of the point, and the size range of the selected window of the median filtering is 3 to 5;
step S3-2: performing OTSU self-adaptive binarization on the filtered image to obtain a binary image;
step S3-3: reserving a maximum white area in the binary image as a target, setting other areas as black, and obtaining a mask M;
step S4: extracting the contour C of the target T in the mask M;
step S5: acquiring the gravity center of a target T in a mask M;
wherein, the center of gravity of the target, which is denoted as (cx, cy), is obtained by:
step S5-1: respectively calculating the zeroth order moment M of the mask M according to the formula (1), the formula (2) and the formula (3)00And first moment m10、m01:
Wherein r and l respectively represent the number of rows and columns of the mask M, i and j respectively represent subscripts of the number of rows and columns of the mask M, the value range of the row number subscript i is 1 to r, and the value range of the column number subscript j is 1 to l;
step S5-2: the abscissa cx and the ordinate cy of the center of gravity of the target are calculated according to the formula (4) and the formula (5), respectively:
cx=m10/m00 (4)
cy=m01/m00 (5)
step S6: and calculating the direction of the target T according to the gravity center (cx, cy) and the contour C to finish visual sorting, and specifically comprising the following substeps:
step S6-1: obtaining a minimum circumscribed rectangle of the outline of the target T;
step S6-2: marking the side of the minimum bounding rectangle furthest from the center of gravity (cx, cy);
wherein, the side farthest from the center of gravity (cx, cy) is marked as L;
step S6-3: a vector pointing to L and perpendicular to L is made through the center of gravity (cx, cy), and the direction of the vector is the direction of the target T.
Advantageous effects
Compared with the prior art, the visible light interference resistant metal feeding visual sorting method has the following beneficial effects:
1. the method has low algorithm complexity and high stability, common metal-containing image processing needs to be conducted with reflection removing processing which is very complex operation, a thermal imager is used for imaging the metal material, reflection does not exist in the image, complex reflection removing operation is not needed, and in addition, the imaging of the thermal imager is only affected by temperature, so that the imaging is stable, the method is benefited from the imaging stability and the reflection-free characteristic of the thermal imager, and the algorithm complexity and the stability are low;
2. the method has good application expansibility, the shape and the size of the metal raw material in the metal feeding machine are changed, and the visual sorting method disclosed by the invention is still effective and is specifically represented as follows: the visual detection technology can always calculate a direction for expressing the direction of the metal according to the direction judgment algorithm in the method no matter how the shape and the size of the metal raw material change, so that the method has good application expansibility.
Detailed Description
The following describes a visual sorting method for metal feeding materials with visible light interference resistance according to the present invention in detail with reference to the accompanying drawings and examples.
Example 1
The embodiment illustrates the specific implementation of the visual sorting method for the metal feeding materials with the visible light interference resistance in the direction sorting of the metal raw materials of the metal feeding machines. In specific implementation, the metal material used for sorting is a nail-shaped (one-tip) elongated metal with a size of about 8mm × 2mm, in order to ensure that the image includes the complete metal material and a certain definition, the resolution of the thermal imager is selected to be 320 × 240, and in combination with the metal size in the embodiment, the lens is selected to be a telephoto lens.
In step S1 in fig. 1, before the metal reaches the feeding inlet of the feeding machine, the metal is heated by a thermostat to 38 to 42 degrees (the specific heating temperature can be adjusted according to the temperature of the working scene and is 3 to 4 degrees higher than the ambient temperature, and the resolution of the thermal imager is reached), the heated metal material reaches the feeding inlet along with the conveyor belt, and the thermal imager is placed at the feeding inlet of the metal feeding machine.
Step S2 in fig. 1 is executed to collect the original image containing the heated metal material, in this embodiment, the original image is a gray scale image, as shown in a in fig. 2, the gray scale value of the metal material with high temperature is larger, the temperature of the background part is lower, and the corresponding gray scale value in the original image is smaller, so that the metal material in the original image is clearly distinguished from the background due to the imaging characteristic of the thermal imager, and step S3 and the subsequent steps in the present patent can be performed without the need of de-reflection treatment. The general sorting method of the metal feeding machine based on vision needs to perform reflection removing processing on pictures collected by an optical camera, the metal reflection removing processing is very complex operation, and the reflection removing effect depends on the reflection degree of objects in actual pictures (von willebrand, liuhongdi, tango, etc.. the high-reflection metal surface defect detection method based on HDRI researches [ J ] instrument technology and sensors, 2019, (8): 112-. Compared with the method disclosed by the invention, the method has the characteristic of removing light interference, fundamentally solves the influence of metal reflection, omits the step of reflection removing operation, and avoids instability caused by the metal reflection removing operation, so that the method disclosed by the invention has low algorithm complexity and high stability.
Step S3 in fig. 1 is executed to perform image processing on the original image, including median filtering, binarization and screening of the target T, and finally obtain a mask M with a white area representing the target and a black area representing the background. In particular, a preferred median filtering window size is 5. The median filtering can better retain image details, especially detail information related to contours, while removing noise, and in this embodiment, the window size of the median filtering is preferably 5 according to the resolution 320 × 240 of the original image. The OTSU method is used for binarization, the OTSU method can adaptively find the threshold value for segmenting the foreground and the background, compared with a mode of fixing the binarization threshold value, the OTSU method can well adapt to the condition that the whole gray value of an image is increased or reduced, and has better adaptability compared with the binarization method of fixing the threshold value. And (4) screening the target, namely only reserving the maximum white area in the binary image as a target T, and setting the gray levels of other areas as 0 to obtain the mask M. The OTSU binarization method used in the method of the present invention can adapt to the situation that the original image is brighter and darker, so that no matter whether the metal material is a nail-shaped material with a size of 8mm by 2mm selected in this embodiment, and whether the ambient temperature is higher or lower (such as difference between summer and winter), step S3 can always correctly divide the metal material and the background to obtain a mask similar to that shown in b in fig. 2. In the method disclosed by the invention, the step of searching the area where the target is located has good application expansibility.
The process proceeds to step S4 and step S5 to obtain the centroids (cx, cy) of the target contour C and the target T, respectively, according to the flow shown in fig. 1. The target contour is shown as c in FIG. 2, the target barycenter is shown as d in FIG. 2, the barycenter (cx, cy) of the target is obtained, and the specific calculation is shown as steps S5-1 and S5-2. The center of gravity (cx, cy) is calculated from the moment feature of the mask M, and the center of gravity of the metal material can always be calculated from the target moment feature regardless of whether the metal material is selected to be a nail-like material having a size of 8mm 2 mm. Therefore, the method disclosed by the invention has good application expansibility in the step of calculating the target gravity center.
After the target barycenter and the contour are obtained, step S6 is executed to analyze a side L of the minimum bounding rectangle of the contour C farthest from the barycenter (cx, cy), and a vector pointing to L and perpendicular to L is made through the barycenter, and the direction of the vector is defined as the direction of the metal material, as indicated by an arrow e in fig. 2. After the target profile and the target center of gravity are obtained, the direction of the target can be obtained by the method of step S6 regardless of whether the metal material is a nail-shaped material having a size of 8mm by 2mm selected in this example, and does not need to be changed depending on the metal material. Therefore, the criterion for judging the target direction in the method disclosed by the invention also has good application expansibility.
The good application expansibility of the invention mentioned in the steps S3 to S6 is mainly reflected in that firstly, in the target segmentation, the OTSU binaryzation can adapt to different environmental temperatures, secondly, the calculation of the gravity center of the object is not limited by the size and the shape of the metal raw material, and thirdly, the judgment criterion of the direction can always provide a reasonable direction. However, in the currently used judgment method based on the characteristics of light such as diffraction, reflection, refraction and the like, the diffraction, reflection and refraction of light are influenced by the size and shape of the metal raw material in addition to the ambient light, so that the corresponding direction calculation and direction judgment criteria need to be changed every time the shape of the metal raw material is changed once, and therefore, the method has high expanded application cost. Compared with the prior art, the method has the advantages that the metal raw material is changed, the steps of the method do not need to be adjusted, and the application expansibility is good.
Finally, in this embodiment, after steps S1 to S6 are completed, the direction of the metal material in the current original image is obtained, the obtained direction of the metal material needs to be compared with the positive direction of the metal specified by the feeding machine, the metal material in accordance with the specified positive direction can enter the next process, and the metal material not in accordance with the specified direction is "blown" out of the track and returned to the metal material conveyor again. Therefore, the visual sorting of the metal feeding which is resistant to the visible light interference is completed.
In conclusion, the method aims at the problem that the metal feeding machine vision detection method is serious in light reflection, uses the thermal imaging instrument to replace a common industrial camera, thoroughly solves the problem of light reflection of the metal feeding machine, does not need to execute reflection removing operation, reduces the complexity of an image processing algorithm, and improves the stability of the algorithm. Meanwhile, the image processing algorithm related to the method does not need to set parameters and is not limited by the ambient temperature and the shape and size of the metal raw material, so that the method has good application expansibility. Good application expansibility has simplified manual operation, can avoid the direction that the unreasonable parameter setting leads to judge the performance reduction, has reduced manufacturing cost, has improved production efficiency.
While the present invention has been described with reference to the embodiments shown in the drawings, the present invention is not limited to the embodiments, which are illustrative and not restrictive, and it will be apparent to those skilled in the art that various changes and modifications can be made therein without departing from the spirit and scope of the invention as defined in the appended claims.