Research on online inspection system of emulsion explosive packaging defect based on machine vision

Roll packaging is the last step in the emulsion explosives production line. Due to various reasons, explosives may have defects in the packaging process. How to sort defective drug coils efficiently and accurately is a major problem. In this paper, an online detection system for drug package which based on machine vision is developed for the defect of emulsion explosive drug packaging. This paper mainly discusses the image preprocessing, image segmentation and feature extraction. The test and application show that the system can detect the defect drug coil better and has the advantages of fast and accurate, which can meet the needs of the production site.


Introduction
In traditional industrial sites, workers are usually checking the quality of medicine packages along the production line and inspecting the operation of production lines.This method is inefficient and cannot guarantee the accuracy of the test.Machine vision [1] technology uses computers and video cameras instead of people to track, detect and judge the target.Its non-contact, precise, continuous, and efficient features for on-line detection of targets are ideally suited for applications in the explosive production environment.It enables people to get rid of dangerous and harsh working environments in explosives production workshops, and at the same time, it can detect explosives production conditions in real time online and collect valid data to provide important basis for production control.
In this paper, the visual inspection system for drug package defects was developed for the problem of drug package defects.First introduced the overall structure of the system framework.Secondly, the specific methods of image preprocessing, image segmentation and image edge detection are discussed.Finally, the defect feature of the medicine image was extracted and the standard template of the medicine roll was established.The medicine image was collected in real time and compared with the standard template to realize on-line detection and identification of the package defect drug.

The system structure
As is shown in figure 1, the emulsion explosive defect detection system [2] consists of an image acquisition unit, an image processing unit, a host computer control unit, and an execution unit.In order to ensure the coverage of the entire detection area of the drug roll, two industrial cameras are used at the same time to avoid missing images at certain intervals.The camera collects images and then detects defects in the package.Eventually, the control unit controls the actuators to sort them.

The design method 3.1 Problem Analysis
Roll defects mainly refer to the abnormal contour of the roll or the rupture of the plastic film packaging bag to cause leakage of the emulsion explosive.At the same time, in the process of converting the explosive packaging machine, due to too little charge, the explosive surface is not full and other defects.According to the analysis of the explosive production process, the defect of the roll profile mainly occurs in the charging process, and the reasons are various.By analyzing the actual production process and collecting medicine roll images, the main manifestation of packaging defects is the unusual shape of the drug roll, which can be divided into: (A) side-end leakage drug of drug roll; B) drug leakage at both ends of drug roll; C) drug The package is not full.
The parameters of the drug roll include the circumference, area, weight, color, angle, volume, length, width, and long section ratio of the drug roll.Through long-term practical experience, the difference between the defective drug roll and the qualified drug roll is mainly shown in length (L), width (W), and aspect ratio (RAT).

Cartridge parameters
The The charge is not full The data in the table 1 shows that the lengths, widths, and aspect ratios of different types of drug cartridges are different.These three data can be used as defect features for detection and classification, and the characteristic values of the normal drug volumes are used as templates to be tested.The characteristic value of the drug roll is compared with the

Image preprocessing
First, the image is thresholded.Due to the fact that the conveyor belt on the industrial field roll packaging production line is basically green, the roll itself is mostly yellow, and the pixel values of the roll and the belt are very different.According to the histogram of image in figure 2, there are two peaks in the histogram, which represent the gray values of the pixels of the belt and the medicine roll.From this, it can be concluded that the front and rear views of the image are very easy to distinguish.Image processing takes the OSTU [3] threshold segmentation to find the optimal threshold.Split the image as shown in figure 3.
After dividing, the binary image of the image can be obtained, and the medicine roll can be completely separated from the background.Due to the presence of noise, the corresponding filtering algorithm is used to smooth the rough edges of the drug roll.Then the Hough [4] algorithm is used to extract the contour of the image so as to obtain the feature value of the medicine image.

Edge detection -Hough algorithm
For a straight line in the plane, in the Cartesian coordinate system, there are two types of representations: a little oblique and two-point.However, in the Hough transformation, another type of representation is considered: using (r, θ) to represent a straight line.Where r is the distance from the line to the origin, and θ is the angle between the vertical line of the line and the x-axis.
The idea of using a Hough transform to detect a straight line is to assume a straight line of n directions for each point, usually n is equal to 180.At this time, the angle accuracy of the detected straight line is 1°, and calculate the (r, θ) of the n straight lines respectively.Coordinates, get n coordinate points.If there are N total points to be judged, the resulting (r, θ) coordinates are N*n.Regarding these N*n (r, θ) coordinates, where θ is a discrete angle, there are a total of 180 values.The most important place to come if multiple points are in a straight line,Then there must be more than one point where θ is equal to a certain value, and r for multiple points is approximately equal to i R .Means that these multiple points are in a straight line ( i R , i  ).For the (r, θ) coordinates of 6 straight lines for which each point was found (figure 4), a total of 3*6 (r,θ) coordinates were obtained.It can be found that when θ is equal to 60, the r of the three points is approximately 80.7, and it can be determined that all three points are on the straight line (80.7,60).This relationship can be more intuitively represented by the (r,θ) coordinate system.As shown below: The (r,θ) curves for the three points in the graph are grouped together.The intersection is the straight line passing through these three points.Figure 5 shows that, in general, a straight line can be detected by finding the number of curves that intersect at one point in the plane θ-r.And the more the curve intersects, the more the points the line represented by the intersection point consists of.We can define multiple curves to intersect at a point by setting the threshold of the point on the line so that it is considered that a straight line is detected.This is what the Hough transform does.It tracks the intersection of the curves at each point in the image.If the number of curves intersecting one point exceeds the threshold, then the parameters represented by this intersection can be considered as (θ,  r ) in the original image is a straight line.
In this paper, the Hough algorithm is used to detect the edge of the drug image, and the canny edge detection and the Laplace detection effect are compared.The Hough algorithm's processing effect is obviously better (figure 6).Fig. 6.Canny, Laplace and Hough Algorithm renderings.

Drug coil defect feature extraction and identification
It is mainly to obtain the profile features of the drug roll, specifically parameters such as L, W and a.Since the contour of the drug roll is relatively close to the rectangle, a rectangle can be used to approximate the drug roll contour indefinitely to obtain the minimum external rectangle of the drug roll (figure 7), so that L and W values can be obtained and the a value can be calculated.The specific steps are as follows: (1) Detect the contour of the drug roll; (2) Obtain the minimum circumscribed rectangle; (3) Calculate the vertices [5] of the circumscribed rectangle, L, W, and a.Finally, the acquired actual roll image is used to compare with the set S of standard template perimeters.Each acquired image is compared with the data of Table 1 to identify the defect category.In the experiment, 100 defect images of three types were selected for inspection.Type A defects were defined as abnormal widths and lengths of standard drug coils.Type B was defined as abnormally long and normal widths of drug coils.Type C defects were defined as length and width.Abnormal drug roll, which class defect C refers to the charge is not saturated.Experimental results as shown in table 2, the three defects can be detected very well, at the same time very short, with a very high practicality.

Conclusion
This article discusses the establishment of an emulsion explosives detection system based on machine vision.Using machine vision technology, the image collection, image processing, feature extraction, and defective drug roll identification and sorting were performed on the drug roll produced in the production process, and a good diagnostic effect was achieved.The main conclusions are as follows: The machine vision-based emulsion explosives detection system has the advantages of non-contact, precise, continuous, and high-efficiency.Compared to the original manual sorting, it saves a lot of manpower and material resources, and can also conduct better screening.Has a very high practicality.In the production process, it may also happen that there is a crack [6] in the drug package, which is the direction that the author needs to study in the later period, in order to be able to better solve various problems in the packaging production site.

2 MATEC
Web of Conferences 189, 05004 (2018) https://doi.org/10.1051/matecconf/201818905004MEAMT 2018 characteristic value of the template drug roll to realize the identification and removal of the defective drug roll.

Fig. 4 .
Fig. 4. The intersection of six straight lines at each point.