Full-automatic injection bottle filling and sealing qualification high-speed identification system
By designing a fully automatic injection bottle filling and sealing qualified high-speed identification system, the problems of lax packaging and low detection efficiency in the existing technology are solved, and high-precision and high-speed packaging defect detection are achieved, which improves the reliability and speed of detection.
Patent Information
- Application Number
- CN202411729442.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-04-25
AI Technical Summary
The prior art has many problems in the inspection of injection bottle filling and sealing qualifications, including the risk of drug quality changes due to lax packaging, low efficiency and poor reliability due to detection relying on human eyes, unreasonable system architecture, untargeted image processing methods, and low positioning and recognition accuracy.
A fully automatic injection bottle filling and sealing qualified high-speed identification system is designed, including an array focusing lighting device, a bottle image acquisition device, a filling and sealing identification system and a high-speed process control system. The MATLAB language is used to implement the programming of each module of the system, and a bottle cap packaging defect detection algorithm is designed. Through step-by-step image refinement, bottle plug area positioning and defect recognition, real-time detection of the packaging quality of the injection bottle is achieved.
It realizes high-precision and high-speed injection bottle packaging defect detection, improves detection efficiency and accuracy, and can detect 150 injection bottles per minute. It has a wide range of application and strong versatility, which significantly improves the reliability and speed of detection.
Smart Images

Figure CN119880902A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to an injection bottle filling and sealing identification system, and in particular to a full-automatic injection bottle filling and sealing qualified high-speed identification system, belonging to the injection bottle identification technical field. Background Art
[0002] In the production process of injection bottles, the quality of their packaging is very important. If the packaging is not tight, it will affect the quality of the injection in a short time and cause it to change qualitatively. The filling and sealing quality of injection bottles is directly related to life safety.
[0003] At present, the main packaging materials used for injection bottle packaging include some glass materials, rubber-textured materials, metal materials and composite materials. Because glass materials are very stable and will not react chemically with any solid or liquid drugs, they are safe and reliable. In addition, glass has the advantages of transparency, recyclability and low price. Glass packaging materials are widely used in the fields of biological products, injections, lyophilized agents, blood products, etc. If the capping machine is not adjusted to the appropriate position, the bottle cap and the bottle body will not be tightly sealed, and the injection bottle will be poorly packaged and the drug will deteriorate. Therefore, in the assembly line production of injection bottles, it is necessary to ensure that the packaging quality of the injection bottles is good.
[0004] Due to the extremely high requirements for the packaging quality of injection bottles, the inspection mainly relies on human eyes to check one by one. However, human eyes are easily fatigued and need to work continuously for several hours. They are also affected by personal mood and state, which is highly subjective and inefficient. This kind of inspection method is difficult to unify the inspection standards, is particularly unreliable, and has low intelligence and automation. The traditional manual inspection method can no longer meet the requirements of production automation and product quality standardization. The visual inspection method can greatly improve the automation and production efficiency of injection bottle production.
[0005] In the actual production line, if the capping machine is not adjusted to the appropriate position, the bottle cap and the bottle body will not be tightly sealed, resulting in poor sealing of the injection bottle and the deterioration of the drug. Therefore, whether the injection bottle is sealed is an extremely important step in the injection bottle production process. At present, it is urgent to correctly identify defective and non-defective injection bottles.
[0006] At present, computer automatic detection is widely used in the packaging industry. Because the packaging process is mostly completed without manual operation, it often leads to omissions, defects, and wrong installation. The computer automatic detection system can automatically identify these omissions, defects, and wrong installations, and remove unqualified products. Cognex of Germany has designed the N-SIGHT series of products and PATMAX software, which are widely used in the appearance of food packaging and the position and text detection of labels, and automatic filling by robots; Effit has designed the EF-VS2000 series of products, which can well solve the problems of detection, identification and positioning in the production and packaging of modern industrial products; Siemens has designed the VS100 series and VS700 series, which are widely used to identify the production date on food packaging, check the label placement position, etc.
[0007] However, there are still many unresolved technical problems in the computer-automatic inspection of injection bottles: the images collected by the computer are often plane images, so there is no way to obtain the dynamic response of the three-dimensional depth information and orientation of the image, and the injection bottles are often not flat, which will lead to uneven acquisition distances and color distortion of the image. The existing technology lacks a good method to correct this problem; for the existing technology of multi-index detection items, we still rely on serial algorithms to a large extent, which is not conducive to improving the processing speed. Therefore, the parallel algorithm for multi-image processing is also a technical problem that needs to be solved.
[0008] At present, computer automatic detection technology is widely used in all aspects and fields of packaging industry detection. The main purpose of packaging detection is to identify and judge whether the packaged products have reached the qualified standards. Its main task is to make correct judgments on the packaging defects on the surface of each package and to make correct identification of the barcode and character string on the package.
[0009] In summary, the prior art injection bottle filling and sealing qualified detection system has several problems and defects. The difficulties and problems to be solved in this application are mainly concentrated in the following aspects:
[0010] First, in the production process of injection bottles, if the capping machine is not adjusted to the appropriate position, the bottle cap and the bottle body will not be tightly sealed, which will cause qualitative changes in a short time. The filling and sealing quality of injection bottles is directly related to life safety. Due to the extremely high requirements for the sealing quality of injection bottles, the relatively reliable detection of existing technologies mainly relies on human eyes to check one by one, but human eyes are easily fatigued and need to work continuously for several hours. They are also affected by personal mood and state, which is highly subjective and inefficient. It is difficult to unify the detection standards of this detection method, and the degree of intelligence and automation is also low. The traditional manual detection method can no longer meet the requirements of production automation and product quality standardization, resulting in low automation and production efficiency in the production of injection bottles, and also burying hidden dangers to the quality of injection bottles and the health of the people;
[0011] Second, the overall architecture design of the injection bottle filling and sealing identification system in the prior art is unreasonable and imperfect. The lighting device lacks the lighting condition design for the injection bottle. The lens, camera and image acquisition software of the bottle image acquisition device are not targeted and stable enough, and it is impossible to acquire high-quality images for subsequent image processing. There is a lack of efficient image step-by-step refinement and positioning methods. The filling and sealing identification system has a high error rate, the process control system has a low matching degree and slow speed, and the real-time detection is poor. In actual production operations, it is impossible to effectively complete the positioning of the injection bottle on the conveyor belt and the knocking out of unqualified injection bottles. It is impossible to make the detection speed keep up with the speed of the assembly line, and it is impossible to ensure that the detection system can quickly collect and transmit the target image. The design of the hardware and software algorithms is not combined with the injection bottle filling and sealing production line, and the real-time performance requirements of the production line system are rarely considered.
[0012] Third, the existing technology lacks the image segmentation specifically for the bottle packaging inspection, lacks the specially designed image feature graying, image denoising, edge enhancement, and image target area segmentation methods, and does not reasonably handle the image details to be highlighted and the parts to be weakened or removed, and cannot suppress and eliminate useless information in the image, cannot simplify the data volume and highlight the detectability of useful information, and cannot segment the packaging target image of interest, resulting in the detection accuracy not meeting the requirements. For the device for the purpose of detection, the most important detection accuracy is directly caused by the poor reliability of the system, the accuracy of the detection device and the detection algorithm is not high, and the coordination ability of the various parts of the device is weak. Since the composition of various injection bottles is different, the size and shape of the bottle stoppers are also different, and some links of the packaging quality detection will also be different, and the system versatility is poor;
[0013] Fourth, the prior art lacks targeted methods for coarse and fine positioning of the cork area, and lacks methods for feature extraction and measurement of injection bottles, contour feature extraction, and identification of packaging defects of injection bottles. The cork positioning position of the prior art method is fixed. When the system is unstable, an incomplete cork may be positioned, resulting in a relatively high missed detection rate and false detection rate. At the same time, there is a lack of image registration and image difference operations. In the hardware part, the various components of the device cannot guarantee long-term stable operation. In the software part, the algorithms and programs of the prior art cannot guarantee the accurate detection of injection bottles with packaging defects, and cannot guarantee long-term stable operation, which ultimately leads to the failure to meet the requirements for detection reliability, speed and accuracy, and cannot be promoted to practical applications. Summary of the invention
[0014] This application develops a system for detecting the quality of injection bottle packaging, designs a bottle cap packaging defect detection algorithm with high accuracy, efficiency and simple operation, and uses MATLAB language to realize the programming requirements of each module of the system. Designed the detection platform, the step-by-step refinement of the injection bottle image, the positioning of the bottle stopper area and the related methods of defect detection, and demonstrated the rationality and feasibility of the packaging defect detection algorithm by measuring and analyzing a large number of injection bottle samples, and realized the real-time detection of whether the bottle stopper and bottle body are well packaged during the production of injection bottles, making up for the current shortcomings of low efficiency and large workload in manual detection, and improving the detection accuracy and production efficiency of the product; this detection method can realize high-speed batch detection of injection bottles, and the detection volume of injection bottles can reach up to 150 per minute. It has a wide range of applications and strong versatility, greatly improving the reliability and speed of detection, and has excellent maintainability.
[0015] In order to achieve the above technical effects, the technical solutions adopted in this application are as follows:
[0016] The fully automatic injection bottle filling and sealing qualified high-speed identification system includes: first, the overall system architecture, which is specifically divided into an array focusing lighting device, a bottle image acquisition device, a filling and sealing identification system, and a high-speed process control system; the array focusing lighting device provides the injection bottle with lighting conditions that meet the image acquisition and identification requirements, and is composed of a row of high-density uniform light arrays; the bottle image acquisition device is composed of a lens, a camera, and image acquisition software; the filling and sealing identification system performs a series of image step-by-step refinement, positioning, and defect identification on the collected initial image, and transmits the results to the monitoring management unit; the high-speed process control system is a control system composed of a computer, a photoelectric sensor, and a bottle knocker, which completes the positioning of the injection bottle on the conveyor belt and the knocking out of the unqualified injection bottle, and the computer records, counts, and displays the detection data in real time; second, the step-by-step refinement and segmentation of the bottle image, specifically including the graying of the bottle image features, the image spatial domain filtering and denoising, the injection bottle image edge enhancement, and the image target area adaptive segmentation, and processes the image details to be highlighted and the parts to be weakened or removed. Suppress and eliminate useless information in the image, simplify the amount of data and highlight the detectability of useful information. First, the collected initial image is grayed and denoised, wherein denoising restores the real information of the image; then the edge information of the image is extracted, and the edge contains the detailed information of the image; then the image is binarized and the target image of interest is segmented; third, adaptive focusing on the bottle stopper area for coarse positioning; fourth, precise positioning of the bottle stopper based on morphological schemes; fifth, injection bottle feature extraction and measurement, specifically including contour feature extraction, measurement of injection bottle target space features, extracting the contour of the injection bottle through the connected code expression method, and obtaining the expression of each eigenvalue characterizing the shape feature of the injection bottle through the obtained connected code sequence for computer decoding and traversal; sixth, injection bottle packaging defect recognition, specifically including defect recognition based on nearest space classification, image registration of defect recognition and improvement of difference operation, and the nearest space classification method is used to detect and identify the packaging defects of the injection bottle; at the same time, image registration and image difference operations are added to further improve the detection accuracy to the expected requirements.
[0017] Preferably, the bottle image is segmented step by step:
[0018] (I) Grayscale of bottle image features
[0019] The three color components are weighted based on the grayscale features of the bottle, so that the pixel value of the grayscale image is their weighted average value, using the formula: GV = R · 0.297 + G · 0.588 + B · 0.120;
[0020] (II) Image Spatial Filtering and Denoising
[0021] Step 1: Determine a window of a certain size, the number of pixels contained in the window is an odd number, and move the window in the image so that the center of the window coincides with a pixel point in the image;
[0022] Step 2: Arrange all pixel values in the window in order from large to small or from small to large;
[0023] Step 3: Find the middle value in this arrangement and use it to replace the pixel value at the center of the window;
[0024] The middle value in the arrangement is obtained instead of the mean of all pixels, so that the edge information of the original image is retained, and the pixel value after filtering is well preserved and is not affected by the noise in the image;
[0025] (III) Image edge enhancement of injection bottle
[0026] First, enhance the edge of the image, take the absolute value to reduce the amount of data calculation, and only take 0 degrees, 45 degrees, 90 degrees, and 135 degrees to perform convolution operations on the image. The specific implementation is:
[0027] Step 1: Set four feature models at 0, 45, 90, and 135 degrees, and perform convolution and sum operations on each pixel in the image with point (i, j) as the center according to these four feature models;
[0028] Step 2: Take the absolute values of the four results obtained in step 1 and compare them with the dynamic critical value respectively. If there is a result equal to or greater than the critical value, the grayscale value of the center point of the feature model is set to the maximum among them, otherwise it is set to 0;
[0029] This application adopts an improved multi-feature model operator and uses a dynamic critical value method to reduce the loss of some edge details during edge detection.
[0030] Preferably, (iv) adaptive segmentation of image target area:
[0031] The injection bottle target area is segmented from the entire image. If R represents the entire image area, then the segmentation of the set R is regarded as decomposing it into N non-empty subsets {R1, R2, …, R N}, image segmentation satisfies the following conditions:
[0032] 1.
[0033] 2. For all i and j, when i≠j, R is satisfied i ∩R j =Φ;
[0034] 3. For i = 1, 2, ..., N, P(Ri )=ture;
[0035] 4. For i≠j, P(R i ∩R j )=false;
[0036] 5. For i = 1, 2, ..., N, R i is a connected region;
[0037] Assuming f(x,y) represents an image, the method of extracting the object from the background is to select a threshold value t and divide the image into two regions. The image g(x,y) after threshold processing is defined as:
[0038]
[0039] In the formula, the pixel marked as 1 is white, corresponding to the object; the pixel marked as 0 is black, corresponding to the background. When the inter-cluster variance between the target and the background is larger, the difference between the two large clusters is larger. The gray value when the inter-cluster variance takes the maximum value can be used as the optimal critical value of the image.
[0040] Assume that the grayscale range of the image is in the range of {0,1,…,L-1}, the total number of image pixels is N, and the number of pixels with grayscale value i is n i Then the probability of the i-th grayscale appearing is:
[0041]
[0042] The critical value T divides the pixels in the image into two groups, namely the target S1 and the background S O , S O S1 corresponds to pixels with grayscale values between [0, T-1], and S2 corresponds to pixels with grayscale values between [T, L-1]. O The probabilities of S0 and S1 are w0 and w1 respectively. O The average grayscale values of S0 and S1 are u0 and u1 respectively, and the total mean of the whole image is u, S O The average variances of the S1 and S2 classes are as follows:
[0043]
[0044] (u0-u1) 2 The larger the cluster variance σ is, the B 2 The larger it is, the better the segmentation effect of the background and the target is. The intra-cluster variance σ w 2 The smaller it is, the better the segmentation effect is;
[0045] set up Then when η(t) takes the maximum value, the corresponding gray level is the optimal critical value Th, that is:
[0046]
[0047] Step 1: Calculate the grayscale probability distribution P(i) of the image, i = 0, 1, ..., L-1;
[0048] Step 2: Calculate S separately O and S1 class probabilities w0, w1, means u0, u1, average variance
[0049] Step 3: Calculate the value of the critical value selection function η(t), t = 0, 1, ..., L-1;
[0050] Step 4: The gray level corresponding to the maximum value of η(t) is the optimal critical value Th;
[0051] Step 5: Adaptively segment the image using this optimal critical value.
[0052] Preferably, the adaptive focusing bottle stopper region is roughly positioned: first, the critical point of the upper edge of the bottle stopper is searched from top to bottom at 1 / 2 of the upper edge of the bottle stopper; if the point cannot be found, move to the right to 3 / 4 of the image to continue searching; if the edge point is still not found, move to the left to 1 / 4 of the image to search; if the upper edge point is found, move downward from this edge point and continue to search for the other two edge critical points of the bottle stopper to the left and right sides respectively;
[0053] If the critical points on the left and right sides are successfully found, the positions of the three edge critical points on the top, left and right of the cork are marked on the initial image, otherwise the process of locating the region of interest is exited; finally, the size of the image region of interest is calculated by the preset extraction height and the coordinates of these three points, and this area is extracted; if the cork area is not detected, reset other appropriate critical values, continue the above operation process, and find the three critical points that meet the requirements.
[0054] Preferably, the precise positioning of the cork based on the morphological scheme: first perform a closing operation on the binary injection bottle image, and then perform an opening operation on it. After the opening operation, the fine edges in the binary image are disconnected and removed, and the boundary of the image is also smoothed, and some small holes are connected; and after the image closing operation, all the holes in the image are expanded. However, for some special bottle images, the opening and closing operations cannot meet the purpose of eliminating all the holes, so it is necessary to add the step of image filling to remove small holes. After the above series of operations, the outline of the cork area is more complete, and the positioning of the cork area will be more accurate.
[0055] Preferably, contour feature extraction:
[0056] 1) Contour connectivity code
[0057] The eight-directional connectivity code is used to express the target boundary of the bottle, where dx(b i ) and dy(b i ) represent the connectivity code a, the offset in the horizontal and vertical coordinates, respectively. Assuming that the coordinates of the contour starting point S are (x, y), and the direction code value of the next boundary point P is 1, the coordinates of point P (x p ,y p ) is expressed as follows:
[0058] x p =x-1,y p =y-1
[0059] 2) Extract the packaging outline of the injection bottle
[0060] The following formula is obtained to express the target contour:
[0061]
[0062] Among them, a i is the direction code value. When extracting the contour of the image, a certain point A is taken as the starting point, and the next point B is obtained through the direction code value of point A. Then the next point can be obtained through the direction code value of point B. In this way, each point of the boundary is continuously searched downward, and finally it returns to the starting point A. The boundary of the injection bottle target is extracted through the eight-directional connectivity code representation method to obtain the boundary of the injection bottle target.
[0063] 3) Polygonal approximation of sealing contour
[0064] Eliminate the influence of local mutation points and burrs of the original contour curve, retain only its main shape features, and approximate the contour of an image through polygons: first select a contour point as the starting point, and then connect the point with several adjacent contour points one by one; then calculate the fitting error between each connecting line and the contour, and when this error is about to exceed a certain limit but has not exceeded it, take this line as a side of the polygon; finally, take the other side of the line segment as the starting point and continue to connect the contour points until returning to the starting point originally selected; the polygonal approximation of the contour is conducive to the subsequent measurement of convex hulls and convex defects. If this operation is not performed, then very small irregular protrusions in the image will be detected as convex defects one by one, increasing the data processing workload.
[0065] Preferably, the measurement of the target spatial features of the injection bottle: characterize the valuable feature information in the injection bottle, select the five features of the shape features, namely, the contour length, the area of the region, the polygon degree of the region, the convex hull and convex defect of the polygon, and the rectangular fitting factor, and give the mathematical calculation expression of the above features through the target boundary connectivity code;
[0066] 1) Outline length of injection bottle
[0067] The contour length is the perimeter of the area surrounded by the image contour. The boundary length of the injection bottle is obtained by calculating the perimeter. The eight-directional connectivity code is used to express the target boundary. The calculation formula for the boundary length of the injection bottle is:
[0068]
[0069] In the formula, n1 represents the total number of all connected codes in the horizontal and vertical directions, and n2 represents the number of connected codes in the diagonal direction;
[0070] 2) Injection bottle area
[0071] The area of the injection bottle describes the size of the area. The number of pixels contained in the area is counted. When the eight-directional connectivity code is used for boundary extraction, the calculation formula of area A is:
[0072]
[0073] Among them, y i =y i-1 +a i2 , y0 is the coordinate of the starting point, a i0 and a i2 are the horizontal and vertical components of the length of the i-th ring of the connected code respectively;
[0074] 3) Area polygon degree
[0075] The polygonal degree of a region is the similarity between the shape of the region and its circumscribed polygon, which is equal to the number of pixels in the region divided by the area of the circumscribed polygon of the region. The calculation formula is:
[0076] R=A / A0
[0077] Where A is the area of the target area, and A0 is the area of the circumscribed polygon of the target area;
[0078] 4) Rectangular fitting factor
[0079] The rectangular fitting factor is the similarity between the target area shape and its minimum enclosing rectangle. It is an important parameter describing the rectangularity of the target. Its calculation formula is:
[0080] R=A / A1
[0081] Where A is the area of the target area, and A1 is the area of the minimum circumscribed rectangle of the target area;
[0082] 5) Polygonal convex hull and convex defects
[0083] The convex hull and convex defects of an object are calculated, and the geometric features of the injection bottle are accurately measured based on the extraction of its boundary using the eight-directional connectivity code.
[0084] Preferably, defect recognition based on nearest space classification: after extracting the feature vector, it is put into a suitable classifier for training, and then the trained model is used to determine which category the target to be tested belongs to. The nearest space method is used to classify and identify the packaging defects of injection bottles. First, the mean vector of each category in the training sample is calculated, and then the mean vector is used as the center position of the category in the multidimensional space. Then, the distance from each pixel in the image to the center of each category is calculated. The pixel belongs to the category with the smallest distance to the category. The classification method is as follows:
[0085] Assume that the packaging defects of injection bottles can be divided into n categories, expressed as the following formula, where p i Indicates a type of defect:
[0086] P=(p1,p2,…,p i ,…p n )
[0087] The standard sample of the i-th class is expressed as:
[0088] M=(m i1 , m i2 ,…,m ij ,…,m iw )
[0089] Among them, m ij Yes i The mean of the jth feature vector of the class image, w represents the number of feature parameters, from m i1 to m iw The vector composed of these w means is called the cluster center of the i-th defect image training sample;
[0090] Assume the feature pattern to be classified is:
[0091] X=(x1,x2,…,x i , …x w )
[0092] The distance from X to a certain class is defined as:
[0093]
[0094] D(f, i) represents the distance between the image to be tested f and the i-th type of sample;
[0095] Five representative features that can characterize image information are selected as the basis for defect recognition. The convex hull and convex defect features are particularly important for the characterization of injection bottle targets. The nearest space classifier is used to identify defective injection bottles. The specific implementation steps are as follows:
[0096] 1) First, select 50 typical images with defects and 50 typical images without defects, calculate the five eigenvalues of each image, and save them as files;
[0097] 2) Calculate the average value of the five features of the two types of images, and obtain M = (m i1 ,m i2 ,…,m i5 );
[0098] 3) Calculate the characteristic value of the image of the defective injection bottle to be tested, and obtain X = (x1, x2, ..., x5);
[0099] 4) Calculate the distance from X to a certain class i
[0100] 5) Identify the type corresponding to the minimum value in D(f,i). If the minimum value corresponds to a type with no package defects, the package is judged to be good. Otherwise, the package is judged to be defective.
[0101] The eigenvalue is equally important for the identification of the nearest space classifier. The eigenvalues in the sample are normalized before classification. The transformation formula is:
[0102]
[0103] In the above formula, x ij * is x ij The normalized value, x ij is the eigenvalue of the jth feature of the ith sample, is the mean value of the jth eigenvalue, s j is its standard deviation, k is the number of samples, and d is the number of features of each sample.
[0104] Preferably, the image registration and difference calculation of defect identification are improved: first, the required registration image is obtained by image registration; then, the registration image and the standard binary injection bottle image are subjected to difference calculation; then, the obtained difference image is subjected to image morphological processing, injection bottle boundary extraction and geometric feature measurement operations in sequence; finally, the packaging defects of the injection bottle are identified by using the nearest space method;
[0105] Image registration allows the image to be inspected and the standard image to be aligned in space. The difference operation subtracts the two images to remove unnecessary information in the image and retain only the part of interest in the image.
[0106] The system first reads in the standard binary injection bottle image and the binary injection bottle image to be inspected, then calls the cpselect function to select key points for the two images, selects 7 registration points to achieve image registration, and saves after the 7 registration points are selected;
[0107] The difference operation is implemented using the imsubstract function, thereby obtaining the difference between the binary image to be tested and the standard binary image;
[0108] When performing the subsequent defect recognition based on the nearest space method, it is only necessary to perform image processing and geometric feature extraction on the obtained differential image to achieve the identification of the defects of the injection bottle.
[0109] Compared with the prior art, the innovations and advantages of this application are:
[0110] First, this application develops a method for detecting the quality of injection bottle packaging, and designs a bottle cap packaging defect detection algorithm with high accuracy, efficiency, simple and effective operation. At the same time, combined with object-oriented programming methods, the MATLAB language is used to implement the programming requirements of each module of the system. The detection platform, the step-by-step refinement and positioning of the injection bottle image, the positioning of the bottle stopper area, and the related methods of defect detection are designed. By measuring and analyzing a large number of injection bottle samples, the rationality and feasibility of the packaging defect detection algorithm are finally demonstrated, and the real-time detection of whether the bottle stopper and bottle body are well packaged during the production process of the injection bottle is realized, which makes up for the current shortcomings of low efficiency and large workload in manual detection, and improves the detection accuracy and production efficiency of the product; this detection method can realize high-speed batch detection of injection bottles, and the detection volume of injection bottles can reach up to 150 per minute. It has a wide range of applications and strong versatility, which greatly improves the reliability and speed of detection;
[0111] Second, the array focusing lighting device of the present application provides the injection bottles with lighting conditions that meet the requirements of image acquisition and identification; the bottle image acquisition device is composed of a lens, a camera and image acquisition software; the filling and sealing identification system performs a series of image refinement, positioning and defect identification on the collected initial image, and transmits the results to the monitoring management unit; the high-speed process control system is a control system composed of a computer, a photoelectric sensor and a bottle knocker, which completes the positioning of the injection bottles on the conveyor belt and the knocking out of unqualified injection bottles, and the computer records, counts and displays the detection data in real time; the software and hardware designs of the system fully consider the reliability of the system, and the hardware design ensures that the various components of the device can work stably for a long time; the software design ensures that the designed algorithm and the written program can accurately detect the injection bottles with packaging defects, and can ensure that the software is of good quality, can run stably for a long time, has a high degree of automation, and has strong practicality;
[0112] Thirdly, the method of step-by-step refinement of injection bottle images and positioning of bottle stopper areas was designed. The image denoising process can minimize the interference of noise introduced by the external environment and photosensitive devices on the real information of the image; the edge enhancement operator can selectively highlight the area of interest and weaken the area of no interest; the binarization process can separate the target from the background, process the image details to be highlighted and the parts to be weakened or removed, suppress and eliminate useless information in the image, simplify the data volume and highlight the detectability of useful information, separate the target image of interest, and improve the detection accuracy and production efficiency of the product;
[0113] Fourth, the coarse positioning of the cork area with adaptive focus and the precise positioning of the cork based on the morphological scheme are proposed, and the feature extraction and measurement method of the injection bottle including the extraction of contour features and the measurement of the target spatial features of the injection bottle is designed. The expression of each characteristic value characterizing the shape features of the injection bottle is obtained through the obtained connected code sequence, which is used for computer decoding and traversal; by obtaining the dynamic response of the three-dimensional depth information orientation of the image, the problem of color distortion of the image caused by unequal acquisition distances due to the fact that the injection bottles are not flat is solved, and the processing speed is improved by parallel algorithms, so as to achieve high-accuracy detection targets and ensure the long-term stability of the system;
[0114] Fifth, a method for detecting defects in the packaging of injection bottles is proposed. The process of detecting defects in the packaging of injection bottles based on the nearest space classification method is to first extract the contour of the injection bottle through the connected code expression method, and then the expression of each characteristic value that characterizes the shape characteristics of the injection bottle can be obtained through the obtained connected code sequence. Then, the nearest space classification method is used to detect and identify the packaging defects of the injection bottle. At the same time, image registration and image difference operations are creatively added. This improvement to the initial scheme improves the accuracy of detection. The false detection rate and missed detection rate of the improved defect detection algorithm are 2% and 0 respectively. When running under ordinary computer hardware configuration conditions, the average detection time is less than 40ms / frame, which greatly improves the speed and accuracy of detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0115] Figure 1 This is a simplified structural diagram of a fully automatic injection bottle filling and sealing qualified high-speed identification system.
[0116] Figure 2 This is a schematic diagram comparing the features of the dosage bottle image before and after grayscale processing.
[0117] Figure 3 It is a comparison chart before and after adaptive segmentation of the target area of the image.
[0118] Figure 4 It is a schematic diagram of the search for the edge critical value of the coarse positioning of the cork area in the adaptive focus.
[0119] Figure 5 It is a schematic diagram of the local effect of coarse positioning of the adaptive focusing cork area.
[0120] Figure 6 It is a flow chart of precise positioning of corks based on morphological scheme.
[0121] Figure 7 This is the effect diagram of the contour connectivity code traversing the boundary.
[0122] Figure 8 It is the measurement effect diagram of the target space characteristics of the injection bottle.
[0123] Fig. 9 This is a schematic diagram of experimental data on defect identification of injection bottle packaging.
[0124] Fig.10 This is a schematic diagram of the inspection results of the injection bottle packaging defect identification experiment.
[0125] Fig.11 This is a graph showing the detection accuracy results under different light source conditions in the experiment.
[0126] Fig.12 It is a flowchart of image registration and difference calculation improvement for defect recognition.
[0127] Fig.13 It is a schematic diagram of the image registration operation for defect recognition.
[0128] Fig.14 This is the experimental result diagram of defect detection based only on the nearest space method in feature matching.
[0129] Fig.15 It is a schematic diagram of the difference operation of defect recognition.
[0130] Fig.16 This is the online detection result diagram after adding image registration and difference operation. DETAILED DESCRIPTION
[0131] The following, in conjunction with the accompanying drawings, further describes the technical solution of the fully automatic injection bottle filling and sealing qualified high-speed identification system provided by the present application, so that technicians in this field can better understand the present application and implement it.
[0132] Taking the application of computer automatic detection technology in bottle cap packaging defect detection as the starting point, an attempt is made to develop a method for detecting the packaging quality of injection bottles, so as to realize real-time detection of whether the bottle cap and bottle body are well packaged during the production process of injection bottles, thereby making up for the current shortcomings of low efficiency and heavy workload in manual inspection, and improving the inspection accuracy and production efficiency of injection bottles.
[0133] This application designs a bottle cap packaging defect detection algorithm with high accuracy, efficiency, simple and effective operation. At the same time, combined with object-oriented programming methods, the MATLAB language is used to implement the programming requirements of each module of the system. The design of the test platform, the step-by-step refinement and positioning of the injection bottle image, the positioning of the bottle stopper area and the related methods of defect detection are designed, and by measuring and analyzing a large number of injection bottle samples, the rationality and feasibility of the packaging defect detection algorithm are finally demonstrated.
[0134] According to the overall performance indicators of the system and the functions to be achieved, the identification system platform was successfully built, which consists of a lighting system, image acquisition equipment and motion devices; the method of step-by-step refinement of the injection bottle image and positioning of the bottle stopper area was designed, in which the image denoising process can minimize the interference of noise introduced by the external environment and photosensitive devices on the real information of the image; the edge enhancement operator can selectively highlight the area of interest and weaken the area of no interest; the binary processing can separate the target from the background, and the method of coarse positioning and fine positioning of the bottle stopper area is proposed, in which the fine positioning is achieved on the basis of digital morphological operators. A method for detecting packaging defects of injection bottles is proposed. The packaging defect detection process of injection bottles based on the nearest space classification method first extracts the contour of the injection bottle through the connected code expression method, and then the expression of each characteristic value that characterizes the shape characteristics of the injection bottle can be obtained through the obtained connected code sequence. Then, the nearest space classification method is used to detect and identify the packaging defects of the injection bottle. At the same time, image registration and image difference operations are added. This improvement to the initial scheme has increased the detection accuracy to the expected detection results.
[0135] 1. System overall architecture
[0136] The overall system architecture is as follows Figure 1 As shown, it is divided into: array focusing lighting device, bottle image acquisition device, filling and sealing identification system, and high-speed process control system.
[0137] The array focusing lighting device provides the injection bottle with lighting conditions that meet the requirements of image acquisition and identification, and is composed of a row of high-density and uniformly illuminated arrays;
[0138] The bottle image acquisition device is composed of a lens, a camera and image acquisition related software;
[0139] The filling and sealing identification system performs a series of image refinement, positioning and defect identification on the collected initial images, and transmits the results to the monitoring management unit.
[0140] The high-speed process control system is a control system composed of computers, photoelectric sensors, and bottle knockers. It completes the positioning of Western medicine injection bottles on the conveyor belt and the knocking out of unqualified injection bottles. The computer records, counts, and displays the detection data in real time.
[0141] Simple structure of the system Figure 1 It can be seen that the system work includes:
[0142] Step 1: Place the injection bottle to be tested at the entrance of the conveyor belt of the production line, and the system allows it to be transported on the conveyor belt at a constant speed;
[0143] Step 2: When the injection bottle is transferred to a specific location, the industrial camera collects images of the injection bottle and transmits the collected image data to the computer;
[0144] Step 3: After the computer receives the image data information, it processes and recognizes the image through a pre-written software program to determine whether the injection bottle is packaged properly and output the test results.
[0145] Step 4: If the identification result is qualified, the injection bottle will enter the next processing step; if the identification result is unqualified, the unqualified information will be passed to the subsequent rejection device to reject the injection bottles that do not meet the requirements.
[0146] 2. Step-by-step segmentation of the bottle image
[0147] The image is refined step by step to process the image details to be highlighted and the parts to be weakened or removed, suppress and eliminate useless information in the image, simplify the data volume and highlight the detectability of useful information.
[0148] First, the collected initial image is grayed and denoised, where denoising restores the real information of the image as much as possible; then the edge information of the image is extracted, and the edge contains the detailed information of the image; then the image is binarized and the target image of interest is segmented.
[0149] (I) Grayscale of bottle image features
[0150] The three color components are weighted based on the grayscale features of the bottle, so that the pixel value of the grayscale image is their weighted average value, using the formula: GV = R 0.297 + G 0.588 + B 0.120, Figure 2 (a) is the initial image captured by the camera. Figure 2 (b) is the image after feature grayscale processing using the weighted average method.
[0151] (II) Image Spatial Filtering and Denoising
[0152] Step 1: Determine a window of a certain size, the number of pixels contained in the window is an odd number, and move the window in the image so that the center of the window coincides with a pixel point in the image;
[0153] Step 2: Arrange all pixel values in the window in order from large to small or from small to large;
[0154] Step 3: Find the middle value in this arrangement and use it to replace the pixel value at the center of the window.
[0155] By finding the middle value in the arrangement instead of the mean of all pixels, the edge information of the original image is retained, and the pixel values after filtering are well preserved and are not affected by the noise in the image.
[0156] (III) Image edge enhancement of injection bottle
[0157] The edge of the injection bottle image concentrates a lot of important information, which is an important basis for later image recognition and understanding. The injection bottle body is transparent, and directly binarizing it can only get the image of the bottle stopper. The bottle mouth is transparent and can be easily regarded as the background. Therefore, the edge of the image is enhanced first, and the absolute value is taken to reduce the amount of data calculation. Only 0, 45, 90, and 135 degrees are used for convolution operation on the image. The specific implementation is as follows:
[0158] Step 1: Set four feature models at 0, 45, 90, and 135 degrees, and perform convolution and sum operations on each pixel in the image with point (i, j) as the center according to these four feature models;
[0159] Step 2: Take the absolute values of the four results obtained in step 1 and compare them with the dynamic critical value respectively. If there is a result equal to or greater than the critical value, the grayscale value of the center point of the feature model is set to the maximum among them, otherwise it is set to 0;
[0160] The ability to suppress noise and the ability to locate edges in edge detection are contradictory, and the choice of edge detection operators directly affects these two abilities. Among them, the Robert operator detects edges through its local difference operator, but because this operator does not smooth the image, its noise suppression effect is not good; the Laplace operator is extremely sensitive to noise and has no way to detect the direction of the edge; the Sobel operator first performs weighted averaging and then differentiates to find the gradient; the Prewitt operator will detect some pseudo edges. This application adopts an improved multi-feature model operator and uses a dynamic critical value method to effectively reduce the loss of some edge details during edge detection.
[0161] (IV) Adaptive segmentation of image target area
[0162] The injection bottle target area is segmented from the entire image. If R represents the entire image area, then the segmentation of the set R is regarded as decomposing it into N non-empty subsets {R1, R2, …, R N}, image segmentation satisfies the following conditions:
[0163] 1.
[0164] 2. For all i and j, when i≠j, R is satisfied i∩R j =Φ;
[0165] 3. For i = 1, 2, ..., N, P(R i )=ture;
[0166] 4. For i≠j, P(R i ∩R j )=false;
[0167] 5. For i = 1, 2, ..., N, R i is a connected region;
[0168] Assuming f(x,y) represents an image, the method of extracting the object from the background is to select a threshold value t and divide the image into two regions. The image g(x,y) after threshold processing is defined as:
[0169]
[0170] In the formula, the pixel marked as 1 is white, corresponding to the object; the pixel marked as 0 is black, corresponding to the background. When the inter-cluster variance between the target and the background is larger, the difference between the two large clusters is larger. The gray value when the inter-cluster variance takes the maximum value can be used as the optimal critical value of the image.
[0171] Assume that the grayscale range of the image is in the range of {0,1,…,L-1}, the total number of image pixels is N, and the number of pixels with grayscale value i is n i Then the probability of the i-th grayscale appearing is:
[0172]
[0173] The critical value T divides the pixels in the image into two groups, namely the target S1 and the background S O , S O S1 corresponds to pixels with grayscale values between [0, T-1], and S2 corresponds to pixels with grayscale values between [T, L-1]. O The probabilities of S0 and S1 are w0 and w1 respectively. O The average grayscale values of S0 and S1 are u0 and u1 respectively, and the total mean of the whole image is u, S O The average variances of the S1 and S2 classes are as follows:
[0174]
[0175] (u0-u1) 2 The larger the cluster variance σ is, the B 2 The larger it is, the better the segmentation effect of the background and the target is. The intra-cluster variance σ w 2The smaller it is, the better the segmentation effect is.
[0176] set up Then when η(t) takes the maximum value, the corresponding gray level is the optimal critical value Th, that is:
[0177]
[0178] Step 1: Calculate the grayscale probability distribution P(i) of the image, i = 0, 1, ..., L-1;
[0179] Step 2: Calculate S separately O and S1 class probabilities w0, w1, means u0, u1, average variance
[0180] Step 3: Calculate the value of the critical value selection function η(t), t = 0, 1, ..., L-1;
[0181] Step 4: The gray level corresponding to the maximum value of η(t) is the optimal critical value Th;
[0182] Step 5: Adaptively segment the image using this optimal critical value.
[0183] The simulation results of the experiment are as follows Figure 3 As shown, the left side is the initial grayscale image of the injection bottle, and the right side is the image obtained by adaptively segmenting the image target area to obtain the optimal critical value after processing.
[0184] 3. Adaptive focusing on the coarse positioning of the cork area
[0185] The body of the injection bottle occupies a large amount of data, which is unnecessary and useless information for defect identification. Therefore, the bottle stopper part of interest is located before feature extraction.
[0186] The cork positioning position of the prior art method is fixed. When the system is unstable, an incomplete cork may be positioned. Therefore, the present application proposes an adaptive focusing cork area coarse positioning method. First, the critical point of the upper edge of the cork is searched from top to bottom at 1 / 2 of the upper edge of the cork. If the point cannot be found, move to the right to 3 / 4 of the image to continue searching. If the edge point is still not found, move to the left to 1 / 4 of the image to search. Figure 4 (a); if the upper edge point is found, then move downward from this edge point and continue to search for the other two edge critical points of the bottle stopper on the left and right sides. The schematic diagram of edge critical point search is shown in Figure 4 (b) as shown.
[0187] If the critical points on the left and right sides are successfully found, the positions of the three edge critical points on the top, left and right of the bottle stopper are marked on the initial image, such as Figure 5 (a) is shown, otherwise the process of locating the region of interest is exited; finally, the size of the image region of interest is calculated by the preset extraction height and the coordinates of the three points, and this area is extracted; if the cork area is not detected, other appropriate critical values are reset, and the above operation process is continued to find the three critical points that meet the requirements.
[0188] 4. Precise positioning of bottle stoppers based on morphological solutions
[0189] After the image is gradually refined and positioned, the outline of the injection bottle can be clearly seen. However, there are some holes and tiny burrs in the injection bottle image obtained by gradual refinement and positioning. The bottle stopper area is connected through closed operation, which is conducive to the precise positioning of the bottle stopper.
[0190] Through analysis, it is found that performing opening or closing operations on the binary injection bottle image alone cannot meet the requirements of the system for image morphological processing. Therefore, in order to make full use of the advantages of both, this application first performs a closing operation on the binary injection bottle image, and then performs an opening operation on it. After the opening operation, the fine edges in the binary image are disconnected and removed, and the boundary of the image is also smoothed, and some small holes are connected; and after the image closing operation, all the holes in the image are expanded, but for some special bottle images, the opening and closing operations cannot meet the purpose of eliminating all holes, so it is necessary to add the image filling step to remove small holes. After the above series of operations, the outline of the bottle stopper area is more complete, and the positioning of the bottle stopper area will be more accurate. Figure 6 is a flowchart of morphological processing.
[0191] 5. Feature extraction and measurement of injection bottles
[0192] Extract the filling and sealing contour boundary of the injection bottle. The computer uses a certain storage method to express the edge of the target in the form of a connectivity code for the computer to decode and traverse.
[0193] (I) Contour feature extraction
[0194] 1) Contour connectivity code
[0195] This application uses eight-directional connectivity codes to express the target boundary of the dosage bottle, where dx(b i ) and dy(b i ) represent the connectivity code a, the offset in the horizontal and vertical coordinates, respectively. Assuming that the coordinates of the contour starting point S are (x, y), and the direction code value of the next boundary point P is 1, the coordinates of point P (x p ,y p ) is expressed as follows:
[0196] x p =x-1,y p =y-1
[0197] 2) Extract the injection bottle package outline
[0198] The following formula is obtained to express the target contour:
[0199]
[0200] Among them, a i is the direction code value. When extracting the contour of the image, a certain point A is taken as the starting point. The direction code value of point A is used to obtain the next point B. Then the direction code value of point B is used to obtain its next point. In this way, each point of the boundary is continuously searched downward, and finally it returns to the starting point A. The target boundary of the injection bottle is extracted by the eight-directional connectivity code representation method, and the Figure 7 The boundaries of the injection bottle object are shown. Figure 7 (a) is the binary image obtained after precise positioning of the cork area. Figure 7 (b) is the image after contour extraction of the binary image using the eight-directional connectivity code method.
[0201] 3) Polygonal approximation of sealing contour
[0202] In actual image sampling, a lot of noise is often introduced due to the influence of the external environment or photosensitive devices, causing the image contour to become less regular than it actually is. In order to eliminate the influence of the local mutation points and burrs of the original contour curve and only retain its main shape features, the contour of an image is approximated by polygons: first select a contour point as the starting point, and then connect the point and several adjacent contour points one by one; then calculate the fitting error between each connecting line and the contour respectively. When this error is about to exceed a certain limit but has not exceeded it, take this line as one side of the polygon; finally, take the other side of the line segment as the starting point and continue to connect the contour points until it returns to the starting point originally selected; the polygonal approximation of the contour is conducive to the subsequent measurement of convex hulls and convex defects. If this operation is not performed, then very small irregular protrusions in the image will be detected as convex defects one by one, increasing the data processing work.
[0203] (II) Measurement of target spatial characteristics of injection bottles
[0204] In order to characterize the valuable feature information in the injection bottle, five features of the shape features, namely contour length, region area, region polygon degree, polygon convex hull and convex defect, and rectangle fitting factor, are selected, and the mathematical calculation expressions of the above features are given through the previous target boundary connectivity code.
[0205] 1) Outline length of injection bottle
[0206] The contour length is the perimeter of the area surrounded by the image contour. The boundary length of the injection bottle is obtained by calculating the perimeter. The eight-directional connectivity code is used to express the target boundary. The calculation formula for the boundary length of the injection bottle is:
[0207]
[0208] Where n1 represents the total number of all connected codes in the horizontal and vertical directions, and n2 represents the number of connected codes in the diagonal direction.
[0209] 2) Injection bottle area
[0210] The area of the injection bottle describes the size of the area. The number of pixels contained in the area is counted. When the eight-directional connectivity code is used for boundary extraction, the calculation formula of area A is:
[0211]
[0212] Among them, y i =y i-1 +a i2 , y0 is the coordinate of the starting point, a i0 and a i2 are the horizontal and vertical components of the length of the i-th ring of the connected code respectively.
[0213] 3) Area polygon degree
[0214] The polygonal degree of a region is the similarity between the shape of the region and its circumscribed polygon, which is equal to the number of pixels in the region divided by the area of the circumscribed polygon of the region. The calculation formula is:
[0215] R=A / A0
[0216] Where A is the area of the target area, and A0 is the area of the circumscribed polygon of the target area.
[0217] 4) Rectangular fitting factor
[0218] The rectangular fitting factor is the similarity between the target area shape and its minimum enclosing rectangle. It is an important parameter describing the rectangularity of the target. Its calculation formula is:
[0219] R=A / A1
[0220] Where A is the area of the target area, and A1 is the area of the minimum circumscribed rectangle of the target area.
[0221] 5) Polygonal convex hull and convex defects
[0222] Calculate the convex hull and convex defects of an object, and accurately measure its geometric features while extracting the boundary of the injection bottle using the eight-directional connectivity code, such as Figure 8 As shown. Among them, Figure 8 The left picture is the image after boundary extraction using the connectivity code representation method. Figure 8 The right picture shows the relevant eigenvalues after measuring its geometric features.
[0223] 6. Identification of packaging defects of injection bottles
[0224] 1. Defect recognition based on nearest space classification
[0225] After the feature vector is extracted, it is put into a suitable classifier for training, and then the trained model is used to determine which category the target to be tested belongs to. The nearest space method is used to classify and identify the packaging defects of injection bottles. First, the mean vector of each category in the training sample is calculated, and then this mean vector is used as the center position of the category in the multidimensional space. Then the distance from each pixel in the image to the center of each category is calculated. The pixel belongs to the category with the smallest distance to the category. The classification method is as follows:
[0226] Assume that the packaging defects of injection bottles can be divided into n categories, expressed as the following formula, where p i Indicates a type of defect:
[0227] P=(p1,p2,…,p i ,…p n )
[0228] The standard sample of the i-th class is expressed as:
[0229] M=(m i1 , m i2 ,…,m ij ,…,m iw )
[0230] Among them, m ij Yes i The mean of the jth feature vector of the class image, w represents the number of feature parameters, from m i1 to m iw The vector composed of these w means is called the cluster center of the i-th defect image training sample;
[0231] Assume the feature pattern to be classified is:
[0232] X=(x1,x2,…,x i , …x w )
[0233] The distance from x to a certain class is defined as:
[0234]
[0235] D(f, i) represents the distance between the image to be tested f and the i-th type of sample.
[0236] Five representative features that can characterize image information are selected as the basis for defect recognition. Among them, the convex hull and convex defect features are particularly important for the characterization of injection bottle targets. The nearest space classifier is used to identify defective injection bottles. The specific implementation steps are as follows:
[0237] 1) First, select 50 typical images with defects and 50 typical images without defects, calculate the five eigenvalues of each image, and save them as files;
[0238] 2) Calculate the average value of the five features of the two types of images, and obtain M = (m i1 , m i2 ,…,m i5 );
[0239] 3) Calculate the characteristic value of the image of the defective injection bottle to be tested, and obtain X=(x1, x2, ..., x5);
[0240] 4) Calculate the distance from X to a certain class i
[0241] 5) Identify which type the minimum value in D(f,i) corresponds to. If this minimum value corresponds to a type of package without defects, the package is judged to be good, otherwise it is judged to be defective.
[0242] Although the magnitude and meaning of each eigenvalue of the image are different and the values vary greatly, these eigenvalues are equally important for the identification of the nearest spatial classifier. The eigenvalues in the sample are normalized before classification. The transformation formula is:
[0243]
[0244] In the above formula, x ij * is x ij The normalized value, x ij is the eigenvalue of the jth feature of the ith sample, is the mean value of the jth eigenvalue, s j is its standard deviation, k is the number of samples, and d is the number of features of each sample.
[0245] (2) Experiment and result analysis
[0246] According to the nearest space method and combined with the actual situation, this application designs a set of injection bottle packaging defect detection and judgment scheme, selects 50 training samples of known categories, and selects 100 images of unknown categories for experiments. The number of samples of each category and the experimental statistical results are as follows: Fig. 9 and Fig.10 shown.
[0247] Depend on Fig.10 It is concluded that the accuracy of identifying packaging defects of injection bottles through the nearest space classifier is still not up to the expected detection target, and the missed detection rate must reach 100% to meet the actual production needs, so the above scheme needs to be improved.
[0248] In the actual production line inspection process, if the light source is not selected properly, it is not conducive to ensuring the accuracy of the inspection. Therefore, it is necessary to find appropriate parameters to adapt to the actual experimental environment. In order to analyze the impact of light sources on computer automatic detection systems, this application conducts experimental research on the images of injection bottles under different light source strengths. The detection accuracy under different light source conditions is as follows: Fig.11 Shown
[0249] from Fig.11 It is concluded that in the injection bottle packaging defect detection system, the intensity of the light source has a great influence on the accuracy of defect classification and recognition. Since the injection bottle is transparent, the brightness of the fixed light source is too high or too low, which will make the outline of the bottle unclear. If the outline of the stopper area is affected, it will directly affect the binarization and morphological processing process, and then affect the final defect recognition result. Therefore, in order to improve the detection accuracy of injection bottle packaging defects, the brightness of the light source should be reasonably controlled when designing the system hardware.
[0250] (II) Improvement of image registration and difference calculation for defect recognition
[0251] The series of step-by-step refinement and positioning of the injection bottle image in the early stage has caused a certain change in the number of pixels contained in the injection bottle itself. The measurement of the feature value is completed under the premise of step-by-step refinement and positioning. The change in the number of pixels contained in the injection bottle itself will have a certain impact on the identification of the injection bottle packaging defect. Therefore, this application improves the injection bottle packaging defect detection method, and its flow chart is as follows: Fig.12 shown.
[0252] In the improved injection bottle defect detection scheme, the required registration image is first obtained through image registration; then, the registration image and the standard binary injection bottle image are subjected to a difference operation; then, the obtained difference image is subjected to image morphological processing, injection bottle boundary extraction and geometric feature measurement operations in sequence; finally, the nearest space method in supervised classification is used to identify the packaging defects of the injection bottle.
[0253] Image registration allows the image to be tested and the standard image to be aligned in space, and the difference operation subtracts the two images to remove unnecessary information in the image and retain only the part of interest in the image.
[0254] The system first reads in the standard binary injection bottle image and the binary injection bottle image to be inspected, and then calls the cpselect function to select key points for the two images and selects 7 registration points to achieve image registration, such as Fig.13 After selecting the 7 registration points, you need to save them.
[0255] The difference operation is implemented using the imsubstract function, thereby obtaining the difference between the binary image to be tested and the standard binary image. Fig.14 As shown in the figure, Figure (a) is a binary image of a well-encapsulated standard injection bottle, and Figure (b) is a binary image of the injection bottle to be tested. After using the difference method to operate them, we get Fig.14 (c) is the difference image shown.
[0256] When performing the subsequent defect recognition based on the nearest space method, it is only necessary to perform image processing and geometric feature extraction on the obtained differential image to realize the identification of the defects of the injection bottle.
[0257] VII. Defect Detection Experiment Results and Analysis
[0258] The defect detection algorithm based on feature matching and the improved defect detection algorithm based on this were designed and implemented, and experiments were conducted on injection bottles with different packaging conditions. In the actual production process, there will be obvious shaking. If the defect is identified only by ordinary feature matching methods, the experimental results will have a large error. The experimental results of defect detection based only on the nearest space method in feature matching are as follows Fig.15 shown.
[0259] from Fig.15 It can be calculated that the false detection rate and missed detection rate of this algorithm are 10% and 7% respectively. Then the defect detection algorithm with added image registration and difference operation is applied to the experiment for online detection, and the following is obtained: Fig.16 The experimental results are shown.
[0260] from Fig.16 It can be seen that the false detection rate and missed detection rate of the improved defect detection algorithm are 0 respectively, which meets the needs of actual production and the detection result requirements to be achieved in this experiment. When running under ordinary computer hardware configuration conditions, the average detection time is less than 40ms / frame.
Claims
1. Fully automatic injection bottle filling and sealing qualified high-speed identification system, characterized by: include: First, the overall system architecture, which is specifically divided into array focusing lighting device, bottle image acquisition device, filling and sealing identification system, and high-speed process control system; The array focusing lighting device provides the injection bottles with lighting conditions that meet the requirements of image acquisition and identification, and is composed of a row of high-density and uniformly illuminated arrays; the bottle image acquisition device is composed of a lens, a camera, and image acquisition software; the filling and sealing identification system performs a series of image refinement, positioning, and defect identification on the collected initial image, and transmits the results to the monitoring management unit; the high-speed process control system is a control system composed of a computer, a photoelectric sensor, and a bottle knocker, which completes the positioning of the injection bottle on the conveyor belt and the knocking out of unqualified injection bottles. The computer records, counts, and displays the detection data in real time; second, the injection bottle image is segmented step by step, with The whole process includes graying of injection bottle image features, image spatial domain filtering and denoising, injection bottle image edge enhancement, and adaptive segmentation of image target areas. The image details to be highlighted and the parts to be weakened or removed are processed to suppress and eliminate useless information in the image, simplify the amount of data and highlight the detectability of useful information. First, the collected initial image is grayed and denoised, wherein denoising restores the real information of the image; then the edge information of the image is extracted, and the edge contains the detailed information of the image; then the image is binarized and the target image of interest is segmented; third, the bottle stopper area is adaptively focused for coarse positioning; fourth, the bottle stopper is precisely positioned based on the morphological scheme; Fifth, injection bottle feature extraction and measurement, specifically including contour feature extraction, measurement of injection bottle target space features, extracting the contour of the injection bottle through the connected code expression method, and obtaining the expression of each characteristic value characterizing the shape characteristics of the injection bottle through the obtained connected code sequence for computer decoding and traversal; Sixth, injection bottle packaging defect identification, specifically including defect identification based on nearest space classification, image registration of defect identification and improvement of difference operation, and using the nearest space classification method to detect and identify the packaging defects of injection bottles; at the same time, adding image registration and image difference operation, further improving the detection accuracy to the expected requirements.
2. According to claim 1, the fully automatic injection bottle filling and sealing qualified high-speed identification system is characterized by: The bottle image is segmented step by step: (I) Grayscale of bottle image features The three color components are weighted based on the grayscale features of the bottle, so that the pixel value of the grayscale image is their weighted average value, using the formula: GV = R · 0.297 + G · 0.588 + B · 0.120; (II) Image Spatial Filtering and Denoising Step 1: Determine a window of a certain size, the number of pixels contained in the window is an odd number, and move the window in the image so that the center of the window coincides with a pixel point in the image; Step 2: Arrange all pixel values in the window in order from large to small or from small to large; Step 3: Find the middle value in this arrangement and use it to replace the pixel value at the center of the window; The middle value in the arrangement is obtained instead of the mean of all pixels, so that the edge information of the original image is retained, and the pixel value after filtering is well preserved and is not affected by the noise in the image; (III) Image edge enhancement of injection bottle First, enhance the edge of the image, take the absolute value to reduce the amount of data calculation, and only take 0 degrees, 45 degrees, 90 degrees, and 135 degrees to perform convolution operations on the image. The specific implementation is: Step 1: Set four feature models at 0, 45, 90, and 135 degrees, and perform convolution and sum operations on each pixel in the image with point (i, j) as the center according to these four feature models; Step 2: Take the absolute values of the four results obtained in step 1 and compare them with the dynamic critical value respectively. If there is a result equal to or greater than the critical value, the grayscale value of the center point of the feature model is set to the maximum among them, otherwise it is set to 0; This application adopts an improved multi-feature model operator and uses a dynamic critical value method to reduce the loss of some edge details during edge detection.
3. According to claim 2, the fully automatic injection bottle filling and sealing qualified high-speed identification system is characterized in that: (IV) Adaptive segmentation of image target area: The injection bottle target area is segmented from the entire image. If R represents the entire image area, then the segmentation of the set R is regarded as decomposing it into N non-empty subsets {R1, R2, …, R N }, image segmentation satisfies the following conditions:
1.
2. For all i and j, when i≠j, R is satisfied i ∩R j =Φ; 3. For i = 1, 2, ..., N, P(R i )=ture; 4. For i≠j, P(R i ∩R j )=false; 5. For i = 1, 2, ..., N, R i is a connected region; Assuming f(x,y) represents an image, the method of extracting the object from the background is to select a threshold value t and divide the image into two regions. The image g(x,y) after threshold processing is defined as: In the formula, the pixel marked as 1 is white, corresponding to the object; the pixel marked as 0 is black, corresponding to the background. When the inter-cluster variance between the target and the background is larger, the difference between the two large clusters is larger. The gray value when the inter-cluster variance takes the maximum value can be used as the optimal critical value of the image. Assume that the grayscale range of the image is in the range of {0,1,…,L-1}, the total number of image pixels is N, and the number of pixels with grayscale value i is n i Then the probability of the i-th grayscale appearing is: The critical value T divides the pixels in the image into two groups, namely the target S1 and the background S O , S O S1 corresponds to pixels with grayscale values between [0, T-1], and S2 corresponds to pixels with grayscale values between [T, L-1]. O The probabilities of S0 and S1 are w0 and w1 respectively. O The average grayscale values of S0 and S1 are u0 and u1 respectively, and the total mean of the whole image is u, S O The average variances of the S1 and S2 classes are as follows: (u0-u1) 2 The larger the cluster variance σ is, the B 2 The larger it is, the better the segmentation effect of the background and the target is. The intra-cluster variance σ w 2 The smaller it is, the better the segmentation effect is; set up Then when η(t) takes the maximum value, the corresponding gray level is the optimal critical value Th, that is: Step 1: Calculate the grayscale probability distribution P(i) of the image, i = 0, 1, ..., L-1; Step 2: Calculate S separately O and S1 class probabilities w0, w1, means u0, u1, average variance Step 3: Calculate the value of the critical value selection function η(t), t = 0, 1, ..., L-1; Step 4: The gray level corresponding to the maximum value of η(t) is the optimal critical value Th; Step 5: Adaptively segment the image using this optimal critical value.
4. According to claim 1, the fully automatic injection bottle filling and sealing qualified high-speed identification system is characterized by: Adaptive focusing bottle cork area coarse positioning: First, search for the critical point of the upper edge of the bottle cork from top to bottom at 1 / 2 of the upper edge of the bottle cork. If the point cannot be found, move to the right to 3 / 4 of the image to continue searching; if the edge point is still not found, move to the left to 1 / 4 of the image to search; if the upper edge point is found, move downward from this edge point and continue to search for the other two edge critical points of the bottle cork to the left and right sides respectively; If the critical points on the left and right sides are successfully found, the positions of the three edge critical points on the top, left and right of the cork are marked on the initial image, otherwise the process of locating the region of interest is exited; finally, the size of the image region of interest is calculated by the preset extraction height and the coordinates of these three points, and this area is extracted; if the cork area is not detected, reset other appropriate critical values, continue the above operation process, and find the three critical points that meet the requirements.
5. According to claim 1, the fully automatic injection bottle filling and sealing qualified high-speed identification system is characterized by: Precise positioning of bottle stoppers based on morphological scheme: first perform a closing operation on the binary injection bottle image, and then perform an opening operation on it. After the opening operation, the fine edges in the binary image are disconnected and removed, and the image boundary is also smoothed, with some small holes connected; and after the image closing operation, all the holes in the image are expanded. However, for some special bottle images, the opening and closing operations cannot meet the purpose of eliminating all holes, so it is necessary to add the step of image filling to remove small holes. After the above series of operations, the outline of the bottle stopper area is more complete, and the positioning of the bottle stopper area will be more accurate.
6. The fully automatic injection bottle filling and sealing qualified high-speed identification system according to claim 1 is characterized in that: Contour feature extraction: 1) Contour connectivity code The eight-directional connectivity code is used to express the target boundary of the bottle, where dx(b i ) and dy(b i ) represent the connectivity code a, the offset in the horizontal and vertical coordinates, respectively. Assuming that the coordinates of the contour starting point S are (x, y), and the direction code value of the next boundary point P is 1, the coordinates of point P (x p ,y p ) is expressed as follows: x p =x-1,y p =y-1 2) Extract the injection bottle package outline The following formula is obtained to express the target contour: Among them, a i is the direction code value. When extracting the contour of the image, a certain point A is taken as the starting point, and the next point B is obtained through the direction code value of point A. Then the next point can be obtained through the direction code value of point B. In this way, each point of the boundary is continuously searched downward, and finally it returns to the starting point A. The boundary of the injection bottle target is extracted through the eight-directional connectivity code representation method to obtain the boundary of the injection bottle target. 3) Polygonal approximation of sealing contour Eliminate the influence of local mutation points and burrs of the original contour curve, retain only its main shape features, and approximate the contour of an image through polygons: first select a contour point as the starting point, and then connect the point with several adjacent contour points one by one; then calculate the fitting error between each connecting line and the contour, and when this error is about to exceed a certain limit but has not exceeded it, take this line as a side of the polygon; finally, take the other side of the line segment as the starting point and continue to connect the contour points until returning to the starting point originally selected; the polygonal approximation of the contour is conducive to the subsequent measurement of convex hulls and convex defects. If this operation is not performed, then very small irregular protrusions in the image will be detected as convex defects one by one, increasing the data processing workload.
7. The fully automatic injection bottle filling and sealing qualified high-speed identification system according to claim 1 is characterized in that: Measurement of target spatial features of injection bottles: Characterize the valuable feature information in injection bottles, select five features from the shape features, namely, contour length, region area, region polygon degree, polygon convex hull and convex defect, and rectangle fitting factor, and give the mathematical calculation expressions of the above features through the target boundary connectivity code; 1) Outline length of injection bottle The contour length is the perimeter of the area surrounded by the image contour. The boundary length of the injection bottle is obtained by calculating the perimeter. The eight-directional connectivity code is used to express the target boundary. The calculation formula for the boundary length of the injection bottle is: In the formula, n1 represents the total number of all connected codes in the horizontal and vertical directions, and n2 represents the number of connected codes in the diagonal direction; 2) Injection bottle area The area of the injection bottle describes the size of the area. The number of pixels contained in the area is counted. When the eight-directional connectivity code is used for boundary extraction, the calculation formula of area A is: Among them, y i =y i-1 +a i2 , y0 is the coordinate of the starting point, a i0 and a i2 are the horizontal and vertical components of the length of the i-th ring of the connected code respectively; 3) Area polygon degree The polygonal degree of a region is the similarity between the shape of the region and its circumscribed polygon, which is equal to the number of pixels in the region divided by the area of the circumscribed polygon of the region. The calculation formula is: R=A / A0 Where A is the area of the target area, A0 is the area of the circumscribed polygon of the target area; 4) Rectangular fitting factor The rectangular fitting factor is the similarity between the target area shape and its minimum enclosing rectangle. It is an important parameter describing the rectangularity of the target. Its calculation formula is: R=A / A1 Where A is the area of the target area, and A1 is the area of the minimum circumscribed rectangle of the target area; 5) Polygonal convex hull and convex defects Calculate the convex hull and convex defects of an object, and accurately measure its geometric features while extracting the boundary of the injection bottle using the eight-directional connectivity code.
8. The fully automatic injection bottle filling and sealing qualified high-speed identification system according to claim 1 is characterized in that: Defect recognition based on nearest space classification: After extracting the feature vector, it is put into a suitable classifier for training, and then the trained model is used to determine which category the target to be tested belongs to. The nearest space method is used to classify and identify the packaging defects of injection bottles. First, the mean vector of each category in the training sample is calculated, and then this mean vector is used as the center position of the category in the multidimensional space. Then the distance from each pixel in the image to the center of each category is calculated. The pixel belongs to the category with the smallest distance to the category. The classification method is as follows: Assume that the packaging defects of injection bottles can be divided into n categories, expressed as the following formula, where p i Indicates a type of defect: P=(p1,p2,…,p i ,…p n ) The standard sample of the i-th class is expressed as: M=(m i1 ,m i2 ,…,m ij ,…,m iw ) Among them, m ij Yes i The mean of the jth feature vector of the class image, w represents the number of feature parameters, from m i1 to m iw The vector composed of these w means is called the cluster center of the i-th defect image training sample; Assume the feature pattern to be classified is: X=(x1,x2,...,x i ,...x w ) The distance from X to a certain class is defined as: D(f, i) represents the distance between the image to be tested f and the i-th type of sample; Five representative features that can characterize image information are selected as the basis for defect recognition. The convex hull and convex defect features are particularly important for the characterization of injection bottle targets. The nearest space classifier is used to identify defective injection bottles. The specific implementation steps are as follows: 1) First, select 50 typical images with defects and 50 typical images without defects, calculate the five eigenvalues of each image, and save them as files; 2) Calculate the average value of the five features of the two types of images, and obtain M = (m i1 , m i2 ,…,m i5 ); 3) Calculate the characteristic value of the image of the defective injection bottle to be tested, and obtain X=(x1, x2, ..., x5); 4) Calculate the distance from X to a certain class i 5) Identify the type corresponding to the minimum value in D(f, i). If the minimum value corresponds to a type of package without defects, the package is judged to be good, otherwise it is judged to be defective. The eigenvalue is equally important for the identification of the nearest spatial classifier. The eigenvalues in the sample are normalized before classification. The transformation formula is: In the above formula, x ij * is x ij The normalized value, x ij is the eigenvalue of the jth feature of the ith sample, is the mean value of the jth eigenvalue, s j is its standard deviation, k is the number of samples, and d is the number of features of each sample.
9. The fully automatic injection bottle filling and sealing qualified high-speed identification system according to claim 1 is characterized in that: Improvement of image registration and difference calculation for defect identification: First, the required registration image is obtained through image registration; then, the registration image and the standard binary injection bottle image are subjected to difference calculation; then, the obtained difference image is subjected to image morphological processing, injection bottle boundary extraction and geometric feature measurement operations in sequence; finally, the nearest space method is used to identify the packaging defects of the injection bottle; Image registration allows the image to be inspected and the standard image to be aligned in space. The difference operation subtracts the two images to remove unnecessary information in the image and retain only the part of interest in the image. The system first reads in the standard binary injection bottle image and the binary injection bottle image to be inspected, then calls the cpselect function to select key points for the two images, selects 7 registration points to achieve image registration, and saves after the 7 registration points are selected; The difference operation is implemented using the imsubstract function, thereby obtaining the difference between the binary image to be tested and the standard binary image; When performing the subsequent defect recognition based on the nearest space method, it is only necessary to perform image processing and geometric feature extraction on the obtained differential image to achieve the identification of the defects of the injection bottle.