Disclosure of Invention
In view of the defects and shortcomings of the prior art, the invention aims to provide a visual-based automatic nozzle atomization angle detection system and method.
The technical scheme of the invention is realized as follows:
a nozzle atomization angle automatic detection system based on vision comprises a target image acquisition module, a target image processing module and a detection data analysis module; the target image acquisition module is used for acquiring a spray image; the target image processing module is used for processing the acquired spray image and calculating a spray atomization angle; and the detection data analysis module performs data statistical analysis on the spray atomization angle to obtain a detection result.
Optionally, the target image acquisition module comprises: the device comprises a backlight source, a camera, a lens, a nozzle, a background plate and a box body, wherein the camera is connected with a computer through a cable; the camera receives the trigger signal, collects a plurality of nozzle spray images at intervals and sends the nozzle spray images to the computer for subsequent processing;
the backlight source is fixed on the outer side of the box body, the background plate is fixed on the inner side of the box body and is positioned above the backlight source, and two surfaces of the box body, which are opposite to the backlight source and the camera, are made of glass and are used for backlight source lighting and image acquisition of the camera;
the nozzle is arranged in the box body and is positioned between the background plate and the lens.
Optionally, the target image processing module includes a preprocessing unit, an edge detection unit, a contour analysis unit, and a cone angle calculation unit; the preprocessing unit firstly carries out smoothing processing on the image through a Gaussian filter algorithm and obtains a binary image through image binarization operation; the edge detection unit extracts edges of the binary image through an edge detection algorithm, and the contour analysis unit screens a spray contour from an edge curve by using a contour analysis algorithm; the cone angle calculation unit obtains the boundary line of the cone angle through a straight line fitting algorithm and calculates a straight line included angle, namely the cone angle.
Optionally, the step of obtaining the binarized image by the preprocessing unit through an image binarization operation specifically includes:
firstly, dividing an image into a background part and a foreground part according to the gray characteristic of the image;
then, for the image I (x, y), the segmentation threshold of the foreground and the background is denoted as T, and the proportion of the number of pixels belonging to the foreground to the whole image is denoted as ω0The average gray scale is recorded as mu0(ii) a The proportion of the number of pixels belonging to the background to the whole image is marked as omega1The average gray scale is recorded as mu1(ii) a The total average gray scale of the image is recorded as mu, and the inter-class variance is recorded as g;
next, the image size is M × N, and the number of pixels in the image with the gray scale value of the pixel less than the threshold T is recorded as N0The number of pixels with gray value greater than threshold T is recorded as N1Then, there are:
ω0=N0/M×N (1)
ω1=N1/M×N (2)
N0+N1=M×N (3)
ω0+ω1=1 (4)
μ=ω0*μ0+ω1*μ1(5)
g=ω0(μ0-μ)2+ω1(μ1-μ)2(6)
substituting formula (5) for formula (6) yields the equivalent formula:
g=ω0ω1(μ0-μ1)2(7)
and obtaining a threshold value T which enables the inter-class variance g to be maximum by adopting a traversal method, namely obtaining the binary image.
Optionally, the edge detection unit performs edge extraction on the binarized image through a Canny edge detection algorithm.
Optionally, the contour analysis unit screens the spray contours from the edge curves by using a contour analysis algorithm, screens edge images meeting requirements according to characteristics of the spray contours, and screens the two longest spray contours by sorting the lengths of the contours.
The invention also provides a nozzle atomization angle automatic detection method based on vision, which comprises the following steps:
collecting a plurality of nozzle spray images;
preprocessing the multiple nozzle spraying images and extracting spraying contours;
obtaining a boundary line of the cone angle through a straight line fitting algorithm, and calculating the cone angle;
and carrying out data analysis on the multiple cone angle angles to obtain a detection result.
Optionally, the preprocessing the plurality of nozzle spray images, the extracting the spray profile step includes: firstly, smoothing an image through a Gaussian filter algorithm, and obtaining a binary image through image binarization operation; and then, performing edge extraction on the binary image through an edge detection algorithm, and screening a spray profile from an edge curve by using a profile analysis algorithm.
Optionally, the step of obtaining a binarized image through an image binarization operation specifically includes:
firstly, dividing an image into a background part and a foreground part according to the gray characteristic of the image;
then, for the image I (x, y), the segmentation threshold of the foreground and the background is denoted as T, and the proportion of the number of pixels belonging to the foreground to the whole image is denoted as ω0The average gray scale is recorded as mu0(ii) a The proportion of the number of pixels belonging to the background to the whole image is marked as omega1The average gray scale is recorded as mu1(ii) a The total average gray scale of the image is recorded as mu, and the inter-class variance is recorded as g;
next, the image size is M × N, and the number of pixels in the image with the gray scale value of the pixel less than the threshold T is recorded as N0The number of pixels having a pixel gray level greater than the threshold T is denoted by N1Then, there are:
ω0=N0/M×N (1)
ω1=N1/M×N (2)
N0+N1=M×N (3)
ω0+ω1=1 (4)
μ=ω0*μ0+ω1*μ1(5)
g=ω0(μ0-μ)2+ω1(μ1-μ)2(6)
substituting formula (5) for formula (6) yields the equivalent formula:
g=ω0ω1(μ0-μ1)2(7)
and obtaining a threshold value T which enables the inter-class variance g to be maximum by adopting a traversal method, namely obtaining the binary image.
Optionally, the step of screening the spray profile from the edge curve by using a profile analysis algorithm includes: and the contour analysis algorithm screens out edge images meeting the requirements according to the characteristics of the spraying contour, and screens out the two longest images as the spraying contour by sequencing the contour lengths.
The invention has the beneficial effects that:
(1) the nozzle atomization angle can be quickly, accurately and stably measured, and the randomness of manual measurement is solved;
(2) analysis of the quality of the current batch of product can be facilitated by deriving a test report.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
FIG. 1 illustrates an alternative embodiment of a vision-based automatic nozzle spray angle detection system.
In this optional embodiment, the vision-based automatic nozzle atomization angle detection system includes a target image acquisition module 1, a target image processing module 2, and a detection data analysis module 3, where the target image acquisition module 1 is configured to acquire a spray image, the target image processing module 2 is configured to process the acquired spray image, calculate a spray atomization angle, and the detection data analysis module 3 performs data statistical analysis on the spray atomization angle to obtain a detection result.
The automatic nozzle atomization angle detection system based on vision is provided with a polishing mode which is designed according to oil mist characteristics and can clearly highlight the oil mist edge, a cone angle is accurately obtained by combining an image processing algorithm, and a test result is generated after statistical analysis.
Fig. 2 shows an alternative embodiment of the object image acquisition module.
In this alternative embodiment, the target image acquisition module comprises: backlight 11, camera 12, lens 13, nozzle 15, background board 16, box 17, camera 12 is connected with computer 14 through the cable. After the target is in place, the camera 12 receives the trigger signal to acquire a plurality of nozzle spray images at intervals, and sends the nozzle spray images to the computer 14 for subsequent processing.
The backlight source 11 is a surface light source and is fixed outside the box body 17, and the inclination angle and the up-down position of the backlight source 11 relative to the side surface of the box body 17 are adjustable, so that the optimal polishing effect is achieved. Optionally, the backlight 11 is a blue area light source.
A background cloth is fixed on the surface of the background plate 16, and the background plate 16 is fixed inside the cabinet 17 at a position above the backlight 11. To facilitate detection of the oil mist edge as a background, the background plate 16 needs to be spread over the camera field of view to improve measurement accuracy. Optionally, a black non-reflective background cloth is fixed on the surface of the background plate 16.
The box 17 is made of high-light-transmitting glass on both sides of the backlight 11 and the camera 12, and is used for illuminating the backlight 11 and collecting images by the camera 12.
The nozzle 15 is disposed in the housing 17 between the background plate 16 and the lens 13.
Optionally, the target image capturing module 1 captures a plurality of nozzle spray images at intervals, and the time interval is adjustable. For example, the target image acquisition module acquires 10 nozzle spray images at intervals.
Fig. 3 shows an alternative embodiment of the target image processing module.
In this alternative embodiment, the target image processing module includes a preprocessing unit 21, an edge detection unit 22, a contour analysis unit 23, and a cone angle calculation unit 24. The preprocessing unit firstly carries out smoothing processing on the image through a Gaussian filter algorithm and obtains a binary image through image binarization operation. The edge detection unit extracts edges of the binary image through an edge detection algorithm, and the contour analysis unit screens the spray contour from the edge curve through a contour analysis algorithm. The cone angle calculation unit obtains the boundary line of the cone angle through a straight line fitting algorithm and calculates a straight line included angle, namely the cone angle.
The preprocessing unit firstly carries out smoothing processing on the image through a Gaussian filter algorithm and obtains a binary image through image binarization operation. The gaussian filtering is a linear smooth filtering, which is suitable for eliminating gaussian noise and is used in the noise reduction process of image processing. The gaussian filtering is a process of weighted average of the whole image, and the value of each pixel point is obtained by weighted average of the value of each pixel point and other pixel values in the neighborhood.
Optionally, the step of obtaining the binarized image by the preprocessing unit through an image binarization operation specifically includes:
firstly, the image is divided into a background part and a foreground part according to the gray characteristic of the image.
Then, for image I (x, y), the segmentation threshold of the foreground (i.e. the target) and the background is denoted as T, and the proportion of the number of pixels belonging to the foreground to the whole image is denoted as ω0The average gray scale is recorded as mu0(ii) a The proportion of the number of pixels belonging to the background to the whole image is marked as omega1The average gray scale is recorded as mu1(ii) a The total mean gray level of the image is denoted as μ and the inter-class variance is denoted as g.
Next, the image size is M × N, and the number of pixels in the image with the gray scale value of the pixel less than the threshold T is recorded as N0The number of pixels with gray value greater than threshold T is recorded as N1Then, there are:
ω0=N0/M×N (1)
ω1=N1/M×N (2)
N0+N1=M×N (3)
ω0+ω1=1 (4)
μ=ω0*μ0+ω1*μ1(5)
g=ω0(μ0-μ)2+ω1(μ1-μ)2(6)
substituting formula (5) for formula (6) yields the equivalent formula:
g=ω0ω1(μ0-μ1)2(7)
and obtaining a threshold value T which enables the inter-class variance g to be maximum by adopting a traversal method, namely obtaining the binary image.
The preprocessing unit obtains the binarized image through image binarization operation, has simple calculation process, is not influenced by the brightness and the contrast of the image, and divides the image into a background part and a foreground part according to the gray characteristic of the image. Since the variance is a measure of the uniformity of the gray distribution, the larger the inter-class variance between the background and the foreground, the larger the difference between the two parts constituting the image, and the smaller the difference between the two parts when part of the foreground is mistaken for the background or part of the background is mistaken for the foreground. Thus, a segmentation that maximizes the inter-class variance means that the probability of false positives is minimized.
The edge detection unit carries out edge extraction on the binary image through an edge detection algorithm, and the purpose of edge detection is to remarkably reduce the data scale of the image under the condition of keeping the original image attribute.
Optionally, the edge detection unit performs edge extraction on the binarized image by a Canny edge detection algorithm.
Optionally, the Canny edge detection algorithm comprises the following steps: firstly, a non-maximum suppression (non-maximum suppression) technology is applied to eliminate edge false detection; then, a double threshold method is applied to determine potential boundaries; finally, the boundary is tracked using a hysteresis technique.
By adopting the optional embodiment, the Canny edge detection algorithm can identify actual edges in the image as much as possible, and the probability of missing detection of the actual edges and the probability of false detection of non-edges are both as small as possible; the position of the edge point detected by the Canny edge detection algorithm is closest to the position of the actual edge point, or the degree that the detected edge deviates from the real edge of the object due to the influence of noise is minimum; moreover, the detection points correspond to the edge points one to one.
Due to the influence of noise points in the images, a plurality of contours may exist, the contour analysis unit screens the spraying contours from the edge curves by using a contour analysis algorithm, screens edge images meeting requirements according to the characteristics of the spraying contours, and screens the two longest contours which are the spraying contours by sequencing the lengths of the contours.
The cone angle calculation unit obtains the boundary line of the cone angle through a straight line fitting algorithm and calculates a straight line included angle, namely the cone angle. Wherein a line fitting algorithm fits a line from a given set of points (e.g., a contour). Optionally, the line fitting algorithm uses a least squares algorithm to minimize the sum of the distances of the points to the line. Optionally, the straight line fitting algorithm adopts a straight line fitting function fitLine provided based on an OpenCV library, so as to achieve a better straight line fitting effect.
The detection data analysis module 3 performs data analysis on multiple cone angle angles in the multiple nozzle spray images, and outputs a detection result, wherein the detection result comprises: maximum, minimum, mean and standard deviation. Wherein the maximum value is the largest value among the plurality of cone angle angles, and is found by sorting and comparing. The minimum value is the smallest value of the plurality of cone angle angles and is found by a sort comparison. The average is the arithmetic average of a plurality of cone angle angles. The standard deviation is the square root of the arithmetic mean of the standard value of each cone angle and the square of its mean deviation, which is used to reflect the degree of dispersion between each cone angle.
FIG. 4 illustrates another alternative embodiment of a vision-based automatic nozzle spray angle detection system.
In this optional embodiment, the automatic nozzle atomization angle detection system based on vision further includes a detection result display module 4, and if the detection result is normal, the detection result display module 4 displays the result on an interface for real-time viewing.
Optionally, the automatic visual-based nozzle atomization angle detection system further includes a detection result output module 5 for generating a test report. Optionally, the test report includes a target data, a detection time, and a detection result image.
Optionally, the automatic nozzle atomization angle detection system based on vision further includes an abnormal result alarm module 6, configured to send an alarm signal to the alarm by the abnormal result alarm module 6 when the detection result is abnormal. Optionally, the abnormal result alarm module 6 sends an alarm signal to the alarm when the spray is not detected or the spray angle exceeds the set threshold.
FIG. 5 illustrates an alternative embodiment of a vision-based method for automatically detecting nozzle spray angle.
In this optional embodiment, the present invention further provides a nozzle atomization angle automatic detection method based on vision, which performs nozzle atomization angle automatic detection based on the detection system, and includes the following steps: step 11, collecting a plurality of nozzle spraying images; step 12, preprocessing the multiple nozzle spraying images and extracting spraying contours; step 13, obtaining a boundary line of the cone angle through a straight line fitting algorithm, and calculating the cone angle; and 14, carrying out data analysis on the multiple cone angle angles to obtain a detection result.
Optionally, in step 12, the step of preprocessing the plurality of nozzle spray images and extracting the spray profile includes: firstly, smoothing an image through a Gaussian filter algorithm, and obtaining a binary image through image binarization operation; and then, performing edge extraction on the binary image through an edge detection algorithm, and screening a spray profile from an edge curve by using a profile analysis algorithm.
The gaussian filtering is a linear smooth filtering, which is suitable for eliminating gaussian noise and is used in the noise reduction process of image processing. The gaussian filtering is a process of weighted average of the whole image, and the value of each pixel point is obtained by weighted average of the value of each pixel point and other pixel values in the neighborhood.
Optionally, the step of obtaining a binarized image through an image binarization operation specifically includes:
firstly, the image is divided into a background part and a foreground part according to the gray characteristic of the image.
Then, for image I (x, y), the segmentation threshold of the foreground (i.e. the target) and the background is denoted as T, and the proportion of the number of pixels belonging to the foreground to the whole image is denoted as ω0The average gray scale is recorded as mu0(ii) a The proportion of the number of pixels belonging to the background to the whole image is marked as omega1The average gray scale is recorded as mu1(ii) a The total mean gray level of the image is denoted as μ and the inter-class variance is denoted as g.
Next, the image size is M × N, and the number of pixels in the image with the gray scale value of the pixel less than the threshold T is recorded as N0The number of pixels having a pixel gray level greater than the threshold T is denoted by N1Then, there are:
ω0=N0/M×N (1)
ω1=N1/M×N (2)
N0+N1=M×N (3)
ω0+ω1=1 (4)
μ=ω0*μ0+ω1*μ1(5)
g=ω0(μ0-μ)2+ω1(μ1-μ)2(6)
substituting formula (5) for formula (6) yields the equivalent formula:
g=ω0ω1(μ0-μ1)2(7)
and obtaining a threshold value T which enables the inter-class variance g to be maximum by adopting a traversal method, namely obtaining the binary image.
The step of obtaining the binary image through the image binarization operation is simple in calculation process, is not influenced by the brightness and the contrast of the image, and divides the image into a background part and a foreground part according to the gray characteristic of the image. Since the variance is a measure of the uniformity of the gray distribution, the larger the inter-class variance between the background and the foreground, the larger the difference between the two parts constituting the image, and the smaller the difference between the two parts when part of the foreground is mistaken for the background or part of the background is mistaken for the foreground. Thus, a segmentation that maximizes the inter-class variance means that the probability of false positives is minimized.
The purpose of edge detection is to significantly reduce the data size of an image while preserving the original image attributes. Optionally, the method performs edge extraction on the binarized image by a Canny edge detection algorithm. Optionally, the Canny edge detection algorithm comprises the following steps: firstly, a non-maximum suppression (non-maximum suppression) technology is applied to eliminate edge false detection; then, a double threshold method is applied to determine potential boundaries; finally, the boundary is tracked using a hysteresis technique.
By adopting the optional embodiment, the Canny edge detection algorithm can identify actual edges in the image as much as possible, and the probability of missing detection of the actual edges and the probability of false detection of non-edges are both as small as possible; the position of the edge point detected by the Canny edge detection algorithm is closest to the position of the actual edge point, or the degree that the detected edge deviates from the real edge of the object due to the influence of noise is minimum; moreover, the detection points correspond to the edge points one to one.
Due to the influence of noise points in the images, a plurality of contours may exist, the contour analysis algorithm screens out edge images which meet requirements according to the characteristics of the spraying contours, and the longest two images are screened out as the spraying contours by sequencing the lengths of the contours.
In the step of calculating the cone angle by obtaining the boundary line of the cone angle through the straight line fitting algorithm, the straight line fitting algorithm is to fit a straight line according to a given point set (such as a contour). Optionally, the line fitting algorithm uses a least squares algorithm to minimize the sum of the distances of the points to the line. Optionally, the straight line fitting algorithm adopts a straight line fitting function fitLine provided based on an OpenCV library, so as to achieve a better straight line fitting effect.
Optionally, in the step of performing data analysis on the multiple cone angle angles to obtain the detection result, the detection result includes a maximum value, a minimum value, an average value, and a standard deviation.
The maximum value is the largest value among the plurality of cone angle angles, and is obtained through sorting and comparison and used for representing the angle. The minimum value is the smallest value among the plurality of cone angle angles and is found by a sort comparison. The average is the arithmetic average of a plurality of cone angle angles. The standard deviation is the square root of the arithmetic mean of the standard value of each cone angle and the square of its mean deviation, which is used to reflect the degree of dispersion between each cone angle.
Optionally, the detection method further includes: and displaying the result on a software interface and generating a test report.
Optionally, the detection method further includes: and when the detection result is abnormal, outputting a signal to an alarm.
The invention provides a system and a method for automatically detecting a nozzle atomization angle based on vision, which can quickly, accurately and stably measure the nozzle atomization angle, solve the problem of randomness of manual measurement, and assist in analyzing the quality of the current batch of products by deriving a detection report.
Therefore, the invention effectively overcomes the defects and shortcomings of nozzle atomization angle detection in the prior art, thereby having high industrial utilization value.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.