Empty container detection method based on radiation imaging
1. A container empty box detection method based on radiation imaging is characterized in that: the detection method comprises two parts: (1) carrying out radiation imaging on a vehicle loading a container to obtain a perspective image of the vehicle head of the container after avoiding; (2) digital image processing is carried out on perspective images of container vehicles to extract a container target area, the container target area is calculated through an algorithm, and whether a detected container is an empty container or not is judged according to a calculation result;
the algorithm for extracting the container target area from the container vehicle perspective image comprises the following steps:
step 1.1: bright and dark field correction is carried out on the perspective image to obtain a corrected image M1;
step 1.2: performing 5 multiplied by 5 window Gaussian blur and histogram equalization processing on the M1 image to obtain an image M2;
step 1.3: normalizing the M2 image to 0-255 by using the maximum and minimum values to obtain an image M3;
step 1.4: the method comprises the steps of obtaining an image M4 by inverting the M3 image, carrying out column-by-column pixel value mean calculation on the M4 image to obtain a one-dimensional array ArrCols, wherein the length LenCols of the array is consistent with the width of the M4 image;
step 1.5: traversing the ArrCols array from ArrCols [0] to ArrCols [ LenCols/2] to obtain a first ArrCols [ i ] value larger than a threshold Thred, and obtaining a corresponding array ArrCols index i, wherein the threshold Thred has a value range of 200 to 100, and the initial value is 100;
step 1.6: if the ArrCols [ i ] value larger than Thred is not obtained in the step 1.5, continuing to decrement the threshold Thred by taking the step length as 10, and performing the step 1.5 until the first ArrCols [ i ] value larger than the threshold Thred is obtained and a corresponding array ArrCols index i is obtained, wherein i is the position of the left edge of the container;
step 1.7: traversing the ArrCols array from the ArrCols [ LenCols ] direction to the ArrCols [ LenCols/2] direction to obtain a first ArrCols [ j ] value larger than a threshold Thred, and obtaining a corresponding array ArrCols index j, wherein the value range of the threshold Thred is 200-100, and the initial value is 200;
step 1.8: if the ArrCols [ j ] value larger than Thred cannot be obtained in the step 1.7, continuing to decrease the threshold Thred by taking the step length as 10, and performing the step 1.7 until the first ArrCols [ j ] value larger than the threshold Thred is obtained and a corresponding array ArrCols index j is obtained, wherein j is the right edge position of the container;
step 1.9: performing progressive pixel value mean calculation on the M4 image to obtain a one-dimensional array ArrRows, wherein the length LenRows of the array is consistent with the height of the M4 image;
step 1.11: traversing the ArrRows array from ArrRows [0] to Arr [ LenRows/2] to obtain a first ArrRows [ k ] value larger than a threshold value Thred, and obtaining a corresponding array ArrRows index k, wherein the threshold value Thred is in a value range of 200 to 100, and the initial value is 200;
step 1.12: if ArrRows [ k ] values larger than Thred are not obtained in the step 1.11, continuing to decrement the threshold Thred by taking the step size as 10, and performing the step 1.11 until the first Arr [ k ] value larger than the threshold Thred is obtained, and obtaining a corresponding array ArrRows index k, wherein k is the position of the top edge of the container;
step 1.13: traversing the ArrRows array from ArrRows [ LenRows ] to ArrRows [ LenRows/2] to obtain a first ArrRows [ m ] value larger than a threshold value through and obtain a corresponding array ArrRows index m, wherein the threshold value through is in a value range of 200-100, and the initial value is set to be 200;
step 1.14: if the ArrRows [ m ] value larger than the threshold value through the step 1.13 is not obtained, continuing to decrease the threshold value through the step length of 10, and performing the step 1.13 until the first ArrRows [ m ] value larger than the threshold value through is obtained, and obtaining a corresponding array ArrRows index m, wherein m is the position of the bottom edge of the container;
step 1.15: through the steps 1.6, 1.8, 1.12 and 1.14, the positions i, j, k and m of the container at the left side, the right side, the top and the bottom in the image are obtained, so that the container target area can be extracted;
after a container target area is obtained, carrying out algorithm calculation on the container target area to judge whether the container is empty or not, wherein the method comprises the following steps;
step 2.1: extracting an Mroi map of the container region from the rectified image M1 and the i, j, k and M values;
step 2.2: sequentially carrying out Gaussian blur, histogram equalization and USM sharpening on the Mroi to obtain an Mroi2 image;
step 2.3: carrying out self-adaptive binarization on the Mroi2 image to obtain an image Mroi 3;
step 2.4: carrying out pixel mean calculation in the column direction on the Mroi3 graph to obtain an array Arr, wherein the calculation formula is
Arr is a pixel mean value array in the column direction of the Mroi3 image, the length of Arr is equal to the width b of the Mroi3, rows is the height of the image, namely the number of pixels in each column of the Mroi3, and M is a matrix corresponding to the Mroi3 image;
step 2.5: for a container with evenly distributed articles, the following algorithm is carried out: if the mean value of the array Arr is more than 80, judging that the container is filled with uniformly distributed articles, wherein the container is a non-empty container;
step 2.6: for the container with non-uniformly distributed articles, the algorithm judgment process is as follows:
calculating the Arr array to obtain an average value Avg, calculating the weight f according to the difference between the average value Avg and the Arr array, wherein the calculation formula of f is
Wherein h is the h index of the array Arr;
the weighted variance of Arr is calculated as follows
WhereinIs the weighted variance, cols is the length of Arr;
according toThe value judges whether the box is empty, if soIf the value is greater than or equal to 50.5, the box is not empty (the value is an empty box calibration value), and if the value is less than the empty box calibration value, the box is empty.
Background
China is a big trade country and also belongs to a big export-oriented economy country, a large number of empty containers enter the customs every year, and the detection demand of the empty containers of the containers is increased day by day. At present, the domestic container empty box detection methods mainly comprise two methods: one is that the container vehicle that adopts the business turn over gateway must open the cabinet door, the bayonet socket must have high-order camera and searchlight and can shine into the box, the artifical interception examines the condition in the empty case, or carry out the manual/machine inspection of arrangement control empty vehicle weight at random and examine, this kind of method all needs the special personnel to intervene in the field of gateway passageway and handles, there are operating efficiency low, receive natural conditions such as weather light to influence greatly, a large amount of mechanicalness and invalid inspection easily flow out defects such as form, potential low administrative or public affairs hidden danger, to the supervision place that the business is busy, foretell defect is easily smuggled the molecule and is discovered and utilized. The other method is to detect the empty container by an ultrasonic instrument developed by a certain domestic manufacturer, and the principle is to judge whether the empty container exists or not by comparing the ultrasonic characteristics of the empty container acquired in advance with the ultrasonic characteristics of the container actually measured. The method has three important defects that the first container and the second container are made of different materials, the thicknesses of iron sheets are different, the influence on ultrasonic echoes is great, great difficulty is brought to the calibration and collection of the echo characteristics of the empty container of the container, the collection of the echo characteristics of the empty container is inaccurate and cannot be accurately judged, the second ultrasonic generator and the sonar must scan the whole container from left to right from top to bottom, vehicles must stop, the consumed time is too long, and the inspection efficiency is very low compared with a container empty container detection method based on radiation imaging without stopping. Thirdly, mechanical equipment such as an engine and the like can generate a large amount of ultrasound during operation to interfere detection, particularly for an area close to the bottom of the container, the ultrasound features are complex, empty box judgment cannot be carried out according to ultrasound feedback, and in practical application, an empty box detection system based on ultrasonic waves is unsatisfactory in the aspect of accuracy.
Disclosure of Invention
The invention aims to provide a radiation imaging-based container empty detection method, which is characterized in that a radiation imaging technology is adopted to collect a perspective view of a container vehicle in a non-stop mode, a container area is extracted by using an image algorithm according to a perspective view, so that the algorithm processing is carried out on the container area, and whether the container is an empty container or not is judged according to a processing result.
The technical scheme of the invention is as follows: a container empty box detection method based on radiation imaging is characterized in that: the detection method comprises two parts: (1) acquiring a perspective view of the container vehicle by a radiation imaging device; (2) and processing the perspective view, extracting a container region, and performing algorithm processing on the picture of the container region so as to judge whether the container is empty.
The algorithm for extracting the container target area from the container vehicle perspective image comprises the following steps:
step 1.1: bright and dark field correction is carried out on the perspective image to obtain a corrected image M1;
step 1.2: performing 5 multiplied by 5 window Gaussian blur and histogram equalization processing on the M1 image to obtain an image M2;
step 1.3: normalizing the M2 image to 0-255 by using the maximum and minimum values to obtain an image M3;
step 1.4: the method comprises the steps of obtaining an image M4 by inverting the M3 image, carrying out column-by-column pixel value mean calculation on the M4 image to obtain a one-dimensional array ArrCols, wherein the length LenCols of the array is consistent with the width of the M4 image;
step 1.5: traversing the ArrCols array from ArrCols [0] to ArrCols [ LenCols/2] to obtain a first ArrCols [ i ] value larger than a threshold Thred, and obtaining a corresponding array ArrCols index i, wherein the threshold Thred has a value range of 200 to 100, and the initial value is 100;
step 1.6: if the ArrCols [ i ] value larger than Thred is not obtained in the step 1.5, continuing to decrement the threshold Thred by taking the step length as 10, and performing the step 1.5 until the first ArrCols [ i ] value larger than the threshold Thred is obtained and a corresponding array ArrCols index i is obtained, wherein i is the position of the left edge of the container;
step 1.7: traversing the ArrCols array from the ArrCols [ LenCols ] direction to the ArrCols [ LenCols/2] direction to obtain a first ArrCols [ j ] value larger than a threshold Thred, and obtaining a corresponding array ArrCols index j, wherein the value range of the threshold Thred is 200-100, and the initial value is 200;
step 1.8: if the ArrCols [ j ] value larger than Thred cannot be obtained in the step 1.7, continuing to decrease the threshold Thred by taking the step length as 10, and performing the step 1.7 until the first ArrCols [ j ] value larger than the threshold Thred is obtained and a corresponding array ArrCols index j is obtained, wherein j is the right edge position of the container;
step 1.9: performing progressive pixel value mean calculation on the M4 image to obtain a one-dimensional array ArrRows, wherein the length LenRows of the array is consistent with the height of the M4 image;
step 1.11: traversing the ArrRows array from ArrRows [0] to Arr [ LenRows/2] to obtain a first ArrRows [ k ] value larger than a threshold value Thred, and obtaining a corresponding array ArrRows index k, wherein the threshold value Thred is in a value range of 200 to 100, and the initial value is 200;
step 1.12: if ArrRows [ k ] values larger than Thred are not obtained in the step 1.11, continuing to decrement the threshold Thred by taking the step size as 10, and performing the step 1.11 until the first Arr [ k ] value larger than the threshold Thred is obtained, and obtaining a corresponding array ArrRows index k, wherein k is the position of the top edge of the container;
step 1.13: traversing the ArrRows array from ArrRows [ LenRows ] to ArrRows [ LenRows/2] to obtain a first ArrRows [ m ] value larger than a threshold value through and obtain a corresponding array ArrRows index m, wherein the threshold value through is in a value range of 200-100, and the initial value is set to be 200;
step 1.14: if the ArrRows [ m ] value larger than the threshold value through the step 1.13 is not obtained, continuing to decrease the threshold value through the step length of 10, and performing the step 1.13 until the first ArrRows [ m ] value larger than the threshold value through is obtained, and obtaining a corresponding array ArrRows index m, wherein m is the position of the bottom edge of the container;
step 1.15: the positions i, j, k, m of the container on the left, right, top and bottom in the image are obtained through step 1.6, step 1.8, step 1.12 and step 1.14, so that the container target area can be extracted.
After a container target area is obtained, carrying out algorithm calculation on the container target area to judge whether the container is empty or not, wherein the method comprises the following steps;
step 2.1: extracting an Mroi map of the container region from the rectified image M1 and the i, j, k and M values;
step 2.2: sequentially carrying out Gaussian blur, histogram equalization and USM sharpening on the Mroi to obtain an Mroi2 image;
step 2.3: carrying out self-adaptive binarization on the Mroi2 image to obtain an image Mroi 3;
step 2.4: carrying out pixel mean calculation in the column direction on the Mroi3 graph to obtain an array Arr, wherein the calculation formula is
Arr is a pixel mean value array in the column direction of the Mroi3 image, the length of Arr is equal to the width b of the Mroi3, rows is the height of the image, namely the number of pixels of each column of the Mroi3, and M is a matrix corresponding to the Mroi3 image.
Step 2.5: for a container with evenly distributed articles, the following algorithm is carried out: if the mean value of the array Arr is more than 80, judging that the container is filled with uniformly distributed articles, and judging that the container is a non-empty container.
Step 2.6: for the container with non-uniformly distributed articles, the algorithm judgment process is as follows:
calculating the Arr array to obtain an average value Avg, calculating the weight f according to the difference between the average value Avg and the Arr array, wherein the calculation formula of f is
Where h is the h index of the array Arr.
The weighted variance of Arr is calculated as follows
WhereinCols is the length of Arr, a weighted variance.
According toThe value judges whether the box is empty, if soIf the value is greater than or equal to 50.5, the box is not empty (the value is an empty box calibration value), and if the value is less than the empty box calibration value, the box is empty.
The invention has the advantages that: (1) the container vehicle to be checked passes through the detection channel directly without stopping (head avoidance is realized through an electrical technology). (2) The processing method based on the digital image algorithm has higher empty box detection accuracy. (3) The empty box judgment mode based on the digital image algorithm has higher expansibility, and the empty box identification of other types of containers can be improved by upgrading the algorithm instead of hardware. (4) The algorithm provided by the invention has the advantages of low complexity and high stability, meets the actual condition of vehicle speed change within a certain range, and also meets the calculation real-time requirement of a medium-low processor.
Drawings
Fig. 1 is a schematic structural diagram of an empty box detection device based on ultrasonic technology.
Fig. 2 is a schematic diagram of an empty box detection structure based on radiation imaging.
Fig. 3 is a perspective view of a container with an avoided vehicle head based on radiation imaging technology.
Fig. 4 is a graph of container target areas extracted by the algorithm.
Fig. 5 is a container target area map after array image processing.
Fig. 6 is a pixel mean graph calculated in the column direction for a container target area map.
Fig. 7 is a container target area extraction algorithm flow diagram of a container perspective view.
FIG. 8 is a flow chart of an algorithm for empty box determination of the container target area image.
In fig. 1: the system comprises an a-ultrasonic generator, a sonar, a b-ultrasonic instrument base, a c-ultrasonic instrument mechanical arm, a d-vehicle detection channel and an e-container vehicle to be detected.
In fig. 2: the system comprises a 1-ray source, a 2-detector, a 3-outlet contraposition grating used for avoiding a vehicle head, a 4-inlet contraposition grating used for avoiding the vehicle head, a 5-empty box algorithm calculation computer, a 6-vehicle detection channel and a 7-container vehicle to be detected.
Detailed Description
The following describes in further detail specific embodiments of the present invention with reference to the accompanying drawings.
Fig. 2 is a structure diagram of empty container detection based on radiation imaging, 1 is a ray generating device, 2 is a ray detector, imaging is carried out according to different intensities of rays after the rays are attenuated by vehicles, 3 and 4 are vehicle head avoiding gratings, beam outgoing and beam stopping of a ray source can be controlled through signals besides vehicle head avoiding protection of driver safety, 5 is an upper computer for perspective processing and empty container judgment algorithm operation, 6 is a detection channel, a container vehicle 7 to be detected is driven by a driver to pass through the detection channel 4 at a certain speed, the operation of the ray source and the detector is triggered through vehicle head avoiding infrared rays, and container vehicle perspective is collected. The perspective view of the container vehicle is transmitted to the upper computer 5 in real time. The above is the process of the radiation imaging container perspective view diagram.
After the container perspective is obtained, the upper computer 5 extracts a container target area, the extracted algorithm flow is to perform bright and dark field correction on the original perspective, perform Gaussian blur, histogram equalization and USM sharpening on the corrected image, perform self-adaptive binarization segmentation to obtain a binarized image, perform mean value calculation in the column direction on the binarized image, and compare a weighted variance value of the mean value with a weighted variance value of an empty box so as to judge whether the empty box exists. The weighted variance value of the empty box can be calibrated once, and the calibration value is 50 +/-0.5 through actual measurement.
The above description is only of the preferred embodiments of the present invention, and it should be noted that: it will be apparent to those skilled in the art that various modifications and adaptations can be made without departing from the principles of the invention and these are intended to be within the scope of the invention.