Medicine raw material label consistency comparison method, system, equipment and medium

Through the reconstructed Resnet18 network and SIFT key point matching algorithm, combined with edge computing, the accuracy and efficiency problems in the consistency comparison of label pictures of pharmaceutical raw materials are solved, and the accurate positioning and consistency measurement of label styles are achieved.

CN120472474AActive Publication Date: 2025-08-12INSPUR YUNZHOU (SHANDONG) IND INTERNET CO LTD

Patent Information

Application Number
CN202510540437.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-27
Publication Date
2025-08-12
Estimated Expiration
2045-04-27

AI Technical Summary

Technical Problem

The prior art cannot effectively process the complex characteristics of drug raw material label pictures, resulting in low consistency and efficiency, especially when the picture is deformed, rotated and positioned, and the similarity calculation method is easily affected, resulting in misjudgment.

Method used

The reconstructed Resnet18 network is used for feature extraction, combined with SIFT key point matching algorithm and edge calculation, and accurately position and measure the consistency of label images through preprocessing, feature vector calculation and similarity measurement.

Benefits of technology

It improves the accuracy and efficiency of label consistency comparison of pharmaceutical raw materials, can handle image deformation and rotation, reduce misjudgment, and achieve efficient label style judgment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120472474A_ABST
    Figure CN120472474A_ABST
Patent Text Reader

Abstract

The invention provides a medicine raw material label consistency comparison method, system and device and a medium, and belongs to the technical field of medicine raw material label identification. The edge server searches a local template library according to the template index based on the comparison picture, and obtains a template tag picture and a feature vector file; extracting a feature vector of a comparison label picture by using a reconstructed Resnet18 network, calculating the similarity between the feature vector of the template label picture and the feature vector of the comparison label picture, and obtaining a label consistency result of the template picture and the comparison picture; and carrying out result visualization display on the label consistency result. Through a traditional image processing algorithm and a deep learning network feature extraction technology, the verification workload is reduced, and the verification efficiency is improved. The feature vectors are extracted by using the reconstructed Resnet18 network, and the consistency of the tag styles can be accurately judged in combination with an SIFT key point matching algorithm.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of pharmaceutical raw material label identification, and in particular relates to a pharmaceutical raw material label consistency comparison method, system, equipment and medium. Background Art

[0002] Pharmaceutical raw materials or packaging materials are packed in cartons or cardboard barrels. After arriving at the warehouse of the pharmaceutical factory, warehouse staff are required to inspect the labels of drugs of the same variety, specification and batch, requiring that the label style and content of each piece remain consistent.

[0003] Current feature extraction methods may not fully capture the complex characteristics of pharmaceutical ingredient label images. Pharmaceutical ingredient packaging images can be deformed, rotated, and have labels positioned in an unstable manner. This makes it difficult to accurately locate the region corresponding to the template label image in the comparison image, impacting the accuracy and efficiency of consistency comparisons. Furthermore, similarity calculation methods, such as cosine similarity, cannot comprehensively measure the similarity between label images and are easily affected by factors such as feature vector dimension and data distribution, leading to misjudgments. Summary of the Invention

[0004] The present invention provides a method for comparing the consistency of drug raw material labels, which can accurately determine whether the label styles between a template image and a comparison image are consistent, thereby improving verification efficiency and accuracy.

[0005] Methods include: S1. Collect and save outer packaging pictures, and send the outer packaging pictures, picture indexes, and template indexes to the edge server in a form; S2. The edge server determines whether the current outer packaging image is a template image or a comparison image based on whether the template index in the form is empty. If the template index is empty, the current outer packaging image is a template image and the process proceeds to S3. Otherwise, the current outer packaging image is a comparison image and the process proceeds to S5. S3. Parse the template image based on a preset algorithm to obtain a standard template label image, name the template label image with the template index, and save it in a local template library in a preset format; S4. Use the reconstructed Resnet18 network to extract the feature vector of the template label image, name the template index, and save the feature vector of the template label image in the local template library as an npy format file; S5. Search the local template library according to the template index and obtain the template label image and feature vector file; S6. Obtaining a comparison label image that matches the template label image in the comparison image based on the SIFT key point matching algorithm; S7. Use the reconstructed Resnet18 network to extract the feature vector of the comparison label image, calculate the similarity between the feature vector of the template label image obtained in step S5 and the feature vector of the comparison label image, and compare them with a pre-set similarity threshold to obtain the label consistency result of the template image and the comparison image; S8. The label consistency results, image index, and template index are transmitted to the terminal device in a form for visual display of the results.

[0006] It should be further explained that step S2 specifically includes: Step S201: Receive and parse the uploaded form data, extract the outer packaging image, image index and template index fields, and verify the data format and integrity; Step S202: Check whether the template index field is empty. If it is empty, it is determined to be a template image and the template registration process is triggered. If it is not empty, it is determined to be a comparison image and the label comparison process is triggered to achieve automated process diversion; Step S203: Dynamically assign a processing path based on the determination result: generate a unique template index for the template image and bind the data, and then retrieve the associated template data through the index when comparing the image; Step S204: Generate a globally unique index for the template image, bind the index with the image data and the feature file for storage, and establish a multi-level association relationship of the index data.

[0007] It should be further explained that step S3 specifically includes: S301: Applying median filtering, bilateral filtering, and Gaussian filtering to the template image to smooth the template image, and converting the smoothed image into a grayscale template image; S302: Processing the grayscale template image using an edge detection algorithm based on the Scharr operator to obtain a binary template image; S303: Based on the binarized template image, apply a contour detection algorithm to screen qualified quadrilateral candidate boxes, and select the quadrilateral with the largest area as the coordinate box of the template label image; S304: Calculate the radial transformation matrix based on the coordinates of the four corner points of the template label image and the width and height of the preset label image, and apply the radial transformation algorithm to obtain a standard template label image on the template image.

[0008] It should be further explained that steps S4 and S7 use the reconstructed Resnet18 network to extract the feature vector of the label image, including the following process: S401: Preprocess the label image, adjust the image size, and give the label image , the preprocessing output is ; The preprocessing is expressed by the following formula:

[0009] in, The size is H , The size is ; S402: Reconstruct the forward reasoning process of the deep learning network Resnet18, load the model weights of the pre-trained Resnet18 under the Pytorch framework, and use the reconstructed Resnet18 network to extract feature maps of two different levels of the template label image; Feature extraction is expressed by the following formula:

[0010]

[0011] in, represents the model weight of the first layer of convolution, Represents the model weights at different levels, Represent feature maps at different levels; S403: Adaptively mean pool the feature maps of layer 2 and layer 3, flatten them according to the channel dimension, and then concatenate them to obtain the feature vector of the label image; The calculation of the eigenvector is expressed by the following formula:

[0012]

[0013]

[0014] in, Indicates that the feature map is processed in the channel dimension Adaptive global average pooling of represents the feature concatenation operation, Indicates that The feature map of size is flattened to ; Size , Size , Size .

[0015] It should be further explained that step S5 specifically includes: The template index is mapped to the bucket array of the Cuckoo filter through a double hash function. Each bucket stores the fingerprint of the index and the associated secondary index. When querying a template index, candidate positions in the bucket array are alternately probed. If the fingerprint matches, the associated secondary index is returned. If the probe path exceeds the threshold, the secondary retrieval process is triggered. High-frequency template indexes are preloaded into the memory cache based on the LRU strategy. The cache key is encoded using a combination of the index hash value and the timestamp. In step 5, a hash check is performed on the npy file in the local template library based on the hash value of the feature vector in the metadata. If the check fails, the data repair mechanism is triggered. If the check passes, the feature vector is loaded through the memory-mapped file. The loading method is based on parallel loading, loading the original image file and the feature vector file of the labeled image, and asynchronous prefetching is achieved through CUDA streams. The image data is decoded and normalized using OpenCL kernel functions. When it is detected that the same template index corresponds to multiple versions of feature vectors, the system starts comparing the template creation time stored locally based on the timestamp and hash value; If the timestamp difference is less than the preset time, the version with higher confidence is selected based on the cosine similarity of the feature vectors.

[0016] It should be further explained that step S6 specifically includes: S601: For template label images and comparison pictures , respectively apply SIFT detector , detect key feature points and feature descriptors ; Detecting key points and calculating feature descriptors are expressed by the following formula:

[0017]

[0018] S602: Based on the feature descriptors of the comparison image and the template label image, use the FLANN matcher Pairing of key points; based on the distance between key points , filter matching point pairs; The screening matching point pairs are expressed by the following formula:

[0019] in, is a pair of matching points, representing the coordinate sets of key points on the template label image and the comparison image, and they exist in pairs; S603: Calculate the homography matrix from the template label image to the comparison image based on the matching point pairs, and use the homography matrix to transform the coordinates of the four corner points of the template label image to obtain the coordinates of the four corner points of the label on the comparison image; The four corner points of the label on the comparison image are expressed by the following formula:

[0020]

[0021] in, Represents the formula for calculating the homography matrix, represents the application of the homography matrix, Represents the homography matrix of the template label image transformed to the comparison image, Represents the four corner points on the template label image, Indicates the four corner points on the comparison image; S604: Calculate an affine transformation matrix based on the coordinates of the four corner points of the label on the comparison image and the width and height of the preset label image, and use the radial transformation matrix to transform the coordinates of the four corner points of the label on the comparison image to obtain a standard comparison label image; The acquisition of the comparison label image is expressed by the following formula:

[0022]

[0023] in, To compare label images, represents the affine transformation matrix, Indicates the four corner points of the label image obtained based on width and height, Indicates the calculation method of the affine transformation matrix.

[0024] It should be further explained that step S7 specifically includes: S701: Use the reconstructed Resnet18 network to extract the feature vector of the comparison label image; S702: Calculate the similarity between the template label image feature vector obtained in step S5 and the comparison label image feature vector, including cosine similarity and structural similarity ; The similarity calculation is expressed by the following formula:

[0025]

[0026] in, Represents the cosine similarity calculation formula, Represents the structural similarity calculation formula, The feature vector representing the template label image, The feature vector representing the comparison label image; S703: According to cosine similarity and structural similarity Compare with the preset threshold to obtain the label image consistency result.

[0027] This application also provides a drug raw material label consistency comparison system, the system comprising: The image acquisition and storage module is used to collect and save the outer packaging pictures, and send the outer packaging pictures, picture indexes and template indexes in the form of a form to the edge server; The edge server is used to determine whether the current outer packaging image is a template image or a comparison image based on whether the template index in the form is empty. If the template index is empty, the current outer packaging image is a template image and the image parsing and saving module is executed; otherwise, it is a comparison image and the feature search module is executed; The image parsing and saving module is used to parse the template image based on a preset algorithm to obtain a standard template label image, and save the template label image in a preset format in the local template library with the template index name; The feature extraction module is used to extract the feature vector of the template label image using the reconstructed Resnet18 network, name the template index, and save the feature vector of the template label image in the local template library as an npy format file; Feature search module, used to search the local template library according to the template index and obtain the template label image and feature vector file; An image matching module is used to obtain a comparison label image that matches the template label image in the comparison image based on the SIFT key point matching algorithm; The image processing module is used to extract the feature vector of the comparison label image using the reconstructed Resnet18 network, calculate the similarity between the obtained template label image feature vector and the comparison label image feature vector, and compare it with a pre-set similarity threshold to obtain the label consistency result of the template image and the comparison image; The image display module is used to transmit the label consistency results, image index and template index in a form to the terminal device for visual display of the results.

[0028] According to another embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of the pharmaceutical raw material label consistency comparison method when executing the program.

[0029] According to another embodiment of the present application, a storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for comparing consistency of drug raw material labels are implemented.

[0030] It can be seen from the above technical solutions that the present invention has the following advantages: The pharmaceutical raw material label consistency comparison method provided by this invention uses a reconstructed ResNet18 network for feature extraction. The label image is preprocessed, resized, and normalized. The multi-layer convolution and pooling operations of the ResNet18 network are then used to extract feature maps at different levels. Finally, feature vectors are obtained through adaptive mean pooling and concatenation. This method fully learns the complex features of the label image, extracting representative and robust features for images under different conditions, thereby improving the accuracy of feature extraction. The SIFT keypoint matching algorithm is used to locate the comparison label image. The SIFT detector detects the key points and descriptors of the template label image and the comparison image. The FLANN matcher is then used to pair the key points, and matching point pairs are selected based on the metric distance. The homography matrix and affine transformation matrix are then calculated based on the matching point pairs to accurately locate the label in the comparison image and obtain a standard comparison label image. This method effectively handles various image deformations and rotations, accurately locates the label, and improves the accuracy and efficiency of label positioning. Cosine similarity and structural similarity are calculated simultaneously to measure the similarity between labeled images. Cosine similarity measures the angle between feature vectors, reflecting the directional consistency of these vectors; structural similarity focuses more on the structural information of the images, taking into account similarities in brightness, contrast, and structure. Combining these two measures comprehensively measures the similarity between images from different perspectives, improving the accuracy and reliability of consistency comparisons and reducing false positives.

[0031] Using edge computing, data collection, preprocessing, and some computing tasks are performed on edge servers. By sending the outer packaging image, image index, and template index in a form to the edge server, the edge server performs operations such as template label image parsing, feature vector extraction, comparison label image acquisition, and similarity calculation. The results are then sent to the terminal device for visualization. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] In order to more clearly illustrate the technical solution of the present invention, the following is a brief introduction to the drawings required for the description. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0033] Figure 1 This is a flow chart of the consistency comparison method for drug raw material labels; Figure 2 This is a schematic diagram of the drug raw material label consistency comparison system; Figure 3 Schematic diagram of an electronic device. DETAILED DESCRIPTION

[0034] The pharmaceutical raw material label consistency comparison method provided in this application reduces the verification workload and improves verification efficiency by combining traditional image processing algorithms and deep learning network feature extraction technology. By extracting feature vectors using a reconstructed Resnet18 network and combining it with the SIFT key point matching algorithm, it can accurately determine the consistency of label styles.

[0035] The following describes in detail the pharmaceutical raw material label consistency comparison method involved in this application. Specific details such as specific system structures and technologies are provided for illustration rather than limitation to facilitate a thorough understanding of the embodiments of this application. However, it should be clear to those skilled in the art that this application can also be implemented in other embodiments without these specific details.

[0036] It should be understood that when used in this specification, the term "comprising" indicates the presence of the described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or their collections. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized.

[0037] The phrases "one embodiment" or "some embodiments" described in this application mean that the specific features, structures, or characteristics described in the embodiment are included in one or more embodiments of the application. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in other embodiments," etc. that appear in different places in this application do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized.

[0038] In embodiments of the present invention, computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (exemplarily, via the Internet using an Internet service provider).

[0039] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0040] See also Figure 1 The figure is a flow chart of a method for comparing consistency of drug raw material labels in a specific embodiment, the method comprising: S1. Collect and save outer packaging pictures, and send the outer packaging pictures, picture indexes, and template indexes to the edge server in a form.

[0041] In this embodiment, a high-definition camera can be used to capture the outer packaging of the pharmaceutical raw materials. The captured images are saved according to certain naming rules, such as using timestamps, batch numbers, etc. as image indexes.

[0042] The template index is set based on the actual situation. If the template image is new, the template index can be left blank. If the image is for comparison, the corresponding template index is filled in. The image, image index, and template index are organized into a form and sent to the edge server via the network. This ensures the integrity and accuracy of the original data. Furthermore, data transmission in a form-based format improves data transmission efficiency.

[0043] S2. The edge server determines whether the current outer packaging image is a template image or a comparison image based on whether the template index in the form is empty. If the template index is empty, the current outer packaging image is a template image and enters S3. Otherwise, it is a comparison image and enters S5.

[0044] After receiving the form data, the edge server of this embodiment checks the template index field. A conditional statement, which can be implemented through programming, determines whether the template index is a string type and has a length of 0. If so, it is determined to be a template image; otherwise, it is determined to be a comparison image.

[0045] It's important to note that the template image serves as a standard reference and doesn't need to be associated with other templates, so the template index is empty. The comparison image must be compared with a specific template image and carries the corresponding template index. This method allows for image classification, enabling automatic image classification and improving processing efficiency.

[0046] As an embodiment of the present application, step S201: receiving and parsing the uploaded form data, extracting the outer packaging image, image index and template index fields, and verifying the data format and integrity.

[0047] This embodiment can parse the form content through a preset HTTP interface to extract key fields, including the binary data of the outer packaging image, the image index, and the template index. The extracted fields are format-checked to ensure the integrity of the image data and the legality of the template index format. The legality of the template index format can be determined based on the length of the string and the character type.

[0048] Step S202: Check whether the template index field is empty. If it is empty, it is determined to be a template image and the template registration process is triggered. If it is not empty, it is determined to be a comparison image and the label comparison process is triggered to achieve automated process diversion.

[0049] Here, a string processing function is called to check whether the template index field is empty, such as an empty string, null, or undefined. If it is, the current outer packaging image is determined to be the first uploaded template image, triggering the template registration process and entering S3. If it is not empty, the current outer packaging image is determined to be a sample image to be compared, triggering the label comparison process and entering S5.

[0050] Step S203: Dynamically allocate a processing path based on the determination result: generate a unique template index for the template image and bind the data, and retrieve the associated template data through the index when comparing the image.

[0051] In this embodiment, the dynamic allocation of processing paths for the judgment results can automatically generate a new template index, such as using a hash algorithm or UUID to generate a unique identifier and bind it to the current image index. The template index is then backfilled into the form to ensure a strong correlation between subsequent template data storage and the index. Based on the template index, the corresponding template label image and feature vector file are quickly retrieved from the local template library to ensure the accuracy of the data source comparison.

[0052] Step S204: Generate a globally unique index for the template image, bind the index with the image data and the feature file for storage, and establish a multi-level association relationship of the index data.

[0053] It should be noted that a globally unique template index is generated using a combination of timestamp, device ID, and random number to avoid index conflicts. A mapping relationship is established between the generated template index and the current image index and written to the local database, allowing subsequent comparison processes to trace back to the original template data through the template index.

[0054] As can be seen, the empty / non-empty status of the template index automatically triggers different processing branches, eliminating the need to specify the image type and reducing interaction complexity. This enables autonomous process diversion, avoiding confusion caused by operational errors and improving verification efficiency. Field parsing, index generation, and process allocation are completed on the edge server, reducing cloud communication latency and supporting high-concurrency scenarios.

[0055] S3. Parse the template image based on a preset algorithm to obtain a standard template label image, name the template label image with the template index, and save it in a local template library in a preset format.

[0056] Step S3 specifically includes the following steps: S301: Apply median filtering, bilateral filtering and Gaussian filtering to the template image to smooth the template image, and convert the smoothed image into a grayscale template image.

[0057] In some embodiments, median filtering replaces the grayscale value of each pixel in the template image with the median grayscale value of the pixels in the neighborhood of that point, which can effectively remove impulse noise such as salt and pepper noise. Bilateral filtering not only considers the spatial distance relationship between pixels, but also the similarity between pixel values. It can better preserve edge information while smoothing the image. Gaussian filtering performs weighted averaging on the image based on the Gaussian function, and controls the degree of smoothing by adjusting the size and standard deviation of the Gaussian kernel, which can effectively remove Gaussian noise. Converting the smoothed color image into a grayscale image is to convert the RGB value of each pixel of the color image into a grayscale value according to a certain weighted formula. This can convert the image from a three-dimensional color space to a one-dimensional grayscale space, which is convenient for subsequent processing.

[0058] S302: For the grayscale template image, an edge detection algorithm based on the Scharr operator is used to obtain a binary template image.

[0059] In this embodiment, the Scharr operator in the horizontal direction is: d / dx = [-3, 0, 3; -10, 0, 10; -3,0, 3]. The vertical direction is: d / dy = [-3, -10, -3; 0, 0, 0; 3, 10, 3]. The calculated gradient amplitude is: Gradient = sqrt((dx)^2 + (dy)^2).

[0060] Binarization can be performed using the Otsu algorithm for automatic threshold segmentation, converting the gradient magnitude image into a binary image. The absolute values of the two gradient images are added together to produce a composite gradient image. Finally, the composite gradient image is binarized based on a set threshold. Pixels with gradient values greater than the threshold are set to white, indicating edges, and pixels with gradient values less than the threshold are set to black, indicating non-edges, thus producing a binary template image.

[0061] S303: Based on the binarized template image, apply a contour detection algorithm to screen qualified quadrilateral candidate boxes, and select the quadrilateral with the largest area as the coordinate box of the template label image.

[0062] In some embodiments, the contour detection algorithm is based on the binary information of the image and finds the contour by tracing the boundaries of the black and white areas in the image. When judging the quadrilateral, the geometric characteristics of the quadrilateral are used, that is, it has four vertices. The selection of the quadrilateral with the largest area is based on the prior knowledge of the relative size and position of the drug raw material label in the image, and it is believed that the label usually occupies a large area and has a relatively regular quadrilateral shape. Through contour detection and screening, the area in the template image that may contain the drug raw material label can be accurately located, eliminating other irrelevant edges and noise interference in the image.

[0063] S304: Calculate the radial transformation matrix based on the coordinates of the four corner points of the template label image and the width and height of the preset label image, and apply the radial transformation algorithm to obtain a standard template label image on the template image.

[0064] In this example, the four vertices of the quadrilateral coordinate box are arranged in the order [top-left, top-right, bottom-right, bottom-left]. The cv2.getPerspectiveTransform function is used to map the original quadrilateral to a standard rectangle of a preset size. This preset size must be consistent with the size of the label in the template library. Use cv2.warpPerspective to perform the transformation and generate a standardized template label image.

[0065] As can be seen, the radiometric transformation can perform operations such as translation, rotation, scaling, and shearing on images. By calculating the radiometric transformation matrix, the coordinate frame of the template label image is mapped to the preset standard label size and orientation, thereby transforming the label area in the template image into a standard form. This allows label images of different shooting angles and sizes to be analyzed and compared under the same standard in subsequent processing, improving the accuracy and reliability of the comparison.

[0066] S4. Use the reconstructed Resnet18 network to extract the feature vector of the template label image, name the template index, and save the feature vector of the template label image in the local template library as an npy format file.

[0067] In this embodiment, steps S4 and S7 use the reconstructed Resnet18 network to extract the feature vector of the label image, including the following process: S401: Preprocess the label image, adjust the image size, and give the label image , the preprocessing output is ; The preprocessing is expressed by the following formula:

[0068] in, The size is H , The size is .

[0069] As can be seen, the ToTensor operation converts the image data into a tensor format suitable for processing by deep learning models. The Resize operation adjusts the size of the image to meet the requirements of subsequent network input, usually uniformly adjusting the image to the fixed size expected by the network to facilitate model processing. The Normalize operation normalizes the image data and maps the pixel values to a specific range, which helps to speed up the convergence of the model and improve the stability and generalization ability of the model. Through these preprocessing operations, labeled images of different sizes and pixel value ranges can be converted to a unified format and size, allowing subsequent deep learning models to effectively process these image data and improve the accuracy and efficiency of the model.

[0070] S402: Reconstruct the forward reasoning process of the deep learning network Resnet18, load the model weights of the pre-trained Resnet18 under the Pytorch framework, and use the reconstructed Resnet18 network to extract feature maps of two different levels of the template label image; Feature extraction is expressed by the following formula:

[0071]

[0072] in, represents the model weight of the first layer of convolution, Represents the model weights at different levels, Represents feature maps at different levels.

[0073] In this embodiment, ResNet-18 automatically learns image feature representations through a multi-layered architecture consisting of convolutional layers, pooling layers, and residual connections. The pre-trained model weights have been learned on a large-scale image dataset and contain rich image feature information. During the reconstructed forward inference process, the input image data is subjected to operations such as convolution with these model weights to gradually extract feature maps at different levels. This reduces model training time and data requirements while extracting representative and robust image features.

[0074] S403: Adaptively mean pool the feature maps of layer 2 and layer 3, flatten them according to the channel dimension, and then concatenate them to obtain the feature vector of the label image; The calculation of the eigenvector is expressed by the following formula:

[0075]

[0076]

[0077] in, Indicates that the feature map is processed in the channel dimension Adaptive global average pooling of represents the feature concatenation operation, Indicates that The feature map of size is flattened to ; Size , Size , Size .

[0078] Adaptive mean pooling performs 1×1 adaptive global average pooling on the channel dimension of the feature map. It converts feature maps of different sizes into fixed-length vector representations while preserving important information in the channel dimension. Flattening converts multidimensional feature maps into one-dimensional vectors, facilitating subsequent calculations and processing. Concatenation combines feature vectors from different levels to form a comprehensive feature vector that fully describes the characteristics of the labeled image.

[0079] As can be seen, compared to traditional methods, this embodiment typically uses only the features output by the fully connected layer, resulting in loss of detail or semantic information. Based on cross-layer fusion, it can simultaneously utilize mid-level detail features and high-level semantic features to enhance the representational capabilities of features. The feature map of each channel is compressed into a scalar, generating a low-dimensional dense vector while preserving the channel response strength. This reduces the dimension of the feature vector and reduces the comparison calculation time from 15ms to 0.5ms.

[0080] This embodiment uses ImageNet pre-training knowledge to adapt the pre-trained model and optimize edge processing, retaining and reorganizing only the intermediate convolutional layers to avoid training and reduce computational load. Real-time processing is achieved on the edge server without the need to annotate drug label data. Through resizing, tensor conversion, and ImageNet normalization, the input distribution is forced to align with the pre-trained model. The robustness of the feature vector to lighting and deformation is improved, and the standard deviation of the feature cosine similarity under different shooting conditions of the same label is reduced from 0.12 to 0.03.

[0081] S5. Search the local template library according to the template index and obtain the template label image and feature vector file.

[0082] In this embodiment, based on the multi-level index mapping of the Cuckoo filter, the template index is mapped to the Cuckoo filter's bucket array using a double hash function. Each bucket stores the index's fingerprint and the associated secondary index. When querying a template index, candidate positions in the bucket array are alternately probed. If the fingerprint matches, the associated secondary index is returned. If the probe path exceeds a threshold, the secondary search process is triggered. High-frequency template indexes are preloaded into the memory cache based on the LRU strategy. The cache key is encoded using a combination of the index hash value and the timestamp.

[0083] This embodiment also involves performing a hash check on the npy file in the local template library based on the hash value of the feature vector in the metadata. If the check fails, a data repair mechanism is triggered; if the check passes, the feature vector is loaded through the memory mapping file.

[0084] In this embodiment, a hash value is calculated and written to the log block when each feature vector file is generated. During verification, the Merkle tree is used to quickly locate the data block, ensuring that the feature vector has not been tampered with. This embodiment loads the original image file and feature vector file of the template label image in parallel, implementing asynchronous prefetching of GPU memory through CUDA streams. OpenCL kernel functions are used to decode and normalize the image data.

[0085] When the same template index is detected with feature vectors for multiple versions, version arbitration logic based on timestamps and hash values is activated. The template creation time recorded in the locally stored version_meta.json is compared. If the timestamp difference is less than 5ms, the version with higher confidence is selected based on the cosine similarity of the feature vectors. If there is a conflict, the distributed lock mechanism is triggered to block subsequent operations until the master node completes the version merge.

[0086] It can be seen that this embodiment forms a complete link of index positioning, data verification, resource loading, and conflict resolution, solving the problem of false detection caused by version conflicts or data corruption in traditional solutions.

[0087] S6. Obtain a comparison label image that matches the template label image in the comparison image based on the SIFT key point matching algorithm.

[0088] Step S6 specifically includes: S601: For template label images and comparison pictures , respectively apply SIFT detector , detect key feature points and feature descriptors ; Detecting key points and calculating feature descriptors are expressed by the following formula:

[0089]

[0090] In this embodiment, the SIFT detector is an algorithm for detecting key points in an image and calculating their feature descriptors. The template label image T_temp and the comparison image I_comp are input into the SIFT detector SIFTDetector(*) . The detector searches for key points in the image that are scale- and rotation-invariant. These key points are typically corners, edges, or other points with unique features. At the same time, a feature descriptor is calculated for each key point. This descriptor is a vector that describes the characteristics of the image area surrounding the key point.

[0091] S602: Based on the feature descriptors of the comparison image and the template label image, use the FLANN matcher Pairing of key points; based on the distance between key points , filter matching point pairs; The screening matching point pairs are expressed by the following formula:

[0092] in, are matching point pairs, representing the coordinate sets of key points on the template label image and the comparison image, and they exist in pairs.

[0093] The FLANN matcher in this embodiment is used to pair keypoints based on the feature descriptors of the template label image and the comparison image. Matching point pairs are determined by searching for the nearest neighbor in the feature descriptor space. Matching point pairs are filtered based on the distance metric between keypoints, distance_select(*), retaining only those with a distance less than a certain threshold as valid matches. The FLANN matcher can quickly find matching point pairs between feature descriptors, improving matching efficiency.

[0094] S603: Calculate the homography matrix from the template label image to the comparison image based on the matching point pairs, and use the homography matrix to transform the coordinates of the four corner points of the template label image to obtain the coordinates of the four corner points of the label on the comparison image; The four corner points of the label on the comparison image are expressed by the following formula:

[0095]

[0096] in, Represents the formula for calculating the homography matrix, represents the application of the homography matrix, Represents the homography matrix of the template label image transformed to the comparison image, Represents the four corner points on the template label image, Indicates comparing the four corner points on the image.

[0097] The calculation of the homography matrix in this embodiment is based on the coordinate information of the matching point pairs and is obtained by solving a set of linear equations. The points on the template label image can be mapped to the corresponding points on the comparison image through a projection transformation, taking into account the relationship between the rotation, translation, scaling and perspective transformation of the images. By calculating the homography matrix, the corresponding position of the template label image on the comparison image can be accurately found. Even if there is a certain perspective change, scaling or rotation between the two images, they can be aligned through this matrix.

[0098] S604: Calculate an affine transformation matrix based on the coordinates of the four corner points of the label on the comparison image and the width and height of the preset label image, and use the radial transformation matrix to transform the coordinates of the four corner points of the label on the comparison image to obtain a standard comparison label image; The acquisition of the comparison label image is expressed by the following formula:

[0099]

[0100] in, To compare label images, represents the affine transformation matrix, Indicates the four corner points of the label image obtained based on width and height, Indicates the calculation method of the affine transformation matrix.

[0101] This embodiment compares the coordinates of the four corner points of the label on the image And the width and height of the preset label image , use the GetPerspectiveTransform(*) function to calculate the affine transformation matrix matrix_trans. This affine transformation matrix is used to transform the coordinates of the four corner points of the label on the image. The WarpPerspective(*) function then resamples and interpolates the image based on the affine transformation matrix to achieve the image transformation. This makes subsequent feature extraction and consistency comparison of the label image more accurate and reliable. The uniform size and shape facilitates feature vector calculation and comparison, eliminating interference caused by varying label positions and shapes, and improving comparison accuracy and efficiency.

[0102] After introducing the drug label consistency comparison method in steps S601 to S604, the true shape of the label is restored using the homography matrix, and the size and perspective are normalized using an affine transformation. This reduces the label positioning error from ±15 pixels with traditional methods to ±3 pixels. FLANN acceleration and RANSAC denoising improve the reliability of geometric transformations. Affine transformation driven by preset width and height dynamically adjusts the output based on the preset label size, preserving the proportions of the label content. This reduces the deformation rate of the label content.

[0103] S7. Use the reconstructed Resnet18 network to extract the feature vector of the comparison label image, calculate the similarity between the feature vector of the template label image obtained in step S5 and the feature vector of the comparison label image, and compare them with the pre-set similarity threshold to obtain the label consistency result of the template image and the comparison image.

[0104] Step S7 specifically includes: S701: Use the reconstructed Resnet18 network to extract the feature vector of the comparison label image.

[0105] This example uses the ResNet18-CPCA model and embeds a CPCA attention module within the residual block. Channel features are extracted through global average pooling and max pooling, and channel weights are generated through an MLP. Spatial weights are calculated by calculating the mean and maximum values of the feature maps. Finally, a sigmoid filter is used to fuse the channel and spatial attention to generate a weighted feature map.

[0106] It can be seen that after inputting the standardized comparison label image T_comp, multi-level features are extracted through layer2 and layer3: feature2 = model_layer2(model_layer1(model_conv_7X7(T_comp))) feature3 = model_layer3(feature2) The feature vector vectors_comp (size 384×1) is generated through adaptive average pooling (AdapAvgPool) and concatenation. The attention mechanism reduces background interference and improves sensitivity to subtle differences. Transfer learning based on pre-trained weights reduces the time and data required for training from scratch.

[0107] S702: Calculate the similarity between the template label image feature vector obtained in step S5 and the comparison label image feature vector, including cosine similarity and structural similarity ; The similarity calculation is expressed by the following formula:

[0108]

[0109] in, Represents the cosine similarity calculation formula, Represents the structural similarity calculation formula, The feature vector representing the template label image, A feature vector representing the comparison label image.

[0110] The cosine similarity of this embodiment judges similarity based on the direction of the vector, without considering the length of the vector. In the feature vector space, if the directions of two feature vectors are similar, it means that the images represented have high similarity in features. It can comprehensively measure the similarity between the template label image and the comparison label image from different angles. Cosine similarity can quickly give a preliminary similarity judgment based on the direction of the vector, while structural similarity can more carefully consider the actual structural information of the image, making up for the shortcomings of cosine similarity.

[0111] S703: According to cosine similarity and structural similarity Compare with the preset threshold to obtain the label image consistency result.

[0112] This embodiment uses a threshold to determine the similarity calculation results, transforming numerical similarity metrics into practical judgment results. The threshold acts as a standard; when the similarity reaches or exceeds this threshold, the images are considered sufficiently similar, resulting in consistent labels. Otherwise, differences are considered present, resulting in inconsistent labels. This simple and intuitive method effectively translates similarity calculation results into practical application conclusions.

[0113] After this application introduces steps S701 to S703 into the drug label consistency comparison method, cosine similarity captures global semantic differences, and structural similarity detects local statistical anomalies, forming a complementary relationship. Dual-modal fusion reduces the false detection rate compared to single cosine similarity. Structural similarity is calculated on deep feature vectors, inheriting the model's robustness to geometric changes while reducing the amount of calculation. The time consumption of feature domain SSIM calculation is reduced from 15ms in the pixel domain to 0.2ms. The collaborative design of multimodal similarity fusion, feature domain SSIM calculation and dynamic threshold mechanism solves the problems of single indicator limitations, calculation redundancy and lack of flexibility in traditional methods.

[0114] S8. The label consistency results, image index, and template index are transmitted to the terminal device in a form for visual display of the results.

[0115] This embodiment organizes the tag consistency results, image indexes, and template indexes into a form and sends it to a terminal device, which can also be an electronic device, via the HTTP protocol. The electronic device can be a computer, mobile phone, or other device. A corresponding application or webpage is developed on the electronic device to parse and display the form data, for example, in a table or chart format. This allows users to intuitively understand the tag consistency comparison results.

[0116] Based on the above examples, in order to further improve the reliability of the drug raw material label consistency comparison method provided in the above examples, the following is a specific implementation method. In this example, a pharmaceutical company needs to perform consistency comparison on the labels of its "XX tablets" raw material drug to ensure that the new batch of labels is consistent with the original template. The following is the full implementation process: Step S1: Capture an image of the outer packaging. The quality inspector uses an industrial camera to capture the full front view of a new batch of medicine boxes, saves it as IMG_20250420_001.jpg, and records the batch number BATCH_202504. The image, image index IMG_20250420_001, and template index (null value) are sent to the edge server.

[0117] Step S2: Edge server classification. If the template index is empty, it is determined to be a template image and proceeds to S3. This triggers the template processing flow and assigns feature extraction.

[0118] Step S3: Template label parsing. Use the Canny algorithm to identify the label border and locate the coordinates (x=100, y=150). Generate TMPL_20250420.jpg (200x200 pixels) and save it to the template library. Name the file with the template index TMPL_20250420.

[0119] Step S4: Feature vector extraction. Use the pre-trained CSP-ResNet18, input TMPL_20250420.jpg, and output a 128-dimensional feature vector. Save it as TMPL_20250420.npy, with the hash value SHA-256 = abc123.

[0120] New batch label check: S1: Capture a new image, IMG_20250427_002.jpg, containing the template index TMPL_20250420. S2: Verify the template index is not empty and proceed to S5. S5: Search the template library and load TMPL_20250420.jpg and the .npy file. S6: Perform SIFT matching on the labeled regions in the image and crop COMPARE_20250427.jpg. S7: Extract the alignment feature vectors and calculate a cosine similarity of 0.92 (greater than the threshold of 0.9), determining consistency. S8: Return the results to the terminal, displaying "Consistent" and overlaying the annotations of the difference areas.

[0121] Example of exception handling: Suppose a batch of labels has font color deviation: S7: The similarity is 0.88, which is below the threshold. S8: The result is marked "inconsistent", triggering manual review. If the label printing deviation is found, the production line will be suspended for adjustment.

[0122] This example achieves efficient and accurate label consistency comparison through standardized data collection, intelligent classification, deep feature extraction, and visual feedback. The entire process from template creation to result feedback is fully automated, meeting drug regulatory requirements for data traceability and accuracy.

[0123] The following is an embodiment of the pharmaceutical raw material label consistency comparison system provided by the embodiments of the present disclosure. This system and the pharmaceutical raw material label consistency comparison method of the above-mentioned embodiments belong to the same inventive concept. For details not fully described in the embodiments of the pharmaceutical raw material label consistency comparison system, please refer to the embodiments of the above-mentioned pharmaceutical raw material label consistency comparison method.

[0124] like Figure 2 As shown, the system includes: an image acquisition and storage module, which is used to acquire and save outer packaging pictures, and send the outer packaging pictures, picture indexes and template indexes in a form to the edge server.

[0125] The edge server is used to determine whether the current outer packaging image is a template image or a comparison image based on whether the template index in the form is empty. If the template index is empty, the current outer packaging image is a template image and the image parsing and saving module is executed. Otherwise, it is a comparison image and the feature search module is executed.

[0126] The image parsing and saving module is used to parse the template image based on a preset algorithm to obtain a standard template label image, and save the template label image in a preset format in the local template library with the template index name.

[0127] The feature extraction module is used to extract the feature vector of the template label image using the reconstructed Resnet18 network, name the template index, and save the feature vector of the template label image in the local template library as an npy format file.

[0128] The feature search module is used to search the local template library according to the template index and obtain the template label image and feature vector file.

[0129] The image matching module is used to obtain a comparison label image that matches the template label image in the comparison image based on the SIFT key point matching algorithm.

[0130] The image processing module is used to extract the feature vector of the comparison label image using the reconstructed Resnet18 network, calculate the similarity between the obtained template label image feature vector and the comparison label image feature vector, and compare it with a pre-set similarity threshold to obtain the label consistency result of the template image and the comparison image.

[0131] The image display module is used to transmit the label consistency results, image index and template index in a form to the terminal device for visual display of the results.

[0132] like Figure 3 As shown, the present application also provides an electronic device, including a display module 103, a memory 102, a processor 101, and a computer program stored in the memory and executable on the processor 101. When the processor 101 executes the program, the steps of the power transmission engineering GIM model parsing and loading method are implemented.

[0133] In the embodiments of the present invention, electronic devices include, but are not limited to, laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. Electronic devices may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the embodiments of the present application described and / or claimed herein.

[0134] In the embodiment of the present application, the processor 101 can be implemented by using at least one of an application-specific integrated circuit (ASIC), a programmable logic device (PLD), a field programmable gate array (FPGA), a processor, a controller, a microcontroller, a microprocessor, and an electronic unit designed to perform the functions described herein. In some cases, such an embodiment can be implemented in a controller. For software implementation, an embodiment such as a process or function can be implemented with a separate software module that allows the execution of at least one function or operation. The software code can be implemented by a software application (or program) written in any appropriate programming language, and the software code can be stored in a memory and executed by a controller.

[0135] The display module 103 is used to display information input by the user or information provided to the user. The display module 103 may include a display panel, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc.

[0136] The memory 102 can be used to store software programs and various data. The memory 102 can include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.

[0137] The present application also provides a storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the pharmaceutical raw material label consistency comparison method.

[0138] The storage medium can be any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0139] In the context of storage media, a readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transfer a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0140] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not limited to the embodiments shown herein but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for comparing the consistency of drug raw material labels, characterized in that the method include: S1. Collect and save outer packaging pictures, and send the outer packaging pictures, picture indexes, and template indexes to the edge server in a form; S2. The edge server determines whether the current outer packaging image is a template image or a comparison image based on whether the template index in the form is empty. If the template index is empty, the current outer packaging image is a template image and the process proceeds to S3. Otherwise, the current outer packaging image is a comparison image and the process proceeds to S5. S3. Parse the template image based on a preset algorithm to obtain a standard template label image, name the template label image with the template index, and save it in a local template library in a preset format; S4. Use the reconstructed Resnet18 network to extract the feature vector of the template label image, name the template index, and save the feature vector of the template label image in the local template library as an npy format file; S5. Search the local template library according to the template index and obtain the template label image and feature vector file; S6. Obtaining a comparison label image that matches the template label image in the comparison image based on the SIFT key point matching algorithm; S7. Use the reconstructed Resnet18 network to extract the feature vector of the comparison label image, calculate the similarity between the feature vector of the template label image obtained in step S5 and the feature vector of the comparison label image, and compare them with a pre-set similarity threshold to obtain the label consistency result of the template image and the comparison image; S8. The label consistency results, image index, and template index are transmitted to the terminal device in a form for visual display of the results.

2. The method for comparing consistency of drug raw material labels according to claim 1, characterized in that: Step S2 specifically includes: Step S201: Receive and parse the uploaded form data, extract the outer packaging image, image index and template index fields, and verify the data format and integrity; Step S202: Check whether the template index field is empty. If it is empty, it is determined to be a template image and the template registration process is triggered. If it is not empty, it is determined to be a comparison image and the label comparison process is triggered to achieve automated process diversion; Step S203: Dynamically assign a processing path based on the determination result: generate a unique template index for the template image and bind the data, and then retrieve the associated template data through the index when comparing the image; Step S204: Generate a globally unique index for the template image, bind the index with the image data and the feature file for storage, and establish a multi-level association relationship of the index data.

3. The method for comparing consistency of drug raw material labels according to claim 1, characterized in that: Step S3 specifically includes: S301: Applying median filtering, bilateral filtering, and Gaussian filtering to the template image to smooth the template image, and converting the smoothed image into a grayscale template image; S302: Processing the grayscale template image using an edge detection algorithm based on the Scharr operator to obtain a binary template image; S303: Based on the binarized template image, apply a contour detection algorithm to screen qualified quadrilateral candidate boxes, and select the quadrilateral with the largest area as the coordinate box of the template label image; S304: Calculate the radial transformation matrix based on the coordinates of the four corner points of the template label image and the width and height of the preset label image, and apply the radial transformation algorithm to obtain a standard template label image on the template image.

4. The method for comparing consistency of drug raw material labels according to claim 1, characterized in that: Steps S4 and S7 use the reconstructed Resnet18 network to extract the feature vector of the label image. The following processes are included: S401: Preprocess the label image, adjust the image size, and give the label image , the preprocessing output is ; The preprocessing is expressed by the following formula: in, The size is H , The size is ; S402: Reconstruct the forward reasoning process of the deep learning network Resnet18, load the model weights of the pre-trained Resnet18 under the Pytorch framework, and use the reconstructed Resnet18 network to extract feature maps of two different levels of the template label image; Feature extraction is expressed by the following formula: in, represents the model weight of the first layer of convolution, Represents the model weights at different levels, Represent feature maps at different levels; S403: Adaptively mean pool the feature maps of layer 2 and layer 3, flatten them according to the channel dimension, and then concatenate them to obtain the feature vector of the label image; The calculation of the eigenvector is expressed by the following formula: in, Indicates that the feature map is processed in the channel dimension Adaptive global average pooling of represents the feature concatenation operation, Indicates that The feature map of size is flattened to ; Size , Size , Size .

5. The method for comparing consistency of drug raw material labels according to claim 1, characterized in that: Step S5 specifically includes: The template index is mapped to the bucket array of the Cuckoo filter through a double hash function. Each bucket stores the fingerprint of the index and the associated secondary index. When querying a template index, candidate positions in the bucket array are alternately probed. If the fingerprint matches, the associated secondary index is returned. If the probe path exceeds the threshold, the secondary retrieval process is triggered. High-frequency template indexes are preloaded into the memory cache based on the LRU strategy. The cache key is encoded using a combination of the index hash value and the timestamp. In step 5, a hash check is performed on the npy file in the local template library based on the hash value of the feature vector in the metadata. If the check fails, the data repair mechanism is triggered. If the check passes, the feature vector is loaded through the memory-mapped file. The loading method is based on parallel loading, loading the original image file and the feature vector file of the labeled image, and asynchronous prefetching is achieved through CUDA streams. The image data is decoded and normalized using OpenCL kernel functions. When it is detected that the same template index corresponds to multiple versions of feature vectors, the system starts comparing the template creation time stored locally based on the timestamp and hash value; If the timestamp difference is less than the preset time, the version with higher confidence is selected based on the cosine similarity of the feature vectors.

6. The method for comparing consistency of drug raw material labels according to claim 1, characterized in that: Step S6 specifically includes: S601: For template label images and comparison pictures , respectively apply SIFT detector , detect key feature points and feature descriptors ; Detecting key points and calculating feature descriptors are expressed by the following formula: S602: Based on the feature descriptors of the comparison image and the template label image, use the FLANN matcher Pairing of key points; based on the distance between key points , filter matching point pairs; The screening matching point pairs is expressed by the following formula: in, is a pair of matching points, representing the coordinate sets of key points on the template label image and the comparison image, and they exist in pairs; S603: Calculate the homography matrix from the template label image to the comparison image based on the matching point pairs, and use the homography matrix to transform the coordinates of the four corner points of the template label image to obtain the coordinates of the four corner points of the label on the comparison image; The four corner points of the label on the comparison image are expressed by the following formula: in, Represents the formula for calculating the homography matrix, represents the application of the homography matrix, Represents the homography matrix of the template label image transformed to the comparison image, Represents the four corner points on the template label image, Indicates the four corner points on the comparison image; S604: Calculate an affine transformation matrix based on the coordinates of the four corner points of the label on the comparison image and the width and height of the preset label image, and use the radial transformation matrix to transform the coordinates of the four corner points of the label on the comparison image to obtain a standard comparison label image; Obtaining the comparison label image is expressed by the following formula: in, To compare label images, represents the affine transformation matrix, Indicates the four corner points of the label image obtained based on width and height, Indicates the calculation method of the affine transformation matrix.

7. The method for comparing consistency of pharmaceutical raw material labels according to claim 1, characterized in that: Step S7 specifically includes: S701: Use the reconstructed Resnet18 network to extract the feature vector of the comparison label image; S702: Calculate the similarity between the template label image feature vector obtained in step S5 and the comparison label image feature vector, including cosine similarity and structural similarity ; The similarity calculation is expressed by the following formula: in, Represents the cosine similarity calculation formula, Represents the structural similarity calculation formula, The feature vector representing the template label image, The feature vector representing the comparison label image; S703: According to cosine similarity and structural similarity Compare with the preset threshold to obtain the label image consistency result.

8. A pharmaceutical raw material label consistency comparison system, characterized by: The system is used to implement the pharmaceutical raw material label consistency comparison method according to any one of claims 1 to 7; The system includes: The image acquisition and storage module is used to collect and save the outer packaging pictures, and send the outer packaging pictures, picture indexes and template indexes in the form of a form to the edge server; The edge server is used to determine whether the current outer packaging image is a template image or a comparison image based on whether the template index in the form is empty. If the template index is empty, the current outer packaging image is a template image and the image parsing and saving module is executed; otherwise, it is a comparison image and the feature search module is executed; The image parsing and saving module is used to parse the template image based on a preset algorithm to obtain a standard template label image, and save the template label image in a preset format in the local template library with the template index name; The feature extraction module is used to extract the feature vector of the template label image using the reconstructed Resnet18 network, name the template index, and save the feature vector of the template label image in the local template library as an npy format file; Feature search module, used to search the local template library according to the template index and obtain the template label image and feature vector file; An image matching module is used to obtain a comparison label image that matches the template label image in the comparison image based on the SIFT key point matching algorithm; The image processing module is used to extract the feature vector of the comparison label image using the reconstructed Resnet18 network, calculate the similarity between the obtained template label image feature vector and the comparison label image feature vector, and compare it with a pre-set similarity threshold to obtain the label consistency result of the template image and the comparison image; The image display module is used to transmit the label consistency results, image index and template index in a form to the terminal device for visual display of the results.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the pharmaceutical raw material label consistency comparison method as described in any one of claims 1 to 7 are implemented.

10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the pharmaceutical raw material label consistency comparison method as described in any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Video index tag setting method and apparatus, and server

    CN107679227A

  • Workbin label key information comparison method based on deep learning

    CN118691859A

  • Commodity label printing character detection method and system based on PaddleOCR

    CN119888774A

  • Two-dimensional code label Anti-counterfeiting identification system and method based on smart phone

    WO2014019293A1

  • Control method and device based on image recognition

    WO2020237480A1

Cited By

  • Plate identification method

    CN121121294A

  • Intelligent checking method, system and equipment for medicine outer package label information and medium

    CN121661654A

  • Medicine outer package label information intelligent checking method, system, device and medium

    CN121661654B

  • Chemical medicine warehousing method and warehousing system

    CN121745817A