Belt conveyor edge detection method in complex environmentTechnical Field
The invention relates to the technical field of image processing, in particular to a method for detecting edges of a belt conveyor in a complex environment.
Background
The belt conveyor is a continuous transport machine widely used in industries such as coal, construction, metallurgy, electric power and the like. Conveyor belt run out is one of the most common faults of belt conveyors. The deviation not only can cause the accident occurrence frequency of the conveyor to be increased and influence the production, but also can cause the material to be scattered outwards, so that the operation economy of the transportation system is reduced. Whether the conveyor belt is deviated or not can be effectively detected by carrying out edge detection on the conveyor belt, so that the position of the conveyor belt can be adjusted through the terminal.
At present, the deviation correcting measures of the conveyor belt deviation can be mainly divided into an artificial algorithm, a mechanical automatic deviation correcting algorithm, a photoelectric automatic deviation correcting algorithm and the like. The mechanical correction algorithm has low equipment cost but poor precision, and the photoelectric automatic correction algorithm has high precision, good correction effect and high equipment manufacturing cost. Along with the continuous development of science and technology, the conveyer belt deviation is accurately and efficiently detected through computer vision and image processing technology, so that the labor intensity of manual detection can be reduced, the automation level of enterprises is improved, potential faults of the conveyer belt can be found early, and the efficiency and the precision of fault detection are improved.
In addition, in view of the fact that the conveyor belt visual monitoring system needs to operate on line, the image data information amount is very large, and in order to realize the online operation of the system, a simple and efficient image processing algorithm needs to be adopted. If the processing of the image of the conveyor belt is realized by software, the complexity of a processing algorithm is more needed to be considered so as not to influence the real-time performance of the system.
Disclosure of Invention
The invention aims to solve the technical problems in the prior art, and provides a method for detecting the edge of a belt conveyor in a complex environment, which is used for judging whether the belt conveyor is deviated or not by detecting the edge position of the belt conveyor, so as to achieve the aims of accurately detecting the position of the belt conveyor in real time and correcting the position of the belt conveyor in real time.
The technical scheme adopted for solving the technical problems is as follows:
the invention provides a method for detecting the edge of a belt conveyor in a complex environment, which comprises the following steps:
Step one, acquiring an original image of a belt conveyor in a natural environment;
step two, selecting a region of the ROI of the conveyor belt from an original image of the belt conveyor by adopting a specified coordinate point frame;
Step three, adjusting the image contrast of the ROI by using a normalization processing method, and designing two different normalization parameters according to the problem of difference of identification of the edges of the conveyor belt under the condition that the conveyor belt is provided with two different materials and the conveyor belt is not provided with two different materials;
Step four, reinforcing the image in the vertical direction by using a Sobel edge detection operator, so as to reinforce the edge line, and extracting a white line in the vertical direction, namely the edge line;
Step five, reinforcing the extracted white lines in the vertical direction by using morphological expansion operation, expanding between white points, then increasing the communication area of the edge lines, and performing binarization operation on the processed image;
Step six, further executing an eight-connected domain algorithm on the processed image, and deleting large-area white spots in the middle area of the conveyor belt;
and step seven, finding out two head points and two tail points of the edge line in the extracted image, respectively connecting the four points in pairs, and finally marking the straight line in the original image to obtain the edge detection result of the belt conveyor.
Further, the specific method of the first step of the invention is as follows:
and fixing the camera above the belt conveyor, shooting the belt conveyor through the fixed camera position, and acquiring the image of the belt conveyor in the natural environment.
Further, the specific method of the second step of the invention is as follows:
And selecting a partial region frame containing the edge of the conveyor belt by using the designated coordinate value, and dividing the partial region frame from the background image.
Further, the specific method of the third step of the invention is as follows:
The formula of normalization processing is:
Wherein Ak represents an array to be normalized, Ai represents an original array, P represents an array obtained after normalization operation, AK does not belong to { max (Ai),min(Ai) }, p=1 when AK is equal to max (Ai), p=0 when AK is equal to min (Ai), and a normalization algorithm is adopted to enable the value of the array Ak to be translated or scaled to a specified range.
Further, the specific method of the fourth step of the invention is as follows:
carrying out sobel edge detection on the normalized image in the vertical direction so as to strengthen a vertical line;
According to the characteristics of the image of the conveyor belt, a vertical edge detection template is provided, according to the characteristics that the straight lines are horizontal and the pixel values between the straight lines are larger than those on the straight lines, an expansion difference method is provided for detecting the vertical edge, and the vertical edge detection template is as follows:
The method comprises the steps of detecting a template in a matrix of pixels of an image, wherein Gy represents a result value after detecting the edge of the sobel in the vertical direction, A represents a pixel matrix of the image which needs to be detected by the edge, the size of the template is 3x3, carrying out convolution operation on the template and the image, enhancing points in the vertical direction of the image, weakening the points in the horizontal direction to a certain extent, and reducing interference.
Further, the specific method of the fifth step of the present invention is as follows:
the image is subjected to binarization operation by using an immobilization threshold value, the gray value of a pixel point on the image is set to be 0 or 255, a threshold value T is set, and data of the image is divided into two parts by using T, namely, a pixel group larger than T and a pixel group smaller than T, namely, the part larger than the threshold value is set to be 255, and the part smaller than the threshold value is set to be 0, wherein the expression is as follows:
Wherein dst (x, y) represents an output image threshold, maxval represents a maximum gray value, src (x, y) represents an original image gray value, thresh represents a set threshold T, different binarization thresholds are set for conveyor belts of different scenes according to the influence of the image under illumination, the left threshold value is reduced under the scene with weak contrast to strengthen the edge of the conveyor belt, and the left threshold value is increased under the scene with strong contrast to reduce the influence of other noise points.
Further, the specific method of the step six of the invention is as follows:
The extracted binarized image is subjected to eight-communication domain processing, and the gray value of surrounding pixel points is counted as 0 or 255 for each pixel, and according to the binarization processing, if one pixel is a part of interference factors, the gray value of the pixel in the binarization result is 255, namely white, and if one pixel is background, the gray value of the pixel is 0 and black;
So that for a noise it should be a black background for all around, i.e. one noise pixel is white and the surrounding 8 neighboring pixels are all black, if the picture resolution is high enough, one noise may actually be made up of many pixels, i.e. one pixel is white and the neighboring 8 pixels are black more than a fixed value, this pixel is the noise, and the threshold of this fixed value is fixed for the conveyor belt in different environments.
Further, the specific method of the step seven of the invention is as follows:
Finding out two head points and two tail points of an edge line in the extracted image according to the processed image, respectively connecting the four points in pairs, marking the straight line in an original image, calibrating the edge of the conveyor belt at the position, judging whether the position of the edge of the conveyor belt is in a set range according to a standard, detecting that the position of the edge of the conveyor belt is in the set range, and judging that the conveyor belt is not deviated, or else, judging that the conveyor belt is deviated.
The method has the beneficial effects that the method is suitable for detecting the edge of the belt conveyor under a complex background, and the edge of the belt conveyor is accurately obtained by enhancing images, extracting gradient edges, carrying out eight-communication-domain and other methods, so that whether the belt conveyor is deviated or not is judged according to the position of the edge of the belt conveyor. The invention has strong anti-interference capability and good robustness, and can realize the real-time edge detection of the belt conveyor in a complex environment.
Drawings
The invention will be further described with reference to the accompanying drawings and examples, in which:
FIG. 1 is a flow chart of an edge detection algorithm of a belt conveyor according to the present invention;
FIG. 2 is an extracted conveyor belt normalization chart of the present invention;
FIG. 3 is a perspective view of the extracted conveyor belt sobel enhancement vertical line of the present invention;
FIG. 4 is a binarization chart of the extracted conveyor belt of the present invention;
FIG. 5 is a diagram of an eight-pass domain noise cancellation plot for an extracted conveyor belt in accordance with the present invention;
fig. 6 is a graph of the invention marking extracted belt edge results.
Detailed Description
The present invention will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present invention more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
The flow chart of the edge detection method of the belt conveyor in the complex environment of the embodiment of the invention is shown in fig. 1, and is carried out in the following manner:
step 1, acquiring an image of a belt conveyor in a natural environment through a fixed camera;
And 2, in order to uniformly process the belt conveyor subsequently and avoid interference of the background, extracting the ROI region of the belt conveyor before detection, selecting coordinates of four points in a fixed coordinate form, sequentially connecting the four points to frame the ROI region, and then taking the part outside the frame as a mask to cover all the ROI region with black.
And 3, carrying out normalization processing on the image before edge detection to improve the contrast of the boundary in order to obtain a better boundary extraction effect. The contrast is reduced by setting the parameters in the normalization function to a smaller value in the presence of material and the contrast is improved by setting the parameters in the normalization function to a larger value in the absence of material. The normalization process is to sum up the statistical distribution of the unified samples, and is to limit the data to be processed to a certain range after being processed, and the formula is as follows:
wherein aK does not belong to { max (Ai), min (Ai) }, p=1 when aK is equal to max (Ai), p=0 when it is equal to min (Ai). The normalization algorithm is used to translate or scale the values of the array to a specified range. When normalization processing is used, the right value is increased for a graph with small contrast, and the left value is increased for a graph with large contrast, so that edge information can be better displayed, as shown in fig. 2.
And 4, after normalization processing, performing sobel edge detection enhancement vertical lines in the vertical direction. Inspired by a traditional edge detection algorithm, a vertical edge detection template is provided according to the characteristics of a conveyor belt image. From the conveyor belt image, it can be analyzed that the interference line on the middle part of the conveyor belt and the noise generated when the conveyor belt transports coal become more blurred after normalization processing, so that the noise is not enhanced when the enhancement in the vertical direction is performed. The traditional edge detection algorithm has poor effect, and according to the characteristics that the pixel values between straight lines are horizontal and larger than those on the straight lines, an expanded difference method is provided for detecting the edges in the vertical direction, and the template is shown in the following formula.
The template is 3x3 in size, convolved with the image, enhancing points in the vertical direction of the image, and weakening points in the horizontal direction to some extent to reduce interference, as shown in fig. 3.
And 5, performing binarization operation on the image by using an immobilization threshold value, and setting the gray value of the pixel point on the image to be 0 or 255, namely, displaying the whole image with obvious visual effects of only black and white. In order to directly extract a target object from a multi-valued digital image, a common method is to set a threshold T, and divide the image data into two parts, i.e., a pixel group larger than T and a pixel group smaller than T. The binarization function is limited using the cv_thresh_binary type whose purpose is to set a part larger than a threshold to 255 and a part smaller than 0, expressed as:
Wherein maxval denotes a maximum gray value 255, which is replaced with maxval if the image is greater than a set maximum threshold thresh, and replaced with 0 otherwise.
According to the influence of the image under illumination, different binarization thresholds are set for the conveyor belts of different scenes, the left threshold value is reduced under the scene with weak contrast to strengthen the edge of the conveyor belt, and the left threshold value is increased under the scene with strong contrast to reduce the influence of other noise points.
Step 6, performing eight-pass domain processing on the extracted binarized image, wherein the method is similar to mean value filtering, but for each pixel, the gray level average value of the surrounding pixels is not taken, and the number of gray level values of the surrounding pixels is counted to be 0 or 255. From the previous binarization, it is known that if a pixel is part of the disturbing factor, the gray value of this pixel must be 255, i.e. white, in the binarization result, and that if a pixel is background, the gray value should be 0, i.e. black. Thus, for isolated noise, the surroundings should be black, or a large number of dots should be black pixels.
So for a noise it should be against a background of all black, precisely one noise pixel is white and the surrounding 8 neighboring pixels are all black. Of course, if the picture resolution is high enough, a noise may actually be made up of many pixels, so the judgment condition should be relaxed at this time, i.e. one pixel is white and the adjacent 8 pixels are black and larger than a fixed value, then this pixel is a noise. This threshold is fixed for different environments of the conveyor belt, so that it is possible to set the size, try several times, find the best threshold. Through tests, the 8-connected domain denoising method is very effective for removing small noise points, and the calculated amount is not large. Comparing fig. 4 with fig. 5, it is evident that some white noise is reduced in fig. 5.
And 7, measuring the edges of the conveyor belt in the image, searching four starting points of two straight lines on the basis of the straight lines obtained in the step 6, determining a straight line between the two points, respectively connecting the four points in pairs, and calibrating the edges of the conveyor belt. Judging whether the position of the edge of the conveyor belt is within a set range according to the standard, and giving a detection result.
It will be understood that modifications and variations will be apparent to those skilled in the art from the foregoing description, and it is intended that all such modifications and variations be included within the scope of the following claims.