# A Study on the Design and Implementation of an Improved AdaBoost Optimization Mathematical Algorithm Based on Recognition of Packaging Bottles

Authors: Guozhu Liu; Sang-Bing Tsai
Journal: Mathematical Problems in Engineering
 (2022)

---

## Abstract

In this paper, a special design system is developed based on the design of the packaging bottle to achieve the effective acquisition of the image of the cross-section of the packaging bottle to be measured under the condition of limited space size, avoiding the distortion of the object to be measured. At the same time, the image of the area where the target packaging bottle is located is segmented, and the curve features are quickly determined and effectively matched with the template library to realize the recognition of the shape features of the bottle. In this paper, the design of the packaging bottle is first designed by mechanism design and 3D modeling, followed by rapid prototyping methods such as 3D printing, and the prototype is made for functional verification. Finally, the transmission speed and stability of the design system for packaging bottle recognition are improved through structural analysis and optimization methods. To realize the intelligent control of the packaging bottle transmission and identification system, the hardware control circuit is designed and the relevant intelligent control program is prepared based on the embedded system so that the packaging bottles in the transmission process can be quickly and accurately positioned and identified. An improved AdaBoost algorithm is proposed for packaging bottle detection. In the process of algorithm learning, the Haar features are too large and time-consuming, and the training sample is cropped to remove the sample edge pixels, which effectively reduces the number of features, thus reducing the computation. The proposed optical flow method is used to obtain the motion region in the video image as the region of interest, and the canny operator is used in the region of interest for edge detection, and the region of interest is filtered by the edge energy to exclude the noninterest region. Finally, the AdaBoost algorithm is used to detect the region of interest, which reduces the detection area and decreases the detection time. The improved AdaBoost algorithm has a high accuracy improvement over the traditional AdaBoost algorithm for the recognition of various packaging bottles with relatively suitable training set samples, and the system recognition time has reached the requirements of industrial recognition.


---

## Body

## 1. Introduction

In recent years, thanks to the rapid progress of the economy, the production and consumption of packaging bottle products have increased year by year, and the packaging bottle products industry has developed rapidly. With the increase of packaging bottle consumption, nondegradable packaging bottle products have become an important source of white pollution, causing damage to the environment while also wasting resources to a certain extent. To alleviate the pollution of the environment, effective measures must be taken to identify the use of waste packaging bottles [1]. Most of the packaging bottles are made of petroleum as raw material, in fact, according to the correct way to refine 1 ton of waste packaging bottles, you can get about 600 kg of fuel, so the packaging bottles contain a lot of renewable resources. Waste packaging bottles are also figuratively called the second oil field. Each ton of packaging bottles identified for use can avoid the generation of about 1.5–2 tons of carbon dioxide emissions. The significance of the identification of waste packaging bottles is extraordinary. It not only brings good economic benefits and promotes resource recycling but is also one of the most effective ways to reduce carbon dioxide emissions [2]. At present, the promotion of the packaging bottle identification device has only just started. The packaging bottle identification system’s function design is not perfect, leading to people accepting that the degree is not high. Most of the packaging bottle identification systems will use infrared scanning barcode results as the basis of discrimination, as the need to identify the bottle has the barcode end of the bottle towards upward delivery and requires the barcode to maintain integrity [3, 4]. The AdaBoost algorithm uses the integral graph to extract features, obtains the classifier through training samples, and selects the best weak classifier as the optimal weak classifier; in the next training, more attention is paid to the misclassified samples, and the optimal weak classifier is selected at the same time. To improve the speed of packaging bottle detection, the strong classifiers with weak to strong detection abilities are cascaded, and the weaker detection ability is made stronger. The classifier can quickly exclude areas that are easily identified as nonpackaged bottles.Based on the research and development of core technologies for packaging bottle identification, sorting, and logistics, a new intelligent packaging bottle identification device has been developed, including key core components such as an integrated and highly reliable packaging bottle logistics and sorting device, a packaging bottle barcode/2D code online identification and weighing device, and a material identification and image recognition system. Firstly, the overall optimization design of the bottle logistics device is carried out, and the double roller rotation method drives the radial rotation of the bottle, avoiding the operational drawback that the bottle side with a barcode must be placed in the identification bin facing upward [5]. Secondly, a set of devices for item acquisition and identification is designed based on a microprocessor, which highly integrates barcode identification, weighing identification, material identification, image identification, and other technologies to improve the identification mechanism and enhance the stability and reliability of the identification device. This paper improves the strong classifier based on the classical AdaBoost algorithm and applies different strong classifiers for different test samples to classify them, from the original single, fixed strong classifier to a dynamic strong classifier that can be changed according to the different test samples [6]. The AdaBoost algorithm is a machine learning method that combines multiple base classifiers according to the weighted error rate, so it has a good effect on classification problems. Because the AdaBoost algorithm has a solid theoretical foundation and high prediction accuracy, it is computationally efficient. It is relatively simple, so it has been widely used.Accurate and timely detection of packaging bottle information from packaging bottle images is an important prerequisite for the application of packaging bottle detection technology in the field of identification. The packaging bottle detection technology is also vulnerable to the influence of external as well as its algorithm itself factors, thus leading to differences in detection results. The algorithms that researchers have been working on often require certain prerequisites to meet the requirements of people. The algorithm in question needs to use a classifier generated by sample training when performing packaging bottle detection. There is no standard training sample pool in the field of packaging bottle detection, so the size, number, and whether the sample set is standard will have some impact on the trained classifier and thus affect the final detection results. This paper analyzes the current packaging bottle detection algorithm and the AdaBoost algorithm and proposes an improved algorithm for the AdaBoost algorithm. Chapter 1 introduces the research content and background significance of this paper, comprehensively points out the problems and challenges faced by the current algorithm and explains the arrangement of all the chapters in this paper. Chapter 2 conducts a study of related work, mainly analyzes the current research status, and points out the differences of this paper’s research. The third chapter is based on the design and implementation research of an improved AdaBoost algorithm for recognizing packaging bottles, which is carried out in three dimensions: construction of packaging bottle recognition model, improved packaging bottle recognition by AdaBoost algorithm, and design and implementation of a packaging bottle recognition system. The improved AdaBoost algorithm is proposed to use the optical flow method to determine the motion region as the region of interest and reduce the detection time. The algorithm is improved in terms of reducing the amount of computation of feature values and optimizing the selection of threshold values. Chapter 4 analyzes the research presented in this paper, conducts experiments using the improved algorithm, and compares the experimental results with other related packaging bottle detection algorithms. Chapter 5 summarizes the work done in this paper, identifies the shortcomings, and provides an outlook on the future development of packaging bottle detection and recognition technology.


## 2. Current Status of Research

The AdaBoost algorithm is a machine learning method that combines multiple base classifiers weighted by error rate, so it has a good effect on classification problems. Since the AdaBoost algorithm has a solid theoretical foundation, high prediction accuracy, and is relatively simple to operate, it has been widely used [7]. Kutsanedzie et al. proposed the combination of the AdaBoost algorithm and SVM, using the SVM algorithm as the base classifier and the embedded multiangle AdaBoost algorithm to classify the group blocks [8]. The empirical analysis shows that the experimental results of this combined algorithm are much better than those of the AdaBoost algorithm [9]. Vanhoeyveld et al. proposed an improved AdaBoost algorithm for multiclassification problems. The boosting algorithm can solve the binary classification problem well, but when dealing with the multiclassification problem, it converts the multiclassification problem into multiple binary classifications for processing, and the exponential loss is large [10]. In this paper, we propose the forward stepwise accumulation model algorithm, which is a direct extension of the AdaBoost algorithm to multiclass cases, to minimize the exponential loss [11]. The main idea of the WB algorithm is that part of the sample is used to train the classification model, and the other part of the sample is used to modify the weights of the model according to the classification results of the model. The results are compared with AdaBoost, Boosting, Bagging, Random Forest, and SVM algorithms using empirical analysis with real data, and the improved WB algorithm is found to be more effective than the other algorithms.Currently available techniques for packaging bottle inspection include feature-based, motion analysis-based, differential-based, and learning-based, among others. Each method has its outstanding aspects. Zhou et al. proposed a projection curve model matching-based method for packaging bottle detection, using projection completeness, the weighted sum of offset expectation, and variance of matching points relative to the model as similarity measures, and using packaging bottle model matching to complete packaging bottle detection [12]. Teng et al. proposed a packaging bottle detection algorithm based on a priori shape information and an active contour model, using color and edge information to remove shadows and extract packaging bottle contour; introducing a priori knowledge of packaging bottle shape, establishing an a priori shape model of packaging bottle with the implicit representation of level set symbols, and constructing an active contour energy construction function with this constraint, using the variational method to find its minimum value, using shape alignment and level set method The segmentation curve of the packaging bottle is evolved to obtain the contour of the packaging bottle and then complete the detection [13]. Divya and Sri proposed a combination of an improved 3D Markov model for bottle detection, using a Markov model combined with a hybrid Gaussian model, followed by Bayesian estimation and an iterative conditional model to complete bottle detection [14]. The improved AdaBoost algorithm, which obtains the binarized mask image by three-frame differencing, finds the connected domain, reconstructs the foreground mask map after denoising, and loads the classifier to detect the image to be inspected, effectively improving the detection efficiency of the algorithm [15]. The improved AdaBoost algorithm combined with the region of interest uses a hybrid Gaussian model to extract the region of interest from the image to be examined and then uses the AdaBoost algorithm to detect it, which greatly reduces the detection time of the algorithm.When the AdaBoost algorithm performs the contour detection of the packaging bottle, it needs to use the sample training generated classifier. There is currently no standard training sample library in the field of packaging bottle contour detection. Therefore, the size, number, and standard of the sample set will have a certain impact on the trained classifier, thereby affecting the final detection result. The intelligent bottle identification part mainly refers to the bottle logistics device and works through the logistics device to achieve the axial transfer and rotation of bottles and other actions. According to the design requirements, based on the existing mature technology, using the mechanical design optimization method, the logistics device is developed for this project, which is integrated with the packaging bottle identification system, and the workflow of the logistics device is optimized so that it has fast and efficient, stable and reliable performance. Due to a variety of factors, the quality of the packaging bottle image will be degraded. Therefore, before the packaging bottle detection, this paper first introduces image preprocessing. For the problem that the image is too bright or too dark, the packaging bottle image is enhanced using histogram equalization; there is more or less noise in the image, and different filtering methods are used for different noises. This paper focuses on the detection of packaging bottles based on the AdaBoost algorithm [16, 17]. We classify the test sample set by the clustering method in advance. Then find the closest sample group for each test set sample, and calculate the similarity between them. According to each base classifier, the error rate of each sample group classification is given its corresponding weight. Combined with the similarity between the test sample and each group, the weighted combination constitutes the final dynamic strong classifier.


## 3. Design and Implementation of Packaging Bottle Recognition Based on Improved AdaBoost Algorithm

### 3.1. Package Bottle Identification Model Construction

The barcode scanner transmits the scanning information to the main controller, and the main controller stores the information temporarily, but it is not used as the basis for controlling the movement mechanism; the material recognition sensor transmits the material information to the main controller, and the main controller stores the information temporarily, and compares it with the database in the background server, and feeds the comparison result to the main controller, and uses it as the basis for controlling the main controller; the pressure sensor transmits the weighing information to the main controller, and the main controller stores the information temporarily [18]. After taking the image of the packaging bottle, the image is processed by the image recognition algorithm, obtains the image outline, and passes it to the main controller. Temporarily stores image outline in the main controller, and the main controller then compares it with the database in the backend server by comparing it with the main controller then compares with the database in the backend server and feeds the comparison result to the main controller as the control basis of the main control. The control flow chart of the packaging bottle recognition model is shown in Figure 1. The pressure sensor required by the intelligent recycling device for plastic packaging bottles is mainly used for weighing and detecting whether there is too much residual liquid in the plastic bottles, and feeding back the detection results to the main controller, which compares the detection results with the preset weight value, recycle or return plastic bottles.Figure 1
. Bottle identification model.The material recognition sensor of the intelligent identification device is mainly used to distinguish the packaging bottles and cans, and the result of the recognition is fed back to the main controller for the sorting and recognition of the packaging bottles and cans. The data is uploaded at the same time, so the metal sensor with reliable performance is selected to meet the requirements. The selected material identification sensor is an inductive proximity sensor whose output is in the form of an NPN normally open. It is normally even in the normal state, and when the object is detected, the signal line outputs a negative voltage signal. The inductive proximity switch consists of a high-frequency oscillator, an amplifier circuit, and a switching circuit, and the material of the detected object must be metal [19, 20]. The high-frequency oscillator forms an electromagnetic field on the detection surface. When a metallic object reaches the induction area, the electromagnetic field causes an eddy current effect inside the metallic object, which absorbs the oscillator energy and makes the oscillator damp or even stop. The transformation of these two different states is converted by the postcircuit into a change of electrical signal in the internal circuit, which is then converted into a binary switching signal and finally amplified by the amplifier circuit and output.When acquiring the ADC return value, we set the ruling group channel 5 of the specified ADC1 with a sampling time of 480 cycles. To obtain the value more accurately, the conversion value of channel 5 is obtained 100 times, and then the average value of the sampling is taken as the final ADC channel sampling value. According to the actual measurement of the pressure sensor, it was found that the voltage reading of the pressure sensor without the measured object was about 160 millivolts, and when the measured object was present, every 10 millivolts corresponded to about 2 grams of the bottle weight. Finally, the real weight of the acquired bottle is compared with the threshold value of 80 grams for bottles that are overweight to determine whether the packaging bottle is identified. When describing the characteristics of packaging bottles, different types of Haar features are selected, and the number of Haar features obtained is different; the size of packaging bottles is different, and the number of Haar features required is also different. For a 150∗ 150 bottle, there are more than 100,000 diagonal features and many more linear features. If the common Haar feature is used to describe the packaging bottle, about 800,000 features are required, that is, more than 800,000 calculations are required to obtain the feature value, and such a large amount of calculation greatly affects the speed of detection.Image noise can be generated from external or internal sources. Most of the noise in images is random, and we usually use neighborhood averaging and median filtering to attenuate or eliminate the noise. Median filtering, as a nonlinear method to remove noise, can overcome the problem of blurred image details brought about by linear averaging filters. The principle is first to reorder the pixels in the neighborhood according to their gray value magnitude, and then to select the middle value of this ordered sequence as the output pixel value. The median is defined as a set of numbersx1, x2, x3,..., xn assuming their ordering as in the following equation:(1)Yx=∑i=n+2/2xi∗2,n⊆1,3,5……,∑i=n+2/2xi∗2+∑i=n/2xi∗22,n⊆2,4,6…….Y is called the median of x1, x2, x3... the median of xn, and the domain of a point of a particular length or shape is called a window. Let the input be {xi}, then the filter output in one dimension is expressed as follows:(2)Yxi=yxi=minyxi−a,xi,xi+a,yxi−b,xi,xi+b.The original image of the packaging bottle is obtained, and to improve the processing speed of the microprocessor, a large amount of color information contained in the image must be removed, and it is most appropriate to do the grayscale processing of the image by using the weighted average method. In the actual algorithm application, the three components of each point pixel are weighted with different weights for the weighted average. At the same time, the floating-point operation is turned into an integer operation, and the three components of blue, green, and red are multiplied by 512, 1024, and 256, respectively, and after accumulation, the integer is divided by 10000 to speed up the operation and grayscale as in the following equation:(3)ym,n=512Rm,n+1024Gm,n+256Bm,n10000.


### 3.2. AdaBoost Algorithm to Improve Packaging Bottle Recognition

Due to the complex background in the image of the packaging bottle contour detection process, nontarget moving objects are also counted as targets to be detected in the ROI region, which to a certain extent will generate the possibility of false detection. Therefore, before and after the detection of the region of interest by the AdaBoost algorithm, the motion region and the detection results are filtered to remove the regions of interest that are smaller before detection and the targets whose size and contour do not match the packaging bottle after detection according to a certain aspect ratio and the area size of the region of interest. The principle of the AdaBoost algorithm is to use nonlinear transformation to place the target space vector in the high-dimensional space and then generate the optimal classification plane in the new high-dimensional space to increase the interclass distance of samples of different categories.Training is performed after cropping the training samples, which greatly reduces the training time while there is no significant decrease in accuracy [20]. The motion regions in the video images were acquired using the optical flow method, and the smallest outer rectangle of motion pixel points belonging to the same motion region was used as the region of interest, the region to be examined by the improved algorithm. The training samples were cropped to remove 1 to 2 pixels from the edges of the samples. N best weak classifiers are obtained after N iterations h(x1), h(x2)...h(xn), which form the strong classifier according to the following equation:(4)fx=∑i=1Nai∗hxi.Due to the sharp angles of the packaging bottle contour, it is very favorable for edge detection. Using edge detection for the region of interest, the contour information of the region of interest is obtained, and again, a large number of noninteresting regions can be excluded. Using Gaussian smoothing filter convolution noise reduction, the gradient amplitude and direction are calculated as in the following equation:(5)M=23125154962.The weight of each base classifier for each group is calculated by the error rate, where the error rate is the percentage of the number of wrongly classified samples to the total number of samples. The overall error rate we represent by the matrixJ (m ∗ n) is shown in equation (6). Where m ∗ n denotes the error rate of the m-th base classifier for the n-th group classification [21].(6)Jm∗n=m11m12m1nm21m22m2nmn1mn1mnn.The weightw (n, i) of the n-th sample group to the i-th base classifier in the training sample can be calculated by equation (6), as shown in the following equation:(7)wn,i=ln1−mni/mni2.By calculating the Euclidean distance between the test sample and the center of each training sample group {x1, x2……xm}, the inverse of which is the corresponding similarity. xim is the s-th attribute value of the centroid of the i-th sample group, xjm is the s-th attribute value of the j-th test sample, d(m, n) is the distance from the m-th sample to the n-th sample group, and h(m, n) is the similarity between the m-th sample and the n-th sample group [21].(8)dm,n=∑i=1mxim−xin2+∑j=1nxjm−xjn2,hm,n=1dm,n.If a classifier is good at classifying a certain class of sample sets, then the classifier will also be good at classifying samples similar to such sample sets. We classify the test sample set by the clustering method beforehand, and then find the most similar sample groups in each test set and calculate the similarity between them. The base classifier is assigned a corresponding weight according to the error rate of each sample group, and when combined with the similarity of the test samples to each group, the weighted combination forms the final dynamic strong classifier. The final weight wmn of the m-th test sample corresponding to the n-th base classifier can be obtained by the following equation:(9)wmn=∑k=1Nhm,k∗wn,k.The final dynamic strong classifier is obtained by weighting and combining multiple base classifiers.(10)Gx=max0,∑i=1Nwmi∗hxi,1.Since the overall mean is unknown, we use the sample mean to estimate the overall mean. That is, in the test process, the difference between the sample means of the two-overall means is used to estimate the difference between the means of the two-overall means. If the two overall distributions obey a normal distribution, then(11)zx,y=x−y∑i=1NSxi−Syi2According to thez(x, y)-value table, the z(x, y)-values corresponding to the degree of freedom n-1 were found and compared with the calculated z(x, y)-values to determine whether the results were significant according to Table 1.Table 1
.z (x, y)-value and significance relationship table.
Serial numberz (x, y)-valueS ValueSignificance levelSignificant difference1z (x, y) < 0S < 0.050.05The difference is very significant2z (x, y) = 0S = 0.050.08Significant difference3z (x, y) > 0S > 0.051.00No obvious difference


### 3.3. Design and Implementation of Packaging Bottle Identification System

The main function of the intelligent packaging bottle identification system is to identify the packaging bottle material, barcode information, weight, and the outline of the packaging bottle shape, to discern whether to identify the packaging bottle and at the same time provide the rebate basis by matching the comparison with the template in the backend server database. Now some intelligent packaging bottle recognition systems on the market to packaging bottle recognition, the function is refuted and not practical, resulting in human-computer interaction interface operation is too complex, does not meet the user operation convenient function demand. Therefore, simple operation and practical function are the main principles of this system design. Intelligent packaging bottle identification systems are mostly put in public areas with a large flow of people, and long-term unattended states. The Haar rectangular feature extracted by the AdaBoost algorithm is relatively simple, and it is easy to cause false detection and missed detection for nontarget interference and occlusion. At the same time, the adaptability of the AdaBoost algorithm is poor for bottles with different angles. At the same time, for the detection of the entire packaging bottle, the AdaBoost algorithm needs to use the sliding window to search and detect, including a large amount of useless information, which has a great impact on the speed of the algorithm.The intelligent packaging bottle identification system embedded system adopts the modular design concept to simplify the design steps and make the design ideas clearer. According to the different functions of the system for modular design, including human-computer interaction module, machine control module, and intelligent identification module, there are three major parts. The human-machine interaction module is mainly realized by a touch-type all-in-one machine. The user can operate the all-in-one machine to complete the bottle-throwing. At the same time, the background staff can also view and understand the working status of the intelligent packaging bottle identification system; the motor control module includes the control of the motor and its driver, photoelectric switch, limit switch, and other related sensors; the identification module includes the barcode scanner for barcode identification and the metal sensor for material identification. The main controller identifies the input bottles by controlling each sensor and feeds the identification results back to the main controller for data interaction. The general design scheme of the system is shown in Figure2.Figure 2
. System functional framework diagram.The design divides the image recognition system into four parts according to the different functions, namely, an image acquisition module, an image recognition module, an image storage module, and an image display module. The working process of each functional module is as follows: the image acquisition module is mainly to complete the acquisition of image data through the image sensor device and provide the image data to the microprocessor for recognition processing; the image recognition module is for the microprocessor to recognize and process the acquired image data through the image recognition algorithm and output the recognition result; the image storage module is to cache the image data processed by the image recognition module. The image storage module caches the image data processed by the image recognition module and prepares it for transmission to the image display module; the image display module mainly displays the results of the image data after recognition processing, and the microprocessor then makes the recognition judgment.


## 3.1. Package Bottle Identification Model Construction

The barcode scanner transmits the scanning information to the main controller, and the main controller stores the information temporarily, but it is not used as the basis for controlling the movement mechanism; the material recognition sensor transmits the material information to the main controller, and the main controller stores the information temporarily, and compares it with the database in the background server, and feeds the comparison result to the main controller, and uses it as the basis for controlling the main controller; the pressure sensor transmits the weighing information to the main controller, and the main controller stores the information temporarily [18]. After taking the image of the packaging bottle, the image is processed by the image recognition algorithm, obtains the image outline, and passes it to the main controller. Temporarily stores image outline in the main controller, and the main controller then compares it with the database in the backend server by comparing it with the main controller then compares with the database in the backend server and feeds the comparison result to the main controller as the control basis of the main control. The control flow chart of the packaging bottle recognition model is shown in Figure 1. The pressure sensor required by the intelligent recycling device for plastic packaging bottles is mainly used for weighing and detecting whether there is too much residual liquid in the plastic bottles, and feeding back the detection results to the main controller, which compares the detection results with the preset weight value, recycle or return plastic bottles.Figure 1
. Bottle identification model.The material recognition sensor of the intelligent identification device is mainly used to distinguish the packaging bottles and cans, and the result of the recognition is fed back to the main controller for the sorting and recognition of the packaging bottles and cans. The data is uploaded at the same time, so the metal sensor with reliable performance is selected to meet the requirements. The selected material identification sensor is an inductive proximity sensor whose output is in the form of an NPN normally open. It is normally even in the normal state, and when the object is detected, the signal line outputs a negative voltage signal. The inductive proximity switch consists of a high-frequency oscillator, an amplifier circuit, and a switching circuit, and the material of the detected object must be metal [19, 20]. The high-frequency oscillator forms an electromagnetic field on the detection surface. When a metallic object reaches the induction area, the electromagnetic field causes an eddy current effect inside the metallic object, which absorbs the oscillator energy and makes the oscillator damp or even stop. The transformation of these two different states is converted by the postcircuit into a change of electrical signal in the internal circuit, which is then converted into a binary switching signal and finally amplified by the amplifier circuit and output.When acquiring the ADC return value, we set the ruling group channel 5 of the specified ADC1 with a sampling time of 480 cycles. To obtain the value more accurately, the conversion value of channel 5 is obtained 100 times, and then the average value of the sampling is taken as the final ADC channel sampling value. According to the actual measurement of the pressure sensor, it was found that the voltage reading of the pressure sensor without the measured object was about 160 millivolts, and when the measured object was present, every 10 millivolts corresponded to about 2 grams of the bottle weight. Finally, the real weight of the acquired bottle is compared with the threshold value of 80 grams for bottles that are overweight to determine whether the packaging bottle is identified. When describing the characteristics of packaging bottles, different types of Haar features are selected, and the number of Haar features obtained is different; the size of packaging bottles is different, and the number of Haar features required is also different. For a 150∗ 150 bottle, there are more than 100,000 diagonal features and many more linear features. If the common Haar feature is used to describe the packaging bottle, about 800,000 features are required, that is, more than 800,000 calculations are required to obtain the feature value, and such a large amount of calculation greatly affects the speed of detection.Image noise can be generated from external or internal sources. Most of the noise in images is random, and we usually use neighborhood averaging and median filtering to attenuate or eliminate the noise. Median filtering, as a nonlinear method to remove noise, can overcome the problem of blurred image details brought about by linear averaging filters. The principle is first to reorder the pixels in the neighborhood according to their gray value magnitude, and then to select the middle value of this ordered sequence as the output pixel value. The median is defined as a set of numbersx1, x2, x3,..., xn assuming their ordering as in the following equation:(1)Yx=∑i=n+2/2xi∗2,n⊆1,3,5……,∑i=n+2/2xi∗2+∑i=n/2xi∗22,n⊆2,4,6…….Y is called the median of x1, x2, x3... the median of xn, and the domain of a point of a particular length or shape is called a window. Let the input be {xi}, then the filter output in one dimension is expressed as follows:(2)Yxi=yxi=minyxi−a,xi,xi+a,yxi−b,xi,xi+b.The original image of the packaging bottle is obtained, and to improve the processing speed of the microprocessor, a large amount of color information contained in the image must be removed, and it is most appropriate to do the grayscale processing of the image by using the weighted average method. In the actual algorithm application, the three components of each point pixel are weighted with different weights for the weighted average. At the same time, the floating-point operation is turned into an integer operation, and the three components of blue, green, and red are multiplied by 512, 1024, and 256, respectively, and after accumulation, the integer is divided by 10000 to speed up the operation and grayscale as in the following equation:(3)ym,n=512Rm,n+1024Gm,n+256Bm,n10000.


## 3.2. AdaBoost Algorithm to Improve Packaging Bottle Recognition

Due to the complex background in the image of the packaging bottle contour detection process, nontarget moving objects are also counted as targets to be detected in the ROI region, which to a certain extent will generate the possibility of false detection. Therefore, before and after the detection of the region of interest by the AdaBoost algorithm, the motion region and the detection results are filtered to remove the regions of interest that are smaller before detection and the targets whose size and contour do not match the packaging bottle after detection according to a certain aspect ratio and the area size of the region of interest. The principle of the AdaBoost algorithm is to use nonlinear transformation to place the target space vector in the high-dimensional space and then generate the optimal classification plane in the new high-dimensional space to increase the interclass distance of samples of different categories.Training is performed after cropping the training samples, which greatly reduces the training time while there is no significant decrease in accuracy [20]. The motion regions in the video images were acquired using the optical flow method, and the smallest outer rectangle of motion pixel points belonging to the same motion region was used as the region of interest, the region to be examined by the improved algorithm. The training samples were cropped to remove 1 to 2 pixels from the edges of the samples. N best weak classifiers are obtained after N iterations h(x1), h(x2)...h(xn), which form the strong classifier according to the following equation:(4)fx=∑i=1Nai∗hxi.Due to the sharp angles of the packaging bottle contour, it is very favorable for edge detection. Using edge detection for the region of interest, the contour information of the region of interest is obtained, and again, a large number of noninteresting regions can be excluded. Using Gaussian smoothing filter convolution noise reduction, the gradient amplitude and direction are calculated as in the following equation:(5)M=23125154962.The weight of each base classifier for each group is calculated by the error rate, where the error rate is the percentage of the number of wrongly classified samples to the total number of samples. The overall error rate we represent by the matrixJ (m ∗ n) is shown in equation (6). Where m ∗ n denotes the error rate of the m-th base classifier for the n-th group classification [21].(6)Jm∗n=m11m12m1nm21m22m2nmn1mn1mnn.The weightw (n, i) of the n-th sample group to the i-th base classifier in the training sample can be calculated by equation (6), as shown in the following equation:(7)wn,i=ln1−mni/mni2.By calculating the Euclidean distance between the test sample and the center of each training sample group {x1, x2……xm}, the inverse of which is the corresponding similarity. xim is the s-th attribute value of the centroid of the i-th sample group, xjm is the s-th attribute value of the j-th test sample, d(m, n) is the distance from the m-th sample to the n-th sample group, and h(m, n) is the similarity between the m-th sample and the n-th sample group [21].(8)dm,n=∑i=1mxim−xin2+∑j=1nxjm−xjn2,hm,n=1dm,n.If a classifier is good at classifying a certain class of sample sets, then the classifier will also be good at classifying samples similar to such sample sets. We classify the test sample set by the clustering method beforehand, and then find the most similar sample groups in each test set and calculate the similarity between them. The base classifier is assigned a corresponding weight according to the error rate of each sample group, and when combined with the similarity of the test samples to each group, the weighted combination forms the final dynamic strong classifier. The final weight wmn of the m-th test sample corresponding to the n-th base classifier can be obtained by the following equation:(9)wmn=∑k=1Nhm,k∗wn,k.The final dynamic strong classifier is obtained by weighting and combining multiple base classifiers.(10)Gx=max0,∑i=1Nwmi∗hxi,1.Since the overall mean is unknown, we use the sample mean to estimate the overall mean. That is, in the test process, the difference between the sample means of the two-overall means is used to estimate the difference between the means of the two-overall means. If the two overall distributions obey a normal distribution, then(11)zx,y=x−y∑i=1NSxi−Syi2According to thez(x, y)-value table, the z(x, y)-values corresponding to the degree of freedom n-1 were found and compared with the calculated z(x, y)-values to determine whether the results were significant according to Table 1.Table 1
.z (x, y)-value and significance relationship table.
Serial numberz (x, y)-valueS ValueSignificance levelSignificant difference1z (x, y) < 0S < 0.050.05The difference is very significant2z (x, y) = 0S = 0.050.08Significant difference3z (x, y) > 0S > 0.051.00No obvious difference


## 3.3. Design and Implementation of Packaging Bottle Identification System

The main function of the intelligent packaging bottle identification system is to identify the packaging bottle material, barcode information, weight, and the outline of the packaging bottle shape, to discern whether to identify the packaging bottle and at the same time provide the rebate basis by matching the comparison with the template in the backend server database. Now some intelligent packaging bottle recognition systems on the market to packaging bottle recognition, the function is refuted and not practical, resulting in human-computer interaction interface operation is too complex, does not meet the user operation convenient function demand. Therefore, simple operation and practical function are the main principles of this system design. Intelligent packaging bottle identification systems are mostly put in public areas with a large flow of people, and long-term unattended states. The Haar rectangular feature extracted by the AdaBoost algorithm is relatively simple, and it is easy to cause false detection and missed detection for nontarget interference and occlusion. At the same time, the adaptability of the AdaBoost algorithm is poor for bottles with different angles. At the same time, for the detection of the entire packaging bottle, the AdaBoost algorithm needs to use the sliding window to search and detect, including a large amount of useless information, which has a great impact on the speed of the algorithm.The intelligent packaging bottle identification system embedded system adopts the modular design concept to simplify the design steps and make the design ideas clearer. According to the different functions of the system for modular design, including human-computer interaction module, machine control module, and intelligent identification module, there are three major parts. The human-machine interaction module is mainly realized by a touch-type all-in-one machine. The user can operate the all-in-one machine to complete the bottle-throwing. At the same time, the background staff can also view and understand the working status of the intelligent packaging bottle identification system; the motor control module includes the control of the motor and its driver, photoelectric switch, limit switch, and other related sensors; the identification module includes the barcode scanner for barcode identification and the metal sensor for material identification. The main controller identifies the input bottles by controlling each sensor and feeds the identification results back to the main controller for data interaction. The general design scheme of the system is shown in Figure2.Figure 2
. System functional framework diagram.The design divides the image recognition system into four parts according to the different functions, namely, an image acquisition module, an image recognition module, an image storage module, and an image display module. The working process of each functional module is as follows: the image acquisition module is mainly to complete the acquisition of image data through the image sensor device and provide the image data to the microprocessor for recognition processing; the image recognition module is for the microprocessor to recognize and process the acquired image data through the image recognition algorithm and output the recognition result; the image storage module is to cache the image data processed by the image recognition module. The image storage module caches the image data processed by the image recognition module and prepares it for transmission to the image display module; the image display module mainly displays the results of the image data after recognition processing, and the microprocessor then makes the recognition judgment.


## 4. Analysis of Results

### 4.1. Packaging Bottle Identification Model Simulation Analysis

Two photos were randomly selected from each of the packaging bottles in the database for training, and the other eight were used for recognition. Three algorithms were used for packaging bottle recognition, and the recognition rate was calculated. In the second experiment, 3 photos of each person in the data were randomly selected for training, and the other 7 were used for recognition. And so on, in the next 6 experiments, the photos of packaging bottles in the training set were gradually added 1 until the number of photos was 9. The recognition rate of the 3 recognition models for each experiment was counted as shown in Figure3.Figure 3
. The recognition rate of three recognition models.800 single-package bottle images and 500 multipackage bottle images were randomly selected, and they were detected using two recognition models, and then the results were simulated and analyzed. The simulation results are shown in Figure4. For both algorithms, the detection rate of multipack bottles is lower than that of single-pack bottles, and the false detection rate of multipack bottles is higher than that of single-pack bottles. Because the background of multipack bottles is relatively more complex, the posture of the bottles is also varied, and the bottles may be missed if the face of the bottles is partially obscured, these factors lead to a lower detection performance of multipack bottles than that of single-pack bottles (see Figure 4).Figure 4
. Identification model simulation results. (a) Traditional AdaBoost algorithm. (b) Improved AdaBoost algorithm.
(a)(b)


### 4.2. Performance Analysis of Packaging Bottle Recognition Algorithm

From Figure5, it can be seen that the differential method is affected by the shadow of the packaging bottle itself in the static background, causing false detection and missed detection. In this paper, the algorithm has a leakage phenomenon for the contour detection of the packaging bottle. The reason is that in the training stage of the algorithm, the front face image of the positive sample bottle is mainly selected from common household bottles, and the algorithm cannot detect the special bottle contour very well (see Figure 5).Figure 5
. Single background test results.From Figure6, it can be seen that the AdaBoost algorithm has a high false detection rate for packaging bottle contour detection in a complex background, which is more easily affected by the background. The algorithm in this paper shows better stability in this complex background. The experimental results show that the differential and traditional AdaBoost algorithms in the detection process will wrongly detect other motion targets in the complex background, resulting in false detection. The improved algorithm effectively removes the false targets after extracting the ROI and screening the ROI. Compared with the differential method and the traditional AdaBoost algorithm, the improved algorithm has a certain improvement in accuracy and a significant reduction in the false detection and missed detection rates (see Figure 6).Figure 6
. Complex background detection results.


### 4.3. Packaging Bottle Identification System Actual Test Analysis

In terms of recognition accuracy, Figure7 shows the relationship between the recognition accuracy and the number of training rounds of the traditional AdaBoost and the improved AdaBoost algorithms, and the experimental system is the packaging bottle recognition system designed in this paper. From Figure 7, we can see that the accuracy of both algorithms improves as the number of training rounds increases, but the improvement of this algorithm is more obvious with the same number of training rounds. Initially, the difference in accuracy between the two algorithms is about 4%, and the peak is reached at about 120 rounds, when the difference in accuracy between the two algorithms reaches 8%, after which the accuracy of the two algorithms stabilizes. The accuracy of the improved AdaBoost algorithm reaches 92.86%, which is about 9% higher than that of the traditional AdaBoost algorithm, and the practicality is improved (see Figure 7).Figure 7
. System recognition accuracy rate.The purpose of the significance test in this paper is to verify whether the difference between the classification effect of the improved AdaBoost algorithm before and after is significant. The significance test was performed using the SPSS software, and the results are shown in Figure8.Figure 8
. Results of the systematic significance test: (a) sample 1 and (b) sample 2.
(a)(b)From the significance test of the error rate of sample 1 in Figure8, it can be seen that the variances of the two samples are not equal, and at the significance level of 5.2%, 0.0 < p < 0.5, indicating that there is a significant difference between the means of the two samples before and after the improvement of sample 1. From the significance test of the error rate of sample 2 in Figure 8, it is clear that the variances of the two samples are not equal, and at the significance level of 4.1%, 0.5 < p < 0.7, indicating that there is a significant difference between the two sample means before and after the improvement of sample 2. In summary, there is a significant difference in the mean values of error rates derived from the AdaBoost algorithm before and after the improvement, that is, the difference in the classification effect of the AdaBoost algorithm before and after the improvement is significant and the improvement is meaningful.


## 4.1. Packaging Bottle Identification Model Simulation Analysis

Two photos were randomly selected from each of the packaging bottles in the database for training, and the other eight were used for recognition. Three algorithms were used for packaging bottle recognition, and the recognition rate was calculated. In the second experiment, 3 photos of each person in the data were randomly selected for training, and the other 7 were used for recognition. And so on, in the next 6 experiments, the photos of packaging bottles in the training set were gradually added 1 until the number of photos was 9. The recognition rate of the 3 recognition models for each experiment was counted as shown in Figure3.Figure 3
. The recognition rate of three recognition models.800 single-package bottle images and 500 multipackage bottle images were randomly selected, and they were detected using two recognition models, and then the results were simulated and analyzed. The simulation results are shown in Figure4. For both algorithms, the detection rate of multipack bottles is lower than that of single-pack bottles, and the false detection rate of multipack bottles is higher than that of single-pack bottles. Because the background of multipack bottles is relatively more complex, the posture of the bottles is also varied, and the bottles may be missed if the face of the bottles is partially obscured, these factors lead to a lower detection performance of multipack bottles than that of single-pack bottles (see Figure 4).Figure 4
. Identification model simulation results. (a) Traditional AdaBoost algorithm. (b) Improved AdaBoost algorithm.
(a)(b)


## 4.2. Performance Analysis of Packaging Bottle Recognition Algorithm

From Figure5, it can be seen that the differential method is affected by the shadow of the packaging bottle itself in the static background, causing false detection and missed detection. In this paper, the algorithm has a leakage phenomenon for the contour detection of the packaging bottle. The reason is that in the training stage of the algorithm, the front face image of the positive sample bottle is mainly selected from common household bottles, and the algorithm cannot detect the special bottle contour very well (see Figure 5).Figure 5
. Single background test results.From Figure6, it can be seen that the AdaBoost algorithm has a high false detection rate for packaging bottle contour detection in a complex background, which is more easily affected by the background. The algorithm in this paper shows better stability in this complex background. The experimental results show that the differential and traditional AdaBoost algorithms in the detection process will wrongly detect other motion targets in the complex background, resulting in false detection. The improved algorithm effectively removes the false targets after extracting the ROI and screening the ROI. Compared with the differential method and the traditional AdaBoost algorithm, the improved algorithm has a certain improvement in accuracy and a significant reduction in the false detection and missed detection rates (see Figure 6).Figure 6
. Complex background detection results.


## 4.3. Packaging Bottle Identification System Actual Test Analysis

In terms of recognition accuracy, Figure7 shows the relationship between the recognition accuracy and the number of training rounds of the traditional AdaBoost and the improved AdaBoost algorithms, and the experimental system is the packaging bottle recognition system designed in this paper. From Figure 7, we can see that the accuracy of both algorithms improves as the number of training rounds increases, but the improvement of this algorithm is more obvious with the same number of training rounds. Initially, the difference in accuracy between the two algorithms is about 4%, and the peak is reached at about 120 rounds, when the difference in accuracy between the two algorithms reaches 8%, after which the accuracy of the two algorithms stabilizes. The accuracy of the improved AdaBoost algorithm reaches 92.86%, which is about 9% higher than that of the traditional AdaBoost algorithm, and the practicality is improved (see Figure 7).Figure 7
. System recognition accuracy rate.The purpose of the significance test in this paper is to verify whether the difference between the classification effect of the improved AdaBoost algorithm before and after is significant. The significance test was performed using the SPSS software, and the results are shown in Figure8.Figure 8
. Results of the systematic significance test: (a) sample 1 and (b) sample 2.
(a)(b)From the significance test of the error rate of sample 1 in Figure8, it can be seen that the variances of the two samples are not equal, and at the significance level of 5.2%, 0.0 < p < 0.5, indicating that there is a significant difference between the means of the two samples before and after the improvement of sample 1. From the significance test of the error rate of sample 2 in Figure 8, it is clear that the variances of the two samples are not equal, and at the significance level of 4.1%, 0.5 < p < 0.7, indicating that there is a significant difference between the two sample means before and after the improvement of sample 2. In summary, there is a significant difference in the mean values of error rates derived from the AdaBoost algorithm before and after the improvement, that is, the difference in the classification effect of the AdaBoost algorithm before and after the improvement is significant and the improvement is meaningful.


## 5. Conclusion

The research designs the design and implementation of packaging bottle recognition based on the improved AdaBoost algorithm. The innovative design and promotion of an intelligent packaging bottle recognition system are of great significance to improve the recognition rate of packaging bottles and standardize the recognition system. For the existing packaging bottle recognition methods, the multidimensional recognition methods of packaging bottle barcode and dimension code online recognition, weighing, material, and packaging bottle image recognition are proposed. Research into image recognition algorithms has also been launched. Through the research and application of preprocessing, edge detection, and image morphology, the clear outline of the packaging bottle in the image is obtained and matched with the outline template in the database to complete the image recognition process. Through a lot of experiments and tests, the intelligent recognition device can operate stably and reliably and can realize the effective intelligent recognition of waste packaging bottles, which has met the basic requirements of the design. For classification, this paper selects the improved AdaBoost algorithm, which can combine the similarity of test samples and each cluster into different strong classifiers according to different test samples, which improves the adaptability of strong classifiers to test samples and improves the overall accuracy. In this paper, the inverse of the Euclidean distance is used to calculate the similarity between test samples and clusters. Although the algorithm studied in this paper has achieved certain results, there are still many problems. Since the training samples are collected from the front face images of the packaging bottles, the detection of the contours of the packaging bottles on the side and back is not yet possible. Optimization for the AdaBoost algorithm sample training phase is effective, but there is further room. With the continuous improvement of artificial intelligence technology, we believe that packaging bottle contour detection technology will make great progress.



---

*Source: 5082544-2022-03-22.xml*