Box positioning control system and method based on machine vision
1. A box body positioning control method based on machine vision is characterized by comprising the following steps:
step 1, a limit switch arranged in front of a loading position stops the loading box after the loading box reaches the loading station, a signal that the loading box reaches the station is sent to an industrial personal computer through a PLC (programmable logic controller), and meanwhile, the correction frequency i is set to be zero;
step 2, after receiving the signals, the industrial personal computer controls industrial cameras A and B arranged on two sides of the charging box to respectively acquire images of the current box body in the X direction and the Y direction, the acquired image information is transmitted to the image information processing unit in real time, and the part of the box opening of the box is cut out through template matching;
3, aiming at the box opening picture cut out in the step 2, carrying out noise reduction on the picture by using Gaussian filtering, preprocessing the picture by using an industrial personal computer of an image processing unit, and extracting the edge of the box body image by using a Canny algorithm;
and 4, calculating to obtain position deviations delta A _ X and delta A _ Y of the actual circle center of the box opening of the charging box and the reference position in the direction X, Y respectively by taking the circle center of the charging opening as the reference position, further obtaining the distance which needs to be pushed by the pneumatic cylinder of the execution unit, if the distance is smaller than a set threshold value, lifting the jacking mechanism to execute charging operation, returning the pneumatic cylinder to the initial position after charging, returning to the step 1, otherwise, judging whether the correction frequency i is smaller than 3, if i is smaller than 3, controlling the pneumatic cylinder of the execution unit to move to correct the box body according to the position deviation value, adding 1 to the correction frequency i, returning to the step 2, if i is not smaller than 3, manually correcting alignment, then executing charging operation, returning to the initial position after charging, and returning to the step 1.
2. The method of claim 1, wherein said step 2 further comprises:
step 2-1, reading a target image I (x, y) and a template image T (x, y), wherein (x, y) represents coordinates of pixels in the images, I (x, y) represents the target image, and T (x, y) represents a known box opening template image for matching;
step 2-2, template matching is carried out by utilizing a standardized interpolation square sum matching algorithm;
and 2-3, carrying out normalization processing on the obtained matching result.
3. The method of claim 2, wherein in step 2.2, the mathematical formula of the normalized interpolation sum of squares matching algorithm is as follows:
where the value of R (x, y) represents the degree of similarity at the (x, y) position.
4. The method of claim 3, wherein step 3 further comprises:
step 3-1, preprocessing an image of a port of the charging box by using a Gaussian filter function; scanning each pixel in the box opening image of the loading box by using a template image T (x, y), and replacing the value of a central pixel point of the template by using a weighted average gray value of pixels in a neighborhood determined by the template;
step 3-2, carrying out graying processing on the box opening picture of the charging box, and then smoothing the image after graying processing by using a Gaussian filter, wherein a Gaussian smoothing function is as follows:
wherein f (x, y) is an original image matrix, H (x, y) is a Gaussian kernel, G (x, y) is a smoothed matrix, and x and y are pixel coordinates;
step 3-3, calculating gradient value g of the smoothed image in the x and y directionsx(x, y) and gy(x, y), if the gradient value of one pixel point in the gradient direction is maximum, the pixel point belongs to the edge, otherwise, the pixel point is not the edge, and the gray value is set to be 0, so that the image edge of the box opening is obtained.
5. The method according to claim 4, characterized in that in step 3.1, the image of the opening of the filling box is preprocessed by Gaussian two-dimensional filtering, as shown in formula (3):
where G (u, v) is a pixel value, σ is a weighting coefficient, and u, v are pixel coordinates.
6. The method according to claim 5, wherein in step 3.3, the formula for calculating the gradient values g (x, y) and the gradient direction θ is as follows:
7. the method of claim 6, wherein step 4 further comprises:
step 4-1, summing the black and white pixel values of each row of the obtained edge image of the opening of the charging box through the A camera, then searching the positions left and right of the pixels at two ends of the maximum diameter of the edge image of the opening of the charging box so as to search the center of the edge image of the opening in the X direction, and similarly, searching the center of the edge image of the opening of the charging box in the Y direction by using the edge image of the opening of the charging box obtained by the B camera so as to position the position information of the charging box;
step 4-2, calculating to obtain position deviation information delta A _ X of the actual circle center of the opening of the charging box and the reference in the direction X, Y by taking the circle center of the charging opening as the reference position1And Δ A _ Y1If the deviation is less than the alignment deviation epsilon, the step is shifted to a step 4-6, otherwise, the box body is pushed by an A, B cylinder group, so that the position of the box body is corrected once, and the corrected position deviation delta A _ X is calculated by using the algorithm in the step 4-1 according to the image information2And Δ A _ Y2According to Δ A _ X2And Δ A _ Y2Judging whether the alignment deviation is smaller than the alignment deviation epsilon or not, and judging whether the box opening of the box is aligned with the material filling opening or not;
step 4-3. if Δ A _ X2And Δ A _ Y2If the box bodies are smaller than epsilon, the box bodies are aligned, and the step 4-6 is carried out;
step 4-4. if Δ A _ X2And Δ A _ Y2If the position difference is larger than epsilon, performing secondary correction on the box body, and obtaining the corrected position deviation delta A _ X by utilizing the algorithm in the step 4-1 according to the image information3And Δ A _ Y3If Δ A _ X3And Δ A _ Y3If the box bodies are smaller than epsilon, aligning the box bodies, and turning to the step 4-6;
step 4-5. if Δ A _ X3And Δ A _ Y3If the position deviation is larger than epsilon, the box body is corrected for the third time, and the corrected position deviation delta A _ X is obtained by utilizing the algorithm in the step 4-1 according to the image information4And Δ A _ Y4If Δ A _ X4And Δ A _ Y4If the alignment is smaller than epsilon, the box bodies are aligned, and the step 4-6 is carried out, otherwise, the box bodies are not aligned, an alarm is given, the alignment is corrected manually, and the step 4-6 is carried out;
and 4-6, completely lifting the jacking mechanism to enable the port of the charging box to be in butt joint with the material filling port to perform charging, and enabling the cylinder to return to the initial position after charging is completed.
8. A box positioning control system using the control method of any one of claims 1 to 7, characterized in that the system comprises a limit switch, an image acquisition unit, an industrial personal computer, a PLC controller, a pneumatic cylinder and a jacking mechanism, wherein the image acquisition unit comprises industrial cameras A and B;
the limit switch is arranged on the front side of the loading position of the pipeline, the loading box is stopped after reaching the loading station, the limit switch stops and sends an analog current signal of the loading box reaching the station to the PLC controller, and the PLC controller converts the analog current signal into a digital signal and sends the digital signal to the industrial personal computer through an RS485 bus;
after receiving the signals, the industrial personal computer controls industrial cameras A and B arranged on two sides of the charging box to respectively acquire images of the current box body in the X direction and the Y direction, and acquired image information is transmitted to the industrial personal computer in real time;
and after receiving the position deviation of the actual circle center of the opening of the charging box and the circle center of the filling opening in the direction of X, Y calculated by the industrial personal computer, the pneumatic cylinder pushes the charging box and the jacking mechanism lifts the charging box to a specified position.
9. The control system of claim 8, wherein the PLC controller transmits the digital signal to the industrial personal computer through an RS485 bus.
10. The control system of claim 8, wherein the industrial personal computer controls the industrial cameras a and B installed at both sides of the loading box through the network cable.
Background
In the filling process of some products in chemical plants, the inner layer of a charging box is an iron packaging box, and the outer layer is a wooden protection box. In this patent, the inner and outer double-layered charging box is collectively referred to as a double-layered box body. When the packaging box is filled, the circular charging opening of the iron packaging box on the inner layer is required to be aligned to the filling opening by adjusting the position of the outer wooden protection box, so that the filling operation is implemented. In traditional irritate the material technology, rely on the manual work to judge location and revise the box position usually, and manual measurement exists that detection speed is slow, can not detect simultaneously in batches, measurement accuracy is not high scheduling problem to lead to production line inefficiency, alignment rate low and degree of automation low, the urgent need carry out intelligent transformation.
Disclosure of Invention
The invention aims to solve the problem of throwing in the filling process caused by inaccurate positioning of a box body in the existing box body filling production line, and provides a box body positioning control system and a method thereof by utilizing machine vision, servo control and information technology.
The technical problem proposed by the invention is solved as follows:
a box body positioning control method based on machine vision comprises the following steps:
step 1, a limit switch arranged on the front side of a loading position of the assembly line stops the loading box after the loading box reaches the loading position, the limit switch stops and then sends an analog current signal of the loading box reaching the loading position to a PLC (programmable logic controller), the PLC converts the analog current signal into a digital signal and sends the signal to an industrial personal computer through a certain communication protocol, and meanwhile, the correction frequency i is zero;
step 2, after receiving the signals, the industrial personal computer controls industrial cameras A and B arranged on two sides of the charging box to respectively acquire images of the current box body in the X direction and the Y direction, the acquired image information is transmitted to the image information processing unit in real time, and the part of the opening of the charging box is cut out through template matching;
3, aiming at the box opening picture cut out in the step 2, carrying out noise reduction on the picture by using Gaussian filtering, preprocessing the picture by using an industrial personal computer of an image processing unit, and extracting the edge of the box body image by using a Canny algorithm;
and 4, calculating to obtain position deviations delta A _ X and delta A _ Y of the actual circle center of the box opening of the charging box from the reference in the direction X, Y by taking the circle center of the charging opening as a reference position, further obtaining the distance which needs to be pushed by a pneumatic cylinder of the execution unit, if the distance is smaller than a set threshold value, lifting the jacking mechanism to execute charging operation, returning the cylinder to the initial position after charging is finished, and then returning to the step 1, otherwise, judging whether the correction frequency i is smaller than 3, if i is smaller than 3, controlling the cylinder of the execution unit to move to correct the box body according to the deviation distance value, adding 1 to the correction frequency i, and then returning to the step 2, and if i is not smaller than 3, manually correcting and aligning, then executing charging operation, returning the cylinder to the initial position after charging is finished, and returning to the step 1.
The step 2 of the invention comprises:
step 2-1, reading a target image I (x, y) obtained by shooting and a loading box opening template image T (x, y) prepared in advance, wherein (x, y) represents coordinates of pixels in the image, I (x, y) represents the target image, and T (x, y) represents a known box opening template image used for matching;
step 2-2, template matching is carried out by utilizing a standardized interpolation square sum matching algorithm, firstly, the template image and the target image are subjected to standardized processing, so that when the brightness of each pixel of the template and the image is multiplied by the same coefficient, the correlation degree is not changed, the method utilizes the square sum of the difference value of each pixel of the image and the template to carry out matching, the worse the matching is, the larger the matching value is, and the mathematical formula of the standardized interpolation square sum matching algorithm is as follows:
where the value of R (x, y) represents the degree of similarity at the (x, y) position.
And 2-3, carrying out normalization processing on the obtained matching result, wherein the normalization processing function is as follows:
wherein dst (x, y) is a pixel value after the image matrix is normalized, R (x, y) is a pixel value in the matching image result, min (R (x, y)) is a pixel minimum value in the matching image result, max (R (x, y)) is a pixel maximum value in the matching image result, min is a normalization range minimum value, and max is a normalization range maximum value.
The step 3 of the invention comprises:
and 3-1, preprocessing the image of the opening of the charging box by using a Gaussian filter function. Scanning each pixel in the box opening image of the loading box by using a template image T (x, y), and replacing the value of a central pixel point of the template by using a weighted average gray value of pixels in a neighborhood determined by the template; adopting Gaussian two-dimensional filtering to preprocess the box opening image of the charging box, as shown in formula (3):
wherein G (u, v) is a pixel value, σ is a weighting coefficient, and u, v are pixel coordinates;
step 3-2, carrying out gray processing on the picture of the opening of the charging box, wherein the calculation formula is as follows (4):
Gray=R×0.299+G×0.587+B×0.114 (4)
wherein R, G, B are three channels of color images, Gray is the transformed result, and then the image is smoothed by a gaussian filter, the gaussian smoothing function is:
wherein f (x, y) is an original image matrix, H (x, y) is a Gaussian kernel, G (x, y) is a smoothed matrix, and x and y are pixel coordinates;
step 3-3, calculating gradient value g of the smoothed image in the x and y directionsx(x, y) and gy(x, y), if the gradient value of one pixel point in the gradient direction is maximum, the pixel point belongs to the edge, otherwise, the pixel point is not the edge, the gray value is set to be 0, and therefore an edge gray image of the box opening is obtained;
the formula for calculating the gradient value g (x, y) and gradient direction θ of the integrated gradient is as follows:
the step 4 of the invention comprises:
and 4-1, summing the black and white pixel values of each row of the obtained edge image of the opening of the loading box through the A camera, searching the positions left and right of the pixels at two ends of the maximum diameter of the opening of the inner-layer box to find the center of the opening in the X direction, and similarly, searching the center of the opening in the Y direction by using the edge image of the opening of the loading box obtained by the B camera to position the position information of the box.
The specific implementation method for finding the direction centers of the cameras A and B comprises the following three steps:
reading a gray image of the bin opening edge of the loading bin, wherein the image is stored in a computer program in a matrix form, the size height and width of the image can be obtained by obtaining the matrix dimension of the image, then, according to the fact that the black pixel value is 0 and the white pixel value is 255, the pixel value of each column is judged to be equal to 255 or 0, the sum of the number of black and white pixels of each column of the image is obtained through calculation, the maximum value of the number of the black pixels is black _ max and the maximum value of the number of the white pixels is white _ max, and if the total number s of the black pixels is larger than the total number t of the white pixels, the obtained bin opening edge image is in a white character with a black bottom, namely, the image background is that the black bin opening edge is white;
secondly, initializing a left-end pixel position left of a box opening to be 1, a right-end pixel position right of the box opening to be 2 and a searching frequency n to be 1, if n is less than width-2, judging whether the total number white [ n ] of the n-th column is greater than a value of alpha multiplied by white _ max, wherein alpha is an empirical value, if the total [ n ] of the n-th column is not greater than the alpha multiplied by white _ max, the n-th column is still located in an image black background and a white box opening edge is not detected, and then returning to n +1 to continuously judge whether the total number white of the next column of pixels meets the requirement;
thirdly, using the left side of the left end position left of the box opening as the black pixel background, having no white pixel, then detecting the left end position of the box opening from left to right, if it is white pixel, satisfying white [ n ] > α × white _ max, then indicating that the left end pixel position of the white box opening is detected, making the left end pixel position left equal to n, then using the same method to search the right end pixel position right of the box opening from the left +1 column, and determining whether the total number black [ m ] of the m-th column is larger than the value of β × black _ max, where β is an empirical value, using the right side of the right end position right of the box opening as the black pixel background, and the left side thereof is unable to satisfy black [ m ] > β × black _ max because of the white pixel in the white box opening, if it is black [ m ]. β × black _ max, indicating that the right end pixel position right of the box opening is detected, then the box opening is the center (right)/2 left, otherwise, m +1 returns to continue judging until the condition is met and the position information of the box opening center is output.
Step 4-2, calculating to obtain position deviation information delta A _ X of the actual circle center of the opening of the charging box and the reference in the direction X, Y by taking the circle center of the charging opening as the reference position1And Δ A _ Y1Then, if the deviation is less than the alignment deviation epsilon, the step 4-6 is carried out, otherwise, the box body is pushed by the A, B cylinder group, so that the position of the box body is corrected once, and the corrected position deviation delta A _ X is calculated by the algorithm in the step 4-1 according to the image information2And Δ A _ Y2According to Δ A _ X2And Δ A _ Y2Whether the alignment deviation is smaller than the alignment deviation epsilon or not is judged, and whether the box opening of the inner layer box is aligned with the material filling opening or not is judged;
step 4-3. if Δ A _ X2And Δ A _ Y2If the box bodies are smaller than epsilon, the box bodies are aligned, and the step 4-6 is carried out;
step 4-4. if Δ A _ X2And Δ A _ Y2If the image information is larger than epsilon, performing secondary correction on the box body, and obtaining corrected bits by utilizing the algorithm in the step 4-1 according to the image informationDeviation Δ A _ X3And Δ A _ Y3If Δ A _ X3And Δ A _ Y3If the box bodies are smaller than epsilon, aligning the box bodies, and turning to the step 4-6;
step 4-5. if Δ A _ X3And Δ A _ Y3If the position deviation is larger than epsilon, the box body is corrected for the third time, and the corrected position deviation delta A _ X is obtained by utilizing the algorithm in the step 4-1 according to the image information4And Δ A _ Y4If Δ A _ X4And Δ A _ Y4If the alignment is smaller than epsilon, the box bodies are aligned, and the step 4-6 is carried out, otherwise, the box bodies are not aligned, an alarm is given, the alignment is corrected manually, and the step 4-6 is carried out;
and 4-6, completely lifting the jacking mechanism to enable the port of the charging box to be in butt joint with the material filling port to perform charging, and enabling the cylinder to return to the initial position after charging is completed.
The invention provides a box body positioning control system based on machine vision, which comprises a limit switch, an image acquisition unit, an industrial personal computer, a PLC (programmable logic controller), a pneumatic cylinder and a jacking mechanism, wherein the image acquisition unit comprises industrial cameras A and B; the limit switch is arranged on the front side of the loading position of the pipeline, the loading box is stopped after reaching the loading station, the limit switch stops and sends an analog current signal of the loading box reaching the station to the PLC controller, and the PLC controller converts the analog current signal into a digital signal and sends the digital signal to the industrial personal computer through an RS485 bus; after receiving the signals, the industrial personal computer controls industrial cameras A and B arranged on two sides of the charging box to respectively acquire images of the current box body in the X direction and the Y direction, and acquired image information is transmitted to the industrial personal computer in real time; and after receiving the position deviation of the actual circle center of the opening of the charging box and the circle center of the filling opening in the direction of X, Y calculated by the industrial personal computer, the pneumatic cylinder pushes the charging box and the jacking mechanism lifts the charging box to a specified position.
Further, the PLC controller sends the digital signal to the industrial personal computer through the RS485 bus.
Further, the industrial personal computer controls the industrial cameras A and B which are arranged on two sides of the charging box through a network cable.
The invention has the beneficial effects that: the method solves the problems of low positioning precision, low automation level and the like in the traditional box positioning and filling production line through machine vision, servo control and information technology. Aiming at the problems of the traditional edge detection algorithm in the application of fast and high-precision extraction of the contour edge of the packing box, the existing Canny algorithm is improved, and adaptive adjustment strategies are introduced in links such as high and low gradient threshold setting, for example, based on gradient amplitude histogram and intra-class variance minimization. After the contour of the packing box body is obtained, the center of the circle of the extracted contour is positioned, and the position of the iron box in the packing box can be accurately obtained. The method has higher positioning precision and intelligent level in the positioning of the box body.
Drawings
The above and other advantages of the invention will become more apparent from the following description of the method according to the present invention with reference to the accompanying drawings and the detailed description.
FIG. 1 is a flow chart of a control system for a cabinet according to the present invention;
FIG. 2 is an original drawing of a double-layer box according to an embodiment of the present invention;
FIG. 3 is a top view of the camera and cylinder mounting location of the present invention;
FIG. 4 is a front view of the camera and cylinder mounting location of the present invention;
FIG. 5 is a schematic diagram of the X-direction deviation calculation in the present invention;
FIG. 6 is a filtered image-converted grayscale image of an embodiment of the present invention;
FIG. 7 is an image of an edge detected by a Canny operator according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of a control system and a cylinder actuator according to the present invention.
Detailed Description
The invention is further described below with reference to the figures and examples.
In recent years, with the development of computer vision technology, vision-based dimensional measurement has become possible. By utilizing machine vision and image processing technology, the working intensity of workers can be reduced, and the working efficiency and the measurement precision can be obviously improved. The image processing technology is used for replacing manual interpretation, so that the visual error caused by long-time manual work and the reading error caused by the working habit of a measurer are reduced, and the reading error and the aiming error of a measuring instrument are reduced.
The method integrates innovation in the links of box body positioning, correction and the like by means of machine vision, servo control, information technology and the like, and solves the problem of throwing in the filling process by the technologies of identification of the outline of the packing box and the dynamic position of the iron box charging opening and high-precision positioning control. Effectively improve the automation and the intelligent level of a factory and make positive contribution to the intelligent positioning and control of the box body.
For convenience of description, the double-deck container is referred to herein collectively as a container body, and the inner container opening is referred to collectively as a charging container opening.
The embodiment provides a box positioning control system based on machine vision, as shown in fig. 2 and 3. The box body positioning control system constructed by the method comprises a limit switch, an image acquisition unit, an industrial personal computer, a PLC (programmable logic controller), a pneumatic cylinder and a jacking mechanism, wherein the image acquisition unit comprises industrial cameras A and B; the limit switch is arranged on the front side of the loading position of the pipeline, the loading box is stopped after reaching the loading station, the limit switch stops and sends an analog current signal of the loading box reaching the station to the PLC controller, and the PLC controller converts the analog current signal into a digital signal and sends the digital signal to the industrial personal computer through an RS485 bus; after receiving the signals, the industrial personal computer controls industrial cameras A and B arranged on two sides of the charging box to respectively acquire images of the current box body in the X direction and the Y direction, and acquired image information is transmitted to the industrial personal computer in real time; and after receiving the position deviation of the actual circle center of the opening of the charging box and the circle center of the filling opening in the direction of X, Y calculated by the industrial personal computer, the pneumatic cylinder pushes the charging box and the jacking mechanism lifts the charging box to a specified position. The PLC controller sends the digital signal to the industrial personal computer through the RS485 bus. The industrial personal computer controls industrial cameras A and B which are arranged on two sides of the charging box through a network cable.
The flow chart of the box positioning control system is shown in FIG. 1, and comprises the following steps:
step 1, a limit switch arranged on the front side of a loading position of the assembly line stops the loading box after the loading box reaches a loading station, an analog current signal of the loading box reaching the station is sent to a PLC controller after the limit switch stops, the PLC controller converts the analog current signal into a digital signal and sends the digital signal to an industrial personal computer through an RS485 bus, and the industrial personal computer is shown in a figure 8;
step 2, after receiving the signals, the industrial personal computer controls the industrial cameras A and B which are arranged on two sides of the charging box through a network cable, respectively collects images of the current box body in the X direction and the current box body in the Y direction as shown in figures 3 and 4, and transmits the collected image information to the industrial personal computer in real time as shown in figure 2, and cuts out a part of a box opening of the charging box through template matching;
the step 2 of the invention comprises:
step 2-1, reading a target image I (x, y) obtained by shooting and a box opening template image T (x, y) prepared in advance, wherein (x, y) represents coordinates of pixels in the image, I (x, y) represents the target image, and T (x, y) represents a known box opening template image used for matching;
and 2-2, performing template matching by using a normalized interpolation square sum matching algorithm. Firstly, the template image and the target image are subjected to standardization processing to ensure that the correlation degree does not change when the brightness of each pixel of the template and the image is multiplied by the same coefficient.
The mathematical formula of the normalized interpolation sum of squares matching algorithm described above is as follows:
where the value of R (x, y) represents the degree of similarity at the (x, y) position.
And 2-3, carrying out normalization processing on the obtained matching result, wherein the normalization processing function is as the following formula (2):
wherein dst (x, y) is a pixel value after the image matrix is normalized, R (x, y) is a pixel value in the matching image result, min (R (x, y)) is a pixel minimum value in the matching image result, max (R (x, y)) is a pixel maximum value in the matching image result, min is a normalization range minimum value, and max is a normalization range maximum value. This example sets min to 0 and max to 1, i.e. normalizes the image matrix to between 0 and 1.
Step 3, denoising the picture of the opening of the charging box cut out in the step 2 by Gaussian filtering;
the step 3 of the invention comprises:
and 3-1, preprocessing the image of the opening of the charging box by using a Gaussian filter function. Scanning each pixel in the box opening image of the loading box by using a template image T (x, y), and replacing the value of a central pixel point of the template by using a weighted average gray value of pixels in a neighborhood determined by the template;
adopting Gaussian two-dimensional filtering to preprocess the box opening image of the charging box, as shown in formula (3):
wherein G (u, v) is a pixel value, the weighting coefficient sigma is 0.5, and u, v are pixel coordinates;
step 3-2, carrying out graying processing on the box opening picture of the charging box obtained in the step 3-2, as shown in fig. 6, and then smoothing the image by using a Gaussian filter;
the graying calculation formula is as follows (4):
Gray=R×0.299+G×0.587+B×0.114 (4)
where R, G, B are the three channels of the color image, Gray is the transformed result, and then the image is smoothed using a gaussian filter with a gaussian smoothing function:
wherein f (x, y) is an original image matrix, H (x, y) is a Gaussian kernel, G (x, y) is a smoothed matrix, and x and y are pixel coordinates;
step 3-3, then countingCalculating gradient value g of one pixel point of image in x and y directions after Gaussian filteringx(x, y) and gy(x, y), so as to calculate gradient value g (x, y) and gradient direction theta of the comprehensive gradient, if the gradient value of one pixel point in the gradient direction is maximum, the pixel point belongs to the edge, otherwise, the pixel point is not the edge, the gray value is set to 0, and thus an edge image of the opening of the inner box is obtained, as shown in fig. 7;
and 4, calculating to obtain position deviations delta A _ X and delta A _ Y of the actual circle center of the box opening of the charging box and the reference position in the direction X, Y respectively by taking the circle center of the charging opening as the reference position, further obtaining the distance which needs to be pushed by the pneumatic cylinder of the execution unit, if the distance is smaller than a set threshold value, lifting the jacking mechanism to execute charging operation, returning the pneumatic cylinder to the initial position after charging, returning to the step 1, otherwise, judging whether the correction frequency i is smaller than 3, if i is smaller than 3, controlling the pneumatic cylinder of the execution unit to move to correct the box body according to the position deviation value, adding 1 to the correction frequency i, returning to the step 2, if i is not smaller than 3, manually correcting alignment, then executing charging operation, returning to the initial position after charging, and returning to the step 1.
The step 4 of the invention comprises:
and 4-1, summing the black and white pixel values of each row of the obtained edge image of the opening of the loading box through the A camera, searching the positions left and right of the pixels at the two ends of the maximum diameter of the edge image of the opening of the inner-layer box so as to find the center of the edge image of the opening in the X direction, and similarly, finding the center of the edge image of the opening in the Y direction by using the edge image of the opening of the loading box obtained by the B camera so as to position the position information of the box.
The specific implementation method for finding the direction centers of the cameras A and B comprises the following three steps:
step 1, reading a box opening edge gray image, because the image is stored in a matrix form in a computer program, obtaining the size height and width of the image by obtaining the matrix dimension of the image, then judging whether the pixel value of each column is equal to 255 or 0 according to the fact that the black pixel value is 0 and the white pixel value is 255, thereby calculating the sum of the number of black and white pixels of each column of the image, and recording the maximum value of the number of black pixels as black _ max and the maximum value of the number of white pixels as white _ max, if the total number s of black pixels is greater than the total number t of white pixels, indicating that the obtained box opening edge image is white with black bottom, namely the image background is that the black box opening edge is white, as shown in fig. 7.
Step 2, initializing a left-end pixel position left of the box opening to be 1, a right-end pixel position right of the box opening to be 2 and a searching frequency n to be 1, and if n is less than width-2, judging whether the total number white [ n ] of white pixels in the nth column is greater than a value of alpha multiplied by white _ max, wherein alpha is 0.02; if white [ n ] is not larger than alpha x white _ max, it indicates that the nth row is still in the black background of the image and no white box opening edge is detected, and then n +1 returns to continue to determine whether the total white number of the pixels in the next row meets the requirement.
And 3, if the white [ n ] is greater than 0.02 × white _ max, indicating that the leftmost pixel position of the white box opening is detected, making the leftmost pixel position left equal to n, then searching the rightmost pixel position right of the box opening from the left +1 column by using the same method, and judging whether the total number black [ m ] of black pixels in the mth column is greater than the value of β × black _ max, wherein β is 0.99. If black [ m ] > 0.99 × black _ max indicates that the rightmost pixel position right of the box opening is detected to be m, the center of the box opening is (right-left)/2, otherwise, m +1 returns to continue judging until the condition is met, and position information of the center of the box opening is output.
Step 4-2, calculating to obtain position deviation information delta A _ X of the actual circle center of the opening of the charging box and the reference in the direction X, Y by taking the circle center of the charging opening as the reference position1And Δ A _ Y1Then, as shown in fig. 5, the X-direction deviation calculation schematic diagram is shown, and if the X-direction deviation is smaller than the alignment deviation by 0.5mm, the process goes to step 4-6. Otherwise, the position of the port of the charging box is corrected once as shown in FIGS. 3 and 8 by pushing the box body by the A, B cylinder group, and the corrected positional deviation DeltaA _ X is calculated once again from the image information by the algorithm in step 4-12And Δ A _ Y2Root of Chinese characterAccording to Δ A _ X2And Δ A _ Y2Whether the alignment deviation is less than 0.5mm or not is judged, and whether the box opening of the inner layer box is aligned with the material filling opening or not is judged;
step 4-3. if Δ A _ X2And Δ A _ Y2If the sizes of the boxes are smaller than 0.5mm, aligning the boxes, and turning to the step 4-6;
step 4-4. if Δ A _ X2And Δ A _ Y2If the distance is larger than 0.5mm, performing secondary correction on the box body, and obtaining the corrected position deviation delta A _ X by utilizing the algorithm in the step 4-1 according to the image information3And Δ A _ Y3If Δ A _ X3And Δ A _ Y3If the box bodies are smaller than epsilon, aligning the box bodies, and turning to the step 4-6;
step 4-5. if Δ A _ X3And Δ A _ Y3If the distance is larger than 0.5mm, the box body is corrected for the third time, and the corrected position deviation delta A _ X is obtained by utilizing the algorithm in the step 4-1 according to the image information4And Δ A _ Y4If Δ A _ X4And Δ A _ Y4If the sizes of the box bodies are smaller than 0.5mm, the box bodies are aligned, the step 4-6 is carried out, otherwise, the box bodies are not aligned, an alarm is given, the alignment is corrected manually, and the step 4-6 is carried out;
and 4-6, completely lifting the jacking mechanism to enable the port of the charging box to be in butt joint with the material filling port to perform charging, and enabling the cylinder to return to the initial position after charging is completed.
While the present invention provides a tank control system and many methods and approaches for implementing the same, it is to be understood that the above description is only a preferred embodiment of the present invention, and it should be understood that the embodiments described herein are for the purpose of assisting the reader in understanding the principles of the present invention, and that the scope of the present invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific changes and combinations based on the teachings of the present invention without departing from the spirit of the invention, and these changes and combinations are within the scope of the invention.
- 上一篇:石墨接头机器人自动装卡簧、装栓机
- 下一篇:一种交互式可升降中央分隔带及其控制方法