Disclosure of Invention
In order to solve the technical problems, the invention aims to provide an intelligent detection method for cigarette packet missing strip of a carton sealing machine based on similarity analysis and feature increment learning, which realizes effective characterization and quantification of picture feature information; by means of feature increment learning of online recognition of pictures without missing strips, the threshold value of the similarity index is continuously updated, the quality defect of the tobacco packet missing strips is accurately judged, and an information basis is provided for missing strip evidences through picture marking.
In order to achieve the purpose, the invention adopts the following technical scheme:
the intelligent detection method for cigarette packet missing of the carton sealing machine based on similarity analysis and feature increment learning comprises the following steps:
(1) image graying and active area selection
Based on the front and rear imaging devices added on the carton sealing machine, when the push plate pushes the front 25 cigarettes into the carton completely, a front picture OF (N) is obtainedof×MofX 3) when the back 25 cigarettes are all pushed into the carton push plate to return, a back bitmap OB (N) is obtainedob×MobX 3) of the front and rear pictures into a gray image GF (N)of×Mof) And GB (N)ob×Mob) Because the shooting angles of the front picture and the rear picture are relatively fixed aiming at a certain carton sealing machine, in order to quickly identify the effective area of the cigarette packet, the method of manually marking the effective area of the cigarette packet is adopted to respectively obtain the coordinates (X) of the upper left corners of the front picture and the rear picturef、xb) Upper left corner Y-axis coordinate (Y)f、yb) Width (w)f、wb) Height (h)f、hb) Waiting for 8 parameters to obtain a gray image PF (N) of the effective area of the tobacco balepf×Mpf) And PB (N)pb×Mpb);
(2) Similarity analysis based on blocking idea
Based on the gray level image of the effective area of the cigarette packet of the preceding picture, equally dividing the gray level image into 5 blocks according to the height of the image to obtain 5 lines of sub-images XPFi(Nxpf×Mpf) (i-1, …,5), calculate each sub-image matrix XPFiMean value of column vectors, obtaining vector XMPF of 5 rows of sub-imagesi(1×Mpf) Calculating the similarity (rho) between every two adjacent rows by using the Pearson correlation coefficientf12、ρf23、ρf34、ρf45) (ii) a Equally dividing the gray image based on the front picture cigarette packet effective area into 5 blocks according to the width of the image to obtain 5 columns of sub-images YPFi(Npf×Mypf) (i 1, …,5), each sub-image matrix YPF is calculatediObtaining the vector YMPF of 5 columns of sub-images by averaging the row vectorsi(NpfX 1), calculating the similarity (rho ') between every two adjacent columns by using Pearson correlation coefficient'f12、ρ′f23、ρ′f34、ρ′f45);
Calculating the bitmap cigarette carton by the same methodSimilarity (p) between every two adjacent lines of the active area gray scale imageb12、ρb23、ρb34、ρb45) And a similarity (ρ'b12、ρ′b23、ρ′b34、ρ′b45);
(3) Modeling picture threshold calculation based on kernel density estimation
A similarity row vector rho can be calculated according to a front bit picture and a rear bit picture of a cigarette packet
1In turn from rho
f12、ρ
f23、ρ
f34、ρ
f45、ρ′
f12、ρ′
f23、ρ′
f34、ρ′
f45、ρ
b12、ρ
b23、ρ
b34、ρ
b45、ρ′
b12、ρ′
b23、ρ′
b34、ρ′
b45Elemental composition, collecting N
oCalculating the similarity row vector rho of each cigarette packet
j(1×16)(j=1,…,N
o) Form a similarity matrix
Aiming at each row of data of the matrix, determining the distribution characteristics of the data by adopting a kernel density estimation method because the distribution condition of the data is unknown, and calculating to obtain a kernel density curve corresponding to each row; taking the similarity data at the leftmost side (namely, the minimum similarity) in the nuclear density curve as a threshold corresponding to the position in the modeling image to obtain a threshold vector theta (1 × 16);
(4) tobacco bale picture on-line identification based on similarity
Re-collecting front picture OF OF cigarette packetTAnd a back bit slice OBTConvert it into a gray image GFTAnd GBTRespectively obtaining gray front image PF of effective area of tobacco bale based on the coordinates of effective area of front image and rear image recognized in advanceTAnd a back picture PBTThe gray front image PFTDividing lines according to the height of the image, and calculating the similarity rho between adjacent linestf12、ρtf23、ρtf34、ρtf45Then, the image is divided into columns according to the image width, and the similarity ρ 'between adjacent columns is calculated'tf12、ρ′tf23、ρ′tf34、ρ′tf45Comparing the calculated 8 similarity indexes with the first 8 elements of the threshold vector theta one by one, if all the similarity indexes are larger than the corresponding elements of the threshold vector theta, identifying that the front image has no missing bars and performing corresponding marking on the image, otherwise identifying that the front image has missing bars and performing corresponding marking on the image, and identifying the gray level back image PB by adopting the same methodTWhether the strip is missing or not;
(5) feature incremental learning based threshold updating
For the tobacco bale image without the missing strips, after the identification by the technologist, the similarity row vector rho representing the tobacco bale image characteristics
TAdding the obtained similarity matrix into the existing similarity matrix R based on the updated similarity matrix
Recalculating to obtain a kernel density curve corresponding to each column, taking the leftmost (i.e. the smallest similarity) similarity data in the kernel density curves as the latest threshold corresponding to the position, and obtaining an updated threshold vector theta
T(1×16)。
The invention provides an intelligent detection method for cigarette packet strip missing of a carton sealing machine based on similarity analysis and feature increment learning, which comprises an offline modeling stage and an online identification stage. An off-line modeling stage: carrying out gray level transformation and image segmentation on tobacco bale internal front and rear position picture sheets collected by front and rear imaging devices of a cigarette pack of a carton sealing machine, calculating 16 characteristic similarity indexes of a modeling picture by adopting a picture transverse and longitudinal blocking similarity analysis method, and determining a threshold value of 16 characteristics of the modeling picture by utilizing a kernel density estimation method. And (3) an online identification stage: and calculating the front position and the rear position of the cigarette carton in the currently acquired cigarette packet in real time by adopting a similarity analysis method of horizontal and vertical partitioning, acquiring 16 characteristic similarity indexes of the current picture, and identifying whether the front position and the rear position have carton defects or not by comparing the similarity indexes with a current threshold value. And for the tobacco bale images which are not stripped on line, after the identification by process personnel, adding the similarity row vector which represents the tobacco bale image characteristics to the existing similarity matrix, and updating the threshold value by using a kernel density estimation method.
The invention has the beneficial effects that: the invention provides an intelligent detection method for cigarette packet strip shortage of a carton sealing machine based on similarity analysis and characteristic increment learning, aiming at the problem that the quality defect of the cigarette packet strip shortage occasionally occurs and based on front and rear pictures of cigarette strips in the cigarette packet, which are acquired by front and rear imaging devices of the cigarette packet of the carton sealing machine. Effective characterization and quantification of picture characteristic information are realized through the horizontal and vertical block division of the front bit and the rear bit picture and the similarity index calculation between the blocks; by means of feature increment learning of online recognition of pictures without missing strips, the threshold value of the similarity index is continuously updated, the quality defect of the tobacco packet missing strips is accurately judged, and an information basis is provided for missing strip evidences through picture marking.
Detailed Description
In order to better understand the technical scheme of the invention, the following description is further provided for the embodiment of the invention with the accompanying drawings. The implementation is an intelligent detection method for carton missing of a carton sealing machine cigarette packet, and the carton missing detection system of the carton sealing machine cigarette packet comprises a control PLC, front and rear cameras, front and rear light sources, a carton missing identification algorithm and the like. In the process that the front 25 cigarettes and the rear 25 cigarettes are pushed into the packing box by the push plate, when all the front 25 cigarettes enter the packing box, the front camera takes a picture; after the back 25 cigarettes are all pushed into the packing box, the lower part of the push plate is turned upwards in the process of returning the push plate, and at the moment, the back camera takes a picture. And (3) adopting image similarity analysis and feature increment learning technology to collect and judge whether the front and rear bitmap sheets of the tobacco strips in the tobacco bale have strip-lacking quality defects in real time. If the defective strip quality exists, sending a removing instruction to a defective strip removing control system; and if the strip-missing quality defect does not exist, sending a quality qualified signal to a quality tracing code pasting system. The implementation block diagram of the intelligent detection method for cigarette packet missing strip of the carton sealing machine based on similarity analysis and feature increment learning is shown in figure 1, and the method mainly comprises the following steps:
(1) image graying and active area selection
Based on the front and rear imaging devices added on the carton sealing machine, when the push plate pushes the front 25 cigarettes into the carton completely, a front picture OF (N) is obtainedof×MofX 3) when the back 25 cigarettes are all pushed into the carton push plate to return, a back bitmap OB (N) is obtainedob×MobX 3) of the front and rear pictures into a gray image GF (N)of×Mof) And GB (N)ob×Mob). As the shooting angles of the front picture and the rear picture are relatively fixed aiming at a certain carton sealing machine, in order to quickly identify the effective area of the cigarette packet, the method of manually marking the effective area of the cigarette packet is adopted to respectively obtain the coordinates (X) of the upper left corners of the front picture and the rear picturef、xb) Upper left corner Y-axis coordinate (Y)f、yb) Width (w)f、wb) Height (h)f、hb) Waiting for 8 parameters to obtain a gray image PF (N) of the effective area of the tobacco balepf×Mpf) And PB (N)pb×Mpb)。
In this example, the front and back original pictures OF the tobacco rod inside a certain cigarette packet are shown in fig. 2, and the matrices OF the original pictures are OF (652 × 738 × 3) and OB (652 × 738 × 3), respectively. The grayscale images after the grayscale conversion are represented by grayscale image matrices GF (652 × 738) and GB (652 × 738) in fig. 3. The effective area of the front gray level image of the artificial mark is as follows: upper left corner X-axis coordinate XfIs 121, upper left corner Y axis coordinate YfIs 196 and has a width wfIs 550 and the height hfIs 290; the effective area of the rear gray level image is as follows: upper left corner X-axis coordinate XbIs 131, upper left corner Y-axis coordinate YbIs 280 and width wbIs 470 and the height hbIs 245. Fig. 4 shows a gray scale image of the effective area of the cigarette packet, and gray scale image matrices PF (290 × 550) and PB (245 × 470) of the effective area.
(2) Similarity analysis based on blocking idea
Based on the gray level image of the effective area of the cigarette packet of the preceding picture, equally dividing the gray level image into 5 blocks according to the height of the image to obtain 5 lines of sub-images XPFi(Nxpf×Mpf) (i-1, …,5), calculate each sub-image matrix XPFiMean value of column vectors, obtaining vector XMPF of 5 rows of sub-imagesi(1×Mpf) Calculating the similarity (rho) between every two adjacent rows by using the Pearson correlation coefficientf12、ρf23、ρf34、ρf45) The calculation formula is as follows:
cov (XMPF)
i,XMPF
i+1) Representing two adjacent row vectors XMPF
iAnd XMPF
i+1The covariance of (a) of (b),
respectively represent vectors XMPF
i、XMPF
i+1Standard deviation of (2).
Equally dividing the gray image based on the front picture cigarette packet effective area into 5 blocks according to the width of the image to obtain 5 columns of sub-images YPFi(Npf×Mypf) (i 1, …,5), each sub-image matrix YPF is calculatediObtaining the vector YMPF of 5 columns of sub-images by averaging the row vectorsi(NpfX 1), calculating the similarity (rho ') between every two adjacent columns by using Pearson correlation coefficient'f12、ρ′f23、ρ′f34、ρ′f45)。
Calculating the similarity (rho) between every two adjacent rows of the effective area gray level image of the bitmap tobacco lamina package by adopting the same methodb12、ρb23、ρb34、ρb45) And a similarity (ρ'b12、ρ′b23、ρ′b34、ρ′b45)。
In this example, the 5 lines of sub-images of the gray scale image of the effective area of the cigarette packet in the front picture are XPFi(58X 550), by calculation XPFiObtaining the vector of the sub-image of 5 rows by the mean value of the column vectors as XMPFi(1 × 550), degree of similarity ρ between each two adjacent rowsf12、ρf23、ρf34、ρf450.9181, 0.9375, 0.9472, 0.8916, respectively. 5 columns of sub-images of the gray scale image of the effective area of the front picture cigarette packet are YPFsi(290X 110) by calculating YPFiThe vector of 5 columns of sub-images obtained by the mean value of the row vectors is YMPFi(290 × 1), similarity ρ 'between each two adjacent columns'f12、ρ′f23、ρ′f34、ρ′f450.7799, 0.8350, 0.9184, 0.9218, respectively.
The 5 lines of subimages of the effective area gray level image of the back bitmap chip tobacco bale are XPBi(49X 470) by calculating XPBiObtaining the vector of 5 lines of sub-images as XMPB by the mean value of the column vectorsi(1 × 470), the degree of similarity ρ between each two adjacent rowsb12、ρb23、ρb34、ρb450.9825, 0.9322, 0.9472, 0.9602, respectively. 5 columns of sub-images of the effective area gray scale image of the back bitmap film tobacco package are YPBi(245X 94), by calculating YPBiThe vector of 5 columns of sub-images obtained by the mean value of the row vectors is YMPBi(245 x 1), similarity ρ 'between each two adjacent columns'b12、ρ′b23、ρ′b34、ρ′b450.7457, 0.6217, 0.8400, 0.9247, respectively.
(3) Modeling picture threshold calculation based on kernel density estimation
A similarity row vector rho can be calculated according to a front bit picture and a rear bit picture of a cigarette packet
1In turn from rho
f12、ρ
f23、ρ
f34、ρ
f45、ρ′
f12、ρ′
f23、ρ′
f34、ρ′
f45、ρ
b12、ρ
b23、ρ
b34、ρ
b45、ρ′
b12、ρ′
b23、ρ′
b34、ρ′
b45And (3) element composition. Collecting N
oCalculating the similarity row vector rho of each cigarette packet
j(1×16)(j=1,…,N
o) Form a similarity matrix
And aiming at each row of data of the matrix, determining the distribution characteristics of the data by adopting a kernel density estimation method because the distribution condition of the data is unknown, and calculating to obtain a kernel density curve corresponding to each row. The kernel density estimation calculation formula in column k is as follows:
where K (-) is a Gaussian kernel function, ρjkIs a similarity index of the jth row and kth column of the similarity matrix R, NoFor modeling the number of pictures, h is the window width, when h is smaller, the nuclear density estimation curve can reflect more details but has poorer smoothness, and when h is larger, the nuclear density estimation curve is smoother but can cover some details.
The similarity data at the leftmost side (i.e., the minimum similarity) in the kernel density curve is used as a threshold corresponding to the position in the modeled image, and a threshold vector θ (1 × 16) is obtained.
In this example, a front bitmap of 130 groups of cigarette packets without strip missing is collectedCalculating similarity row vector rho of each tobacco packet by using the sheet and the rear bitmap sheetj(1 × 16), a similarity matrix R (130 × 16) is constructed. And aiming at each row of data of the matrix, selecting a window width h as 3, calculating a kernel density curve of each row according to a kernel density estimation calculation formula, wherein 16 similarity indexes correspond to the kernel density curve and are shown in fig. 4.
The similarity data at the leftmost side (i.e., the minimum similarity) in the nuclear density curve is used as a threshold corresponding to the position in the modeled image, and a threshold vector θ (1 × 16) is obtained, and 16 elements of the threshold vector θ are 0.8477, 0.8397, 0.8139, 0.8246, 0.6315, 0.6740, 0.7602, 0.7621, 0.9572, 0.8831, 0.9122, 0.9096, 0.5443, 0.5367, 0.7551, and 0.8267.
(4) Tobacco bale picture on-line identification based on similarity
Re-collecting front picture OF OF cigarette packetTAnd a back bit slice OBTConvert it into a gray image GFTAnd GBT. Respectively obtaining gray front image PF of effective area of tobacco bale based on the coordinates of effective areas of front image and rear image which are recognized in advanceTAnd a back picture PBT. PF (front gray level) imageTDividing lines according to the height of the image, and calculating the similarity rho between adjacent linestf12、ρtf23、ρtf34、ρtf45Then, the image is divided into columns according to the image width, and the similarity ρ 'between adjacent columns is calculated'tf12、ρ′tf23、ρ′tf34、ρ′tf45. And comparing the 8 similarity indexes obtained by calculation with the first 8 elements of the threshold vector theta one by one, if all the similarity indexes are greater than the corresponding elements of the threshold vector theta, identifying that the front image has no missing bars and carrying out corresponding marking on the image, and otherwise, identifying that the front image has missing bars and carrying out corresponding marking on the image. Identifying a grayscale post-image PB using the same methodTWhether the strip missing occurs.
In this example, the front images and the rear images of 1 group of cigarette packets without missing strips are collected again for online identification, and the original front image is shown in fig. 6 (a). Gray level image matrix PF of effective area obtained by gray level transformation and image segmentationT1(290 × 550), PF is calculatedT18 similarity indexes ρtf12、ρtf23、ρtf34、ρtf45、ρ′tf12、ρ′tf23、ρ′tf34、ρ′tf45Respectively as follows: 0.9028, 0.8716, 0.9407, 0.8638, 0.8168, 0.8085, 0.8457, 0.8888. The 8 similarity indexes are all larger than the first 8 elements of the threshold vector theta (1 × 16), the previous picture is identified that the missing bar does not appear, and the picture is labeled correspondingly, as shown in fig. 6 (b).
The original posterior image is shown in fig. 7 (a). Obtaining a gray image matrix PB of an active area by gray conversion and image segmentationT1(245X 470) to calculate PBT18 similarity indexes ρtb12、ρtb23、ρtb34、ρtb45、ρ′tb12、ρ′tb23、ρ′tb34、ρ′tb45Respectively as follows: 0.9768, 0.9272, 0.9548, 0.9514, 0.7241, 0.6833, 0.8539, 0.9264. The 8 similarity indexes are all larger than the last 8 elements of the threshold vector theta (1 × 16), the fact that the back bitmap slice has no missing bars is identified, and corresponding labeling is performed on the picture, as shown in fig. 7 (b).
And then, the image of the front cigarette rod in 1 group of cigarette packets is collected again for online identification, and the original front image is shown in fig. 8 (a). Gray level image matrix PF of effective area obtained by gray level transformation and image segmentationT2(290 × 550), PF is calculatedT28 similarity indexes ρtf12、ρtf23、ρtf34、ρtf45、ρ′tf12、ρ′tf23、ρ′tf34、ρ′tf45Respectively as follows: 0.4856, 0.9295, 0.8801, 0.9198, 0.8183, 0.8139, 0.8542, 0.6398. Among the 8 similarity indexes, ρtf12And ρ'tf45And identifying the missing bar of the previous picture when the element is smaller than the element corresponding to the threshold vector theta (1 × 16), and labeling the picture correspondingly, as shown in fig. 8 (b).
And then, the image of the back cigarette strip in 1 group of cigarette packets is collected again for online identification, and the original back image is shown in fig. 9 (a). By grey scale transformation and mappingObtaining gray image matrix PB of effective area by image divisionT2(245X 470) to calculate PBT28 similarity indexes ρtb12、ρtb23、ρtb34、ρtb45、ρ′tb12、ρ′tb23、ρ′tb34、ρ′tb45Respectively as follows: 0.8437, 0.9165, 0.9431, 0.9601, 0.5909, 0.5157, 0.8406, 0.9079. Among the 8 similarity indexes, ρtb12And ρ'tb23And identifying the elements smaller than the threshold vector theta (1 × 16), and labeling the picture correspondingly, as shown in fig. 9 (b).
(5) Feature incremental learning based threshold updating
For the tobacco bale image without the missing strips, after the identification by the technologist, the similarity row vector rho representing the tobacco bale image characteristics
TAdding the obtained similarity matrix into the existing similarity matrix R based on the updated similarity matrix
The kernel density curve corresponding to each column is recalculated. Taking the similarity data at the leftmost side (namely, the similarity is minimum) in the nuclear density curve as the latest threshold corresponding to the position, and obtaining an updated threshold vector theta
T(1×16)。
In this example, the front picture and the rear picture of 10 groups of cigarette packets without the occurrence of the missing carton are collected again for online identification, and the occurrence of the missing carton is identified. The similarity row vector rho of the 10 groups of non-missing tobacco bale image features is representedT1,…,ρT10And adding the similarity matrix R to the existing similarity matrix R in sequence. Selecting the window width h as 3, recalculating the kernel density curve of each row by adopting kernel density estimation, and obtaining an updated threshold vector thetaT(1 × 16), 16 elements of which are 0.8466, 0.8390, 0.8116, 0.8222, 0.6297, 0.6771, 0.7608, 0.7625, 0.9568, 0.8831, 0.9128, 0.9104, 0.5408, 0.5375, 0.7550, 0.8273, respectively.
It should be noted that the above embodiments are merely representative examples of the present invention. Many variations of the invention are possible. Any simple modification, equivalent change and modification of the above embodiments according to the spirit of the present invention should be considered to be within the protection scope of the present invention.