A method for cigarette identification

Through feature comparison and QR code decoding, combined with color distinction model, the problem of only QR codes in the existing technology is difficult to identify, and the accurate identification of different end patterns is achieved, and automatic verification is improved accuracy and efficiency.

CN118644738BActive Publication Date: 2024-11-08SHENZHEN AIMALL TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411092480.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-09
Publication Date
2024-11-08
Estimated Expiration
2044-08-09

AI Technical Summary

Technical Problem

In the prior art, the pattern of the cigarette end is an image with only QR codes but no other identification textures. It is difficult to identify the texture features of the surface, making it difficult to determine the specific specifications, affecting the operation efficiency of the order matching and packaging line. Product quality.

Method used

By obtaining the cigarette end image in the image to be identified, comparing features with the calibrated image, determining whether it contains a QR code, and identifying specifications through cosine similarity and color distinction model, combining feature matching and QR code decoding, realizing Accurate identification of different end patterns.

Benefits of technology

It improves the accuracy of the identification of cigarette ends, reduces misjudgment, improves the matching accuracy rate in automatic verification, and ensures the accurate matching of orders and packaging.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118644738B_ABST
    Figure CN118644738B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for cigarette identification, which relates to the field of computer vision technology and solves the technical problem that it is difficult to determine the specifications of a cigarette image that only has a two-dimensional code but no other identifiable textures. The method comprises: performing feature comparison between a cigarette end image and a calibration image to obtain a first cosine similarity; if the cigarette end image contains a two-dimensional code, decoding the two-dimensional code to obtain the specifications of the cigarette in the cigarette end image; if the cigarette end image does not contain a two-dimensional code, determining whether the first cosine similarity is greater than a first similarity threshold; if the first cosine similarity is greater than the first similarity threshold, identifying that the cigarette end image and the cigarette in the calibration image are of the same specification; if the first cosine similarity is not greater than the first similarity threshold, obtaining the specifications of the cigarette in the cigarette end image by performing feature comparison between the cigarette end image and the identified image. The present invention can improve the accuracy of cigarette specification identification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer vision technology, and in particular to a cigarette recognition method. Background Art

[0002] In the process of tobacco circulation, it starts from various cigarette factories, and various types of cigarettes are gathered in tobacco distribution centers, then wholesaled to retailers, and finally into the hands of consumers. Delivering tobacco packages to retail store owners and ensuring correct delivery is a very important link in the tobacco distribution process system. The usual tobacco distribution process is to receive the purchase and order information from the merchant, and then sort and package the goods for delivery from the warehouse, and finally distribute them uniformly. In order to improve the accuracy of the delivery link and avoid sorting errors in the tobacco sorting process, an order receipt verification link is added at the end of the delivery process.

[0003] In the current automated cigarette order verification process, the core is to identify the information of the cigarette carton end through image recognition and feature matching technology to obtain the specific specifications of the cigarette carton and ensure that it matches the order information. In existing technologies, the identification of cigarette carton ends depends on the surface texture features of the end surface. Using the above method in an actual production environment will face a problem: most tobacco companies will print a QR code containing cigarette carton information on all cigarette packages, and some will modify the pattern of the cigarette carton end to an image with only a QR code but no other identifying textures. This type of end cannot be identified by the surface texture features, making it difficult to determine the specific specifications. The uncertain specifications caused by this problem will affect the subsequent matching with the order, thereby affecting the operating efficiency of the packaging line and the stability of product quality.

[0004] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0005] Some cigarette ends have images with only a QR code but no other identifying textures. Such ends are difficult to identify by the surface texture features, making it difficult to determine their specific specifications. Summary of the invention

[0006] The purpose of the present invention is to provide a method for identifying cigarettes, so as to solve the technical problem that some cigarette ends in the prior art have only a two-dimensional code and no other identifiable texture image, and such ends are difficult to identify by surface texture features, resulting in difficulty in determining specific specifications. The preferred technical solutions among the many technical solutions provided by the present invention can produce many technical effects as described below.

[0007] To achieve the above object, the present invention provides the following technical solutions:

[0008] The present invention provides a method for identifying cigarettes, comprising the following steps: obtaining a cigarette end image in an image to be identified, and performing feature comparison between the cigarette end image and a calibration image to obtain a first cosine similarity; the calibration image is a cigarette end image of known specifications; identifying whether the cigarette end image contains a two-dimensional code; if the cigarette end image contains the two-dimensional code, decoding the two-dimensional code to obtain the specifications of the cigarette in the cigarette end image; if the cigarette end image does not contain the two-dimensional code, determining whether the first cosine similarity is greater than a first similarity threshold; if the first cosine similarity is greater than the first similarity threshold, identifying the cigarette end image and the cigarette end image in the calibration image. the cigarettes are of the same specification; if the first cosine similarity is not greater than a first similarity threshold, the specification of the cigarette in the cigarette end image is obtained by performing feature comparison between the cigarette end image and the identified image; wherein the identified image is the cigarette end image of a determined specification obtained by decoding the first cosine similarity or the two-dimensional code; the obtaining the specification of the cigarette in the cigarette end image by performing feature comparison between the cigarette end image and the identified image comprises: performing feature comparison between the cigarette end image and the identified image to obtain a second cosine similarity; associating the cigarette end image whose second cosine similarity is greater than a second similarity threshold and the cigarette in the identified image as having the same specification.

[0009] Preferably, the method for identifying cigarette carton specifications also includes the following steps: dividing the cigarette carton end image and the identified image that are associated with the same specification into the same similarity group; constructing a color distinction model, and obtaining the color score of the images in the similarity group being the same color through the color distinction model; obtaining the similarity group whose color score is greater than a third similarity threshold, and identifying that the cigarette carton end image and the cigarette carton in the identified image are of the same specification.

[0010] Preferably, constructing the color distinction model includes the following steps: obtaining N pairs of cigarette end samples and color categories appearing in M ​​labeled known specifications to construct a training sample set; wherein the cigarette end samples include cigarette end images of uncertain specifications and cigarette end images of determined specifications; and training a neural network based on the training sample set to obtain the color distinction model.

[0011] Preferably, the color distinction model includes an input layer, an intermediate layer and an output layer; the input layer is used to receive the cigarette end image samples; the intermediate layer includes two resnet18 networks, which respectively receive the cigarette end image samples passing through the input layer; the output layer includes a concate layer, a fully connected layer and a sigmoid layer; the concate layer merges the outputs of the resnet18 networks in the channel dimension, converts them into an output node through the fully connected layer, and converts them into the color scores by the sigmoid layer.

[0012] Preferably, decoding the QR code to obtain the specifications of the cigarette in the cigarette end image includes: decoding the QR code through the quirc module of the OpenCV library or the ZXing library to obtain a specification information website; searching for the cigarette specification information corresponding to the specification information website in a decoding mapping table to obtain the specifications of the cigarette in the cigarette end image; wherein, in the decoding mapping table, the cigarette specification information corresponds to the specification information website.

[0013] Preferably, the identifying whether the cigarette end image contains a QR code comprises:

[0014] A QR code detection module is used to identify whether the cigarette end image contains a QR code; wherein the QR code detection module is obtained by training a target detection model using multiple end sample images with QR codes and annotated QR code coordinates as a training set.

[0015] Preferably, feature comparison is performed through a feature matching module; wherein a MobileNet model is used as a backbone network of the feature matching module.

[0016] Preferably, the formula for calculating the first cosine similarity and the second cosine similarity is:

[0017] , m=1,2,...,n;

[0018] Wherein, a is the feature vector of the cigarette end image; is a feature vector of a comparison image, wherein the comparison image includes the calibration image and the recognized image.

[0019] Preferably, the method of obtaining the cigarette end image in the image to be identified includes: obtaining the cigarette end image in the image to be identified through an end detection module; wherein the end detection module is obtained by training a target detection model using multiple cigarette sample images and annotated end coordinates as a training set.

[0020] Implementing one of the above technical solutions of the present invention has the following advantages or beneficial effects:

[0021] The present invention firstly performs a preliminary recognition of the cigarette end image by feature comparison, and then determines the cigarette specification by identifying the QR code. Because the recognition result of the QR code must be correct, if there is a QR code recognition result, the QR code recognition result is used; if there is no QR code, the specification is confirmed by the cosine similarity with the cigarette end image of known specifications; through the dual recognition of feature comparison and QR code recognition, not only the cigarette end with characteristic texture can be identified, but also the cigarette end with only QR code can be effectively identified, so as to improve the accuracy of cigarette end recognition, thereby reducing the misjudgment phenomenon of automatic cigarette package in automatic verification. For cigarette ends whose cosine similarity does not meet the threshold requirement and do not have a QR code (or the QR code pattern is unclear and cannot be recognized), the recognition accuracy can be further improved by performing feature comparison with cigarettes with confirmed specifications. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. It is obvious that the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0023] Figure 1 is a flow chart of a method for identifying cigarette specifications according to an embodiment of the present invention;

[0024] Figure 2 is a flow chart of decoding a two-dimensional code according to an embodiment of the present invention;

[0025] Figure 3 is a flow chart of step S6 of the method for identifying cigarette carton specifications according to an embodiment of the present invention;

[0026] Figure 4 It is a flow chart of step S7 of the method for identifying cigarette carton specifications according to an embodiment of the present invention. DETAILED DESCRIPTION

[0027] In order to make the purpose, technical solutions and advantages of the present invention clearer, the various exemplary embodiments to be described below will refer to the corresponding drawings, which constitute a part of the exemplary embodiments, wherein various exemplary embodiments that may be used to implement the present invention are described. Unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation methods described in the following exemplary embodiments do not represent all implementation methods consistent with the present disclosure. It should be understood that they are only examples of processes, methods, devices, etc. that are consistent with some aspects of the present disclosure as detailed in the attached claims, and other embodiments may also be used, or the embodiments listed herein may be modified in structure and function without departing from the scope and essence of the present invention.

[0028] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", etc. indicate the orientation or positional relationship based on the drawings, which is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the elements referred to must have a specific orientation, be constructed and operated in a specific orientation. The terms "first", "second", etc. are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. The term "multiple" means two or more. The terms "connected" and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, an integral connection, a mechanical connection, an electrical connection, a communication connection, a direct connection, an indirect connection through an intermediate medium, and can be the internal connection of two elements or the interaction relationship between two elements. The term "and / or" includes any and all combinations of one or more related listed items. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to the specific circumstances.

[0029] In order to illustrate the technical solution of the present invention, a specific embodiment is used below for description, and only the parts related to the embodiment of the present invention are shown.

[0030] Embodiment 1:

[0031] like Figure 1As shown, the present invention provides a method for identifying cigarettes, comprising the following steps: S1, obtaining a cigarette end image in an image to be identified, and performing feature comparison between the cigarette end image and a calibration image to obtain a first cosine similarity; the calibration image is a cigarette end image of known specifications; S2, identifying whether the cigarette end image contains a two-dimensional code; S3, if the cigarette end image contains a two-dimensional code, decoding the two-dimensional code to obtain the specifications of the cigarette in the cigarette end image; S4, if the cigarette end image does not contain a two-dimensional code, determining whether the first cosine similarity is greater than a first similarity threshold; S5, if the first cosine similarity is greater than the first similarity threshold, identifying that the cigarette end image and the cigarette in the calibration image are of the same specification; S6, if the first cosine similarity is not greater than the first similarity threshold, obtaining the specifications of the cigarette in the cigarette end image by performing feature comparison between the cigarette end image and the identified image; wherein the identified image is a cigarette end image of a determined specification obtained by decoding the first cosine similarity or the two-dimensional code.

[0032] This embodiment first performs a preliminary recognition of the cigarette end image through feature comparison, and then determines the cigarette specification by recognizing the QR code. Because the recognition result of the QR code must be correct, if there is a QR code recognition result, the QR code recognition result is used; if there is no QR code, the specification is confirmed by the cosine similarity with the cigarette end image of known specifications; through the dual recognition of feature comparison and QR code recognition, the specifications of cigarettes with various end patterns can be confirmed. For cigarette ends whose cosine similarity does not meet the threshold requirements and do not have a QR code (or the QR code pattern is unclear and cannot be recognized), the recognition accuracy can be further improved by performing feature comparison with cigarettes with confirmed specifications.

[0033] Next, combine Figure 1-Figure 4 The specific implementation steps of the method for identifying cigarette specifications provided in this embodiment are described in detail:

[0034] First, execute step S1, obtain the image of the cigarette end in the image to be identified, and perform feature comparison between the image of the cigarette end and the calibration image to obtain the first cosine similarity; the calibration image is an image of the cigarette end of known specifications. Among them, the image to be identified is the collected image of the cigarette package to be identified (such as taken by a camera). Generally speaking, an image to be identified includes multiple cigarette ends; the image of the cigarette end of known specifications is the collected images of various types of cigarette ends on sale, and the specifications of the cigarettes in the images of the cigarette ends on sale are all known. Feature comparison is performed to determine whether the cigarette end in the image to be identified is similar to the cigarette end in the calibration image.

[0035] Specifically, the end detection module is used to obtain the end image of the cigarette in the image to be identified; wherein, the end detection module is obtained by training the target detection model using multiple (1500 in the actual training process of this embodiment) cigarette sample images and annotated end coordinates as a training set; the target detection model can use the YOLOv7 model, the EfficientDet model, the RetinaNet model and the Yolov8n model. This embodiment preferably uses the Yolov8n model. Yolov8n (You Only Look Once version 8) is a deep learning framework for achieving real-time object detection. It has a powerful feature extraction capability and can accurately obtain the end image of the cigarette in the image to be identified and extract features. In the prediction process, the image to be identified is sent to the end detection module to obtain the coordinates of each cigarette end, and each cigarette end is cut out by the coordinates, so that feature matching and two-dimensional code recognition can be performed simultaneously.

[0036] The feature matching module is used to compare features. The MobileNet model is used as the backbone network of the feature matching module. The MobileNet model is a lightweight neural network that reduces the amount of calculation and the size of the model through deep separable convolution, thereby improving the calculation efficiency and speed. The structure of the feature matching module includes an input layer, an intermediate layer, and an output layer. The input layer receives the cigarette end image with an image size of 336*112*3; the middle layer uses multiple convolutional layers of the MobileNet model to extract features and obtain feature maps; the output layer includes a GAP (Global Average Pooling) layer, a fully connected layer, and a Softmax layer. The GAP layer reduces the dimension of each feature map from H*W*C (H*W is the size of the original image, where H is the length and W is the width; C is the number of RGB color channels, where C is the dimension) to 1*1*C. The number of output nodes of the fully connected layer is equal to the number of specifications of cigarettes on sale that need to be identified, which is used to generate cigarette end images and prediction scores for the specifications of cigarettes on sale in each category. After the fully connected layer, the Softmax activation function is used in the Softmax layer to convert the output into a probability distribution. The output of each node represents the probability that the input image belongs to a certain specification category, that is, the feature matching score, which is calculated by the cosine similarity method. 42,500 images of cigarette carton ends and 425 annotated specifications of cigarette carton ends were used as training sets for training. Finally, the intermediate layer and GAP layer were exported as feature extraction models for feature extraction. After obtaining the feature extraction model, the features of the specifications of the 425 cigarette carton ends needed to be extracted and saved in the database for subsequent feature comparison to determine the specific specifications of the cigarette carton ends.

[0037] The feature comparison uses the method of calculating cosine similarity. The formulas for calculating the first cosine similarity and the second cosine similarity are:

[0038] , m=1,2,...,n;

[0039] Among them, a is the feature vector of the cigarette end image; is the feature vector of the comparison image, wherein the comparison image includes the calibration image and the recognized image.

[0040] Then, step S2 is executed to identify whether the cigarette end image contains a QR code. Specifically, a QR code detection module is used to identify whether the cigarette end image contains a QR code; wherein the QR code detection module is obtained by training a target detection model using multiple (preferably 500) sample images of the end with QR codes and annotated QR code coordinates as a training set. Similarly, the target detection model can adopt a YOLOv7 model, an EfficientDet model, a RetinaNet model, a Yolov8n model, and the like.

[0041] If in step S2, it is identified that the cigarette end image contains a QR code, then step S3 is executed to decode the QR code to obtain the specifications of the cigarette in the cigarette end image. Figure 2 As shown, it includes: S31, decoding the QR code through the quirc module of the OpenCV library or the ZXing library to obtain the specification information website; S32, searching the cigarette specification information corresponding to the specification information website in the decoding mapping table to obtain the specifications of the cigarette in the cigarette end image; wherein, in the decoding mapping table, the cigarette specification information corresponds to the specification information website. In this embodiment, the QR code is decoded through the quirc module of the OpenCV library or the ZXing library, and the quirc module of the OpenCV library or the ZXing library can effectively parse the QR code on the cigarette end. After the QR code on the cigarette end is parsed, a website (i.e., the specification information website) will be obtained. After opening, the basic information of the cigarette specifications, including the cigarette name, etc., can be determined through this website. The specific specifications of the cigarette end can be determined. Considering the influence of network fluctuations, this method of obtaining data from the page pointed to by the website is not stable, and the running scenario needs to be able to run in real time, so this embodiment adopts another method to replace the method of obtaining data from the page pointed to by the website to determine the specific specifications of the end. It is as follows:

[0042] The URL itself has regularity, in which a certain section of characters has a mapping relationship with the specifications of cigarette cartons. That is, although they are different individuals, this section of characters in the URL of cigarette cartons with the same specifications is exactly the same. Therefore, for the specifications of 425 cigarette cartons on sale, a decoding mapping table is established for the same section of characters in the URL and the corresponding cigarette cartons specifications. After completing the QR code parsing to obtain the URL, the corresponding cigarette cartons specifications can be found directly through the mapping table, avoiding the need to obtain the cigarette cartons specifications from the web page pointed to by the URL.

[0043] After completing feature matching and QR code recognition, the results of the two need to be combined. Since the results of QR code recognition must be correct, if there are QR code recognition results for the same cigarette end, the results of QR code recognition will overwrite the original feature matching results to ensure the accuracy of the recognition results.

[0044] If in step S2, it is identified that the cigarette end image does not contain a QR code, step S4 is executed to determine whether the first cosine similarity is greater than the first similarity threshold. Since some cigarette ends do not have a QR code, the original feature matching result is used to confirm the specifications.

[0045] If in step S4, the first cosine similarity is greater than the first similarity threshold, step S5 is executed to identify that the cigarette end image and the cigarette in the calibration image are of the same specification. In this embodiment, the first similarity threshold is set to 0.65. If the first cosine similarity (i.e., the feature matching score mentioned above) is greater than 0.65, it means that the cigarette end to be identified is very similar to the cigarette end of known specifications, and it can be confirmed that they are of the same specification.

[0046] If in step S4, the first cosine similarity is not greater than the first similarity threshold, then step S6 is executed to obtain the specifications of the cigarette in the cigarette end image by performing feature comparison between the cigarette end image and the recognized image; wherein the recognized image is a cigarette end image of a determined specification obtained by decoding the first cosine similarity or the QR code. Since a certain specification is likely to appear repeatedly in the same package, the specifications of the cigarette in the unrecognized cigarette end image can be confirmed by performing feature comparison with the previously recognized cigarette ends, thereby further improving the recognition accuracy.

[0047] As an alternative implementation, Figure 3 As shown, step S6 includes: S61, comparing the features of the cigarette end image with the recognized image to obtain a second cosine similarity; S62, associating the cigarette end image with a second cosine similarity greater than a second similarity threshold and the cigarette in the recognized image as the same specification.

[0048] Due to the influence of environmental factors such as wrapping film wrinkles and reflections, the feature matching scores of some cigarette carton ends do not reach the first similarity threshold, or only part of the QR code of some cigarette carton ends can be successfully identified. In order to obtain the specific specifications of the remaining cigarette carton ends with low feature matching scores and only QR codes as much as possible, based on the condition that a single specification will appear repeatedly in the same package, a feature matching recognition mechanism is introduced to associate it with the successfully identified cigarette carton ends, thereby obtaining the specific specifications of the unidentified cigarette carton ends.

[0049] First, all cigarette carton ends are divided into two categories: one is the images of cigarette carton ends of determined specifications whose QR codes have been successfully identified and whose feature matching scores are above 0.65, and the other is the remaining images of cigarette carton ends of uncertain specifications. Each image of a cigarette carton end of uncertain specifications is matched with each image of a cigarette carton end of determined specifications by calculating the cosine similarity to obtain the second cosine similarity. Each image of a cigarette carton end of uncertain specifications is grouped with the identified image with the highest second cosine similarity. If the second cosine similarity is greater than the second similarity threshold, the cigarette carton end of uncertain specifications can be associated with the same specifications as the cigarette carton in the identified image in the same group. In this embodiment, the second similarity threshold is set to 0.8, that is, when the second similarity threshold is greater than 0.8, it can be confirmed that the cigarette carton end is of the same specifications as the cigarette carton in the identified image in its similar group.

[0050] Since the model used to extract the features of cigarette ends is a universal version applicable to different packages, it is not sensitive to light changes and color distinctions, and the light in the packaging machine is originally darker than normal light conditions. Using only feature matching methods may make it difficult to distinguish specifications with similar colors, resulting in misidentification. Therefore, this embodiment introduces a color matching mechanism after feature matching to further improve the accuracy of identifying the same specifications.

[0051] As an alternative implementation, Figure 4As shown, the method for identifying cigarette carton specifications also includes the following steps: S71, dividing the cigarette carton end images and the identified images that are associated with the same specification into the same similarity group; if the second cosine similarity between the cigarette carton end image and multiple identified images is above 0.8, there may be multiple similarity groups; S72, constructing a color distinction model, and obtaining the color score of the images in the similarity group being the same color through the color distinction model; S73, obtaining similarity groups with color scores greater than the third similarity threshold, and identifying that the cigarette carton end image and the cigarette carton in the identified image are of the same specification. In this embodiment, the third similarity threshold is set to 0.6, and the color distinction model is used to judge each group of similar groups, and all combinations with scores above 0.6 are retained, that is, the specifications in the combination are the same. The determined specifications in each group of combinations of the same specification are overwritten with the recognition results of the uncertain specifications. After the overwriting is completed, the final cigarette carton end specifications are obtained for subsequent matching with orders.

[0052] Optionally, constructing a color differentiation model includes the following steps: obtaining N pairs of cigarette end samples and color categories appearing in M ​​labeled known specifications to construct a training sample set; wherein the cigarette end samples include images of cigarette end with uncertain specifications and images of cigarette end with certain specifications; and training a neural network according to the training sample set to obtain a color differentiation model. In this embodiment, 5,000 pairs of cigarette end samples and color categories appearing in 15 labeled known grids are used as training sets for training to obtain a color differentiation model.

[0053] Optionally, the color distinction model includes an input layer, an intermediate layer and an output layer; the input layer is used to receive cigarette end image samples; the intermediate layer includes two resnet18 networks, which respectively receive cigarette end image samples passing through the input layer; the output layer includes a concate layer, a fully connected layer and a sigmoid layer; the concate layer merges the outputs of the resnet18 networks in the channel dimension, converts them into an output node through the fully connected layer, and converts them into color scores by the sigmoid layer.

[0054] Through the identification method of cigarette carton specifications provided by this embodiment, both cigarette carton ends with obvious texture features and those containing only QR codes can be identified, and the accuracy of other cigarette carton specifications of uncertain specifications can be further improved through the identification mechanism based on feature matching and color features in the same package; this embodiment tested one thousand cigarette carton order verification package pictures, including five hundred packages with only QR codes and different specifications of cigarette pictures and five hundred packages with textures of cigarettes, and all pictures can match the orders. After many simulation experiments, the method of this embodiment was used for identification, and the matching pass rate of pictures and orders was increased from 76% to 97%, greatly improving the recognition rate of cigarette carton ends.

[0055] The embodiment is only a specific example and does not represent only one implementation mode of the present invention.

[0056] The above description is only the preferred embodiment of the present invention. It is known to those skilled in the art that various changes or equivalent substitutions may be made to these features and embodiments without departing from the spirit and scope of the present invention. In addition, under the teachings of the present invention, these features and embodiments may be modified to adapt to specific circumstances and materials without departing from the spirit and scope of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed herein, and all embodiments falling within the scope of the claims of this application belong to the protection scope of the present invention.

Claims

1. A method for cigarette identification, characterized in that: The following steps are involved: Acquire a cigarette end image in the image to be identified, and perform feature comparison between the cigarette end image and a calibration image to obtain a first cosine similarity; the calibration image is a cigarette end image of known specifications; Identifying whether the cigarette end image contains a QR code; If the cigarette end image contains the two-dimensional code, the two-dimensional code is decoded to obtain the specifications of the cigarette in the cigarette end image; If the cigarette end image does not contain the QR code, determining whether the first cosine similarity is greater than a first similarity threshold; If the first cosine similarity is greater than a first similarity threshold, then the cigarette end image and the cigarette in the calibration image are identified as being of the same specification; If the first cosine similarity is not greater than a first similarity threshold, the specification of the cigarette in the cigarette end image is obtained by performing feature comparison between the cigarette end image and the identified image; wherein the identified image is the cigarette end image of the determined specification obtained by decoding the first cosine similarity or the two-dimensional code; The obtaining of the specifications of the cigarette in the cigarette end image by comparing the features of the cigarette end image with the recognized image includes: Performing feature comparison between the cigarette end image and the recognized image to obtain a second cosine similarity; The cigarette end image and the cigarette in the recognized image whose second cosine similarity is greater than a second similarity threshold are associated as having the same specification.

2. A cigarette identification method according to claim 1, characterized in that: The method for identifying cigarette specifications also includes the following steps: Classifying the cigarette end images and the identified images associated with the same specification into the same similarity group; Constructing a color distinction model, and obtaining color scores of images in the similarity group having the same color through the color distinction model; The similarity group whose color score is greater than a third similarity threshold is obtained, and it is identified that the cigarette end image and the cigarette in the identified image are of the same specification.

3. A cigarette identification method according to claim 2, characterized in that: Constructing the color distinction model includes the following steps: Obtain N pairs of cigarette end samples and the color categories appearing in the labeled M categories of known specifications to construct a training sample set; wherein the cigarette end samples include images of cigarette end with uncertain specifications and images of cigarette end with certain specifications; The neural network is trained according to the training sample set to obtain the color distinction model.

4. A cigarette identification method according to claim 3, characterized in that: The color distinction model includes an input layer, an intermediate layer and an output layer; the input layer is used to receive the cigarette end image samples; the intermediate layer includes two resnet18 networks, which respectively receive the cigarette end image samples passing through the input layer; the output layer includes a concate layer, a fully connected layer and a sigmoid layer; the concate layer merges the outputs of the resnet18 networks in the channel dimension, converts them into an output node through the fully connected layer, and converts them into the color score by the sigmoid layer.

5. The method for cigarette identification according to claim 1, characterized in that: Decoding the two-dimensional code to obtain the specifications of the cigarette in the cigarette end image includes: Decode the QR code using the quirc module of the OpenCV library or the ZXing library to obtain the specification information website; The cigarette specification information corresponding to the specification information website is searched in the decoding mapping table to obtain the specifications of the cigarette in the cigarette end image; wherein, in the decoding mapping table, the cigarette specification information corresponds to the specification information website.

6. A cigarette identification method according to claim 5, characterized in that: The identifying whether the cigarette end image contains a QR code includes: A QR code detection module is used to identify whether the cigarette end image contains a QR code; wherein the QR code detection module is obtained by training a target detection model using multiple end sample images with QR codes and annotated QR code coordinates as a training set.

7. A cigarette identification method according to claim 1, characterized in that: Feature comparison is performed through a feature matching module, wherein a MobileNet model is used as the backbone network of the feature matching module.

8. A cigarette identification method according to claim 7, characterized in that: The formula for calculating the first cosine similarity and the second cosine similarity is: ,m=1,2,...,n; Wherein, a is the feature vector of the cigarette end image; is a feature vector of a comparison image, wherein the comparison image includes the calibration image and the recognized image.

9. A cigarette identification method according to claim 1, characterized in that: The step of obtaining the cigarette end image in the image to be identified includes: The cigarette end image in the image to be identified is obtained through an end detection module; wherein the end detection module is obtained by training a target detection model using multiple cigarette sample images and annotated end coordinates as a training set.