Reagent bottle identification method and system

By clearing and binarizing the surface image of the reagent bottle, determining and correcting the label area, acquiring standard label images and text detection, the image distortion problem caused by the arc surface extension of the reagent bottle label is solved, and the accuracy and efficiency of reagent bottle recognition are improved.

CN119850931AActive Publication Date: 2025-04-18JIANGXI YIZHICHU MEDICAL PATHOLOGICAL DIAGNOSIS MANAGEMENT CO LTD
View PDF 13 Cites 0 Cited by

Patent Information

Application Number
CN202510316464.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-18
Publication Date
2025-04-18
Estimated Expiration
2045-03-18

AI Technical Summary

Technical Problem

In the prior art, after the label is attached to the circular reagent bottle, the arc surface of the label extends to a certain degree of distortion in the acquired label image, which in turn leads to deviations in the acquisition of label information and errors in the identification of the reagent bottle.

Method used

By acquiring the surface image of the reagent bottle, performing sharpening processing and binarization segmentation, determining the label area and performing tilt correction, acquiring the standard label image and performing text detection to complete the identification of the reagent bottle.

Benefits of technology

By performing tilt correction and mapping of the tag area, the information acquisition error caused by label distortion is avoided, and the accuracy and efficiency of reagent bottle recognition are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119850931A_ABST
    Figure CN119850931A_ABST
Patent Text Reader

Abstract

The invention provides a reagent bottle identification method and system, and the method comprises the steps: obtaining a surface image of a reagent bottle, and carrying out the clarification processing of the surface image, so as to obtain an enhanced image; carrying out binarization segmentation on the enhanced image, obtaining a gray level image, and determining a label area through edge detection; carrying out tilt correction on the label area; and mapping the label area to a standard area to obtain a standard label image, performing character detection in the standard label image to obtain label character information, and completing identification of the reagent bottle based on the label character information. On the premise that the label area is parallel to the standard area, the mapping relation from all the pixel points of the standard area to the standard area is deduced through the three mapping relations, and then the label extending in a cambered surface mode is flattened, so that the information acquisition error caused by label distortion is avoided, and the recognition accuracy of the reagent bottle is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a method and system for identifying a reagent bottle. Background Art

[0002] Reagent bottles are glass bottles or plastic bottles used to hold reagents. They are mainly used to preserve reagents and ensure the stability and purity of the reagents. The design of reagent bottles usually takes into account the chemical inertness and sealing of the materials to prevent the reagents from volatilizing, absorbing moisture or reacting with components in the air.

[0003] After the reagent bottle is loaded with reagents, a label corresponding to the reagent bottle is usually posted on the reagent bottle. Then, the reagent bottle can be identified by reading the information on the label on the reagent bottle. The traditional identification method usually manually identifies the label information, which is inefficient.

[0004] In order to improve the recognition efficiency of reagent bottles, image recognition technology is usually used to directly identify the information on the label. However, the shape of the reagent bottle is usually round. After the label is attached, the label extends in an arc, which will cause a certain degree of image distortion in the recognized label image, resulting in deviations in the acquisition of label information, and then causing errors in the recognition of the reagent bottle. Summary of the invention

[0005] In view of the deficiencies in the prior art, the purpose of the present invention is to provide a method and system for identifying a reagent bottle, aiming to solve the technical problem in the prior art that after a label is affixed to a circular reagent bottle, the arc surface of the label is extended, resulting in a certain degree of distortion in the acquired label image, causing deviation in the acquisition of label information, and further causing errors in the identification of the reagent bottle.

[0006] In order to achieve the above-mentioned object, in a first aspect, an embodiment of the present application provides a method for identifying a reagent bottle, comprising the following steps: When the label surface of the reagent bottle faces the CCD camera, a surface image of the reagent bottle is acquired, and the surface image is enhanced to acquire an enhanced image; Adaptively acquiring a segmentation threshold of the enhanced image to perform binary segmentation on the enhanced image, and acquiring a grayscale image, performing edge detection in the grayscale image to determine a label area in the grayscale image, and determining whether the label is completely captured based on the label area; If the label is completely photographed, the coordinates of the upper left corner point and the lower left corner point of the label area are obtained, and the tilt correction of the label area is performed based on the coordinates of the upper left corner point and the coordinates of the lower left corner point; Obtain the center point between the upper left corner point and the upper right corner point of the label area, and obtain the standard center point between the standard upper left corner point and the standard upper right corner point of the standard area, map the center point to the standard center point to obtain a first mapping matrix, map the upper left corner point to the standard upper left corner point to obtain a second mapping matrix, and map the upper right corner point to the standard upper right corner point to obtain a third mapping matrix; Based on the first mapping matrix, the second mapping matrix and the third mapping matrix, the label area is mapped to the standard area to obtain a standard label image, text detection is performed in the standard label image to obtain label text information, and the reagent bottle is identified based on the label text information.

[0007] Furthermore, the step of performing a definition enhancement process on the surface image to obtain an enhanced image includes: Converting the surface image into a total amount of incident light and a total amount of reflected light, performing logarithmic processing and Fourier transformation on the total amount of incident light and the total amount of reflected light, so as to convert the total amount of incident light and the total amount of reflected light into frequency domain respectively; Constructing a high-pass filter, and filtering the total amount of incident light and the total amount of reflected light in the frequency domain based on the high-pass filter to obtain a frequency domain image; The frequency domain image is subjected to exponential processing and inverse Fourier transformation to obtain an enhanced image.

[0008] Furthermore, the step of adaptively obtaining the segmentation threshold of the enhanced image to perform binary segmentation on the enhanced image and obtain a grayscale image includes: Acquire a grayscale range of the enhanced image, the grayscale range including a plurality of grayscales, and acquire a first probability of occurrence of a pixel corresponding to each of the grayscales, and divide the grayscale range into a first grayscale range and a second grayscale range based on an initial threshold; Obtaining a second probability and a third probability of occurrence of pixels in the first grayscale range and the second grayscale range respectively, obtaining a first grayscale average value of the first grayscale range based on the first probability and the second probability, and obtaining a second grayscale average value of the second grayscale range based on the first probability and the third probability; A segmentation threshold is obtained based on the second probability, the first grayscale average value, the third probability and the second grayscale average value.

[0009] Furthermore, the calculation formula of the second probability is: , in, represents the second probability, represents the probability that a pixel with gray level i appears in the first gray range, represents the initial threshold, Indicates the minimum gray level within the gray level range; The calculation formula of the third probability is: , in, represents the third probability, represents the probability that a pixel with gray level j appears in the second gray range, Indicates the maximum gray level within the gray level range; The calculation formula of the first grayscale average value is: , in, represents the first grayscale average value, represents the first probability of the occurrence of a pixel with gray level i in the gray level range; The formula for obtaining the segmentation threshold is: , in, represents the segmentation threshold, Represents the second grayscale average value.

[0010] Furthermore, the step of determining whether the label is completely photographed based on the label area includes: Obtaining the total number of pixels in the label area, and determining whether the total number of pixels is within a pixel number threshold range; If the total number of pixels is within the pixel number threshold range, it is determined that the tag is completely photographed.

[0011] Furthermore, the coordinates of the upper left corner point include an upper left horizontal coordinate and an upper left vertical coordinate, the coordinates of the lower left corner point include a lower left horizontal coordinate and a lower left vertical coordinate, and the step of performing tilt correction on the label area based on the coordinates of the upper left corner point and the coordinates of the lower left corner point includes: Acquire the horizontal spacing distance through the upper left horizontal coordinate and the lower left horizontal coordinate, and acquire the vertical spacing distance through the upper left vertical coordinate and the lower left vertical coordinate; Acquire an offset angle based on the lateral spacing distance and the longitudinal spacing distance; The upper left horizontal coordinate is compared with the lower left horizontal coordinate to complete the tilt correction through the offset angle.

[0012] Furthermore, the step of mapping the label area to the standard area based on the first mapping matrix, the second mapping matrix and the third mapping matrix includes: Acquire a plurality of fourth mapping matrices from pixel points between the upper left corner point and the center point to pixel points between the standard upper left corner point and the standard center point based on the first mapping matrix and the second mapping matrix; Acquire a plurality of fifth mapping matrices from pixel points between the center point and the upper right corner point to pixel points between the standard center point and the standard upper right corner point based on the first mapping matrix and the third mapping matrix; The label area is mapped to the standard area through the first mapping matrix, the second mapping matrix, the third mapping matrix, a plurality of the fourth mapping matrices and a plurality of the fifth mapping matrices.

[0013] Furthermore, the step of performing text detection in the standard label image includes: Setting a training image, wherein the training image includes training text, obtaining target text features corresponding to the training text, constructing an initial text recognition model, using the training image as an input value of the initial text recognition model to obtain training text features in the initial text recognition model, comparing the training text features with a preset word library to select a number of benchmark text clusters from the preset word library, and combining the several benchmark text clusters into an original sample cluster; Obtaining the distance between the training text feature and a plurality of the benchmark text clusters, selecting a plurality of comparison clusters from the plurality of the benchmark text clusters, and combining the plurality of comparison clusters into a negative sample cluster; Constructing a first loss function based on the training text features and the benchmark text clustering, constructing a second loss function based on the training text features, the target text features and the negative sample clustering, and constructing a third loss function based on the training text features, the target text features and the original sample clustering; A total loss function is constructed by using the first loss function, the second loss function and the third loss function, and the initial text recognition model is trained based on the total loss function to obtain a final text recognition model.

[0014] Furthermore, the expression of the first loss function is: , in, represents the first loss function, represents the number of benchmark text clusters, represents the training text features, Represents the center vector of the benchmark text cluster that is closest to the training text feature, represents the center vector of the y-th benchmark text cluster, represents the set of center vectors of the benchmark text clusters, represents the hyperparameter, represents the dot product operation, represents the exponential function, represents the logarithmic function; The expression of the second loss function is: , in, represents the second loss function, represents the number of negative samples in the negative sample cluster, represents the target text features, represents the pth negative sample in the negative sample cluster, Represents negative sample clustering; The expression of the third loss function is: , in, represents the third loss function, represents the number of samples in the original sample cluster, represents the qth sample in the original sample cluster, Represents the original sample clustering.

[0015] In a second aspect, an embodiment of the present application provides a reagent bottle identification system, which is applied to the reagent bottle identification method as described in the first aspect above, and the system includes: The first processing module is used to obtain a surface image of the reagent bottle when the label surface of the reagent bottle faces the CCD camera, and perform a clarity enhancement process on the surface image to obtain an enhanced image; A second processing module is used to adaptively obtain a segmentation threshold of the enhanced image to perform binary segmentation on the enhanced image, obtain a grayscale image, perform edge detection in the grayscale image to determine a label area in the grayscale image, and determine whether the label is completely captured based on the label area; an adjustment module, configured to obtain the coordinates of the upper left corner point and the lower left corner point of the label area if the label is completely photographed, and to perform tilt correction on the label area based on the coordinates of the upper left corner point and the coordinates of the lower left corner point; a conversion module, used for obtaining a center point between the upper left corner point and the upper right corner point of the label area, and obtaining a standard center point between the standard upper left corner point and the standard upper right corner point of the standard area, mapping the center point to the standard center point to obtain a first mapping matrix, mapping the upper left corner point to the standard upper left corner point to obtain a second mapping matrix, and mapping the upper right corner point to the standard upper right corner point to obtain a third mapping matrix; An execution module is used to map the label area to the standard area based on the first mapping matrix, the second mapping matrix and the third mapping matrix to obtain a standard label image, perform text detection in the standard label image to obtain label text information, and complete the identification of the reagent bottle based on the label text information.

[0016] In a third aspect, an embodiment of the present application provides a computer, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the reagent bottle identification method as described in the first aspect above is implemented.

[0017] In a fourth aspect, an embodiment of the present application provides a storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method for identifying a reagent bottle as described in the first aspect above is implemented.

[0018] Compared with the prior art, the beneficial effects of the present invention are as follows: by performing the definition enhancement processing on the surface graphics, the noise caused by uneven illumination can be avoided, thereby improving the accuracy of information recognition of the label in the later stage; when the label is completely photographed, by performing the tilt correction on the label area, the label area is parallel to the subsequent standard area in the horizontal direction, thereby improving the efficiency of subsequent text extraction; further, on the premise that the label area is parallel to the standard area, a first mapping matrix between the center point of the label area and the standard center point, a second mapping matrix between the upper left corner point and the standard upper left corner point, and a second mapping matrix between the upper right corner point and the standard are obtained. The third mapping matrix between the quasi-upper-right corner points can derive the mapping relationship from all the pixel points of the standard area to the standard area through three mapping relationships, and then flatten the label that extends on an arc surface, thereby avoiding the information acquisition error caused by label distortion and improving the accuracy of reagent bottle recognition; by constructing the final text recognition model, the first loss function is used to shorten the distance between the input value and the true value, and the second loss function is used to improve the difference judgment between the input value and the similar value, thereby avoiding the occurrence of text recognition errors caused by similar characters, improving the accuracy of text information extraction, and further improving the accuracy of reagent bottle recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 Flow chart of the method for identifying a reagent bottle in the first embodiment of the present invention; Figure 2 It is a structural block diagram of a reagent bottle identification system in a second embodiment of the present invention; The following specific implementation manner will further illustrate the present invention in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION

[0020] In order to facilitate the understanding of the present invention, the present invention will be described more fully below with reference to the relevant drawings. Several embodiments of the present invention are given in the drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present invention more thorough and comprehensive.

[0021] It should be noted that when an element is referred to as being "fixed to" another element, it may be directly on the other element or there may be a central element. When an element is considered to be "connected to" another element, it may be directly connected to the other element or there may be a central element at the same time. The terms "vertical", "horizontal", "left", "right" and similar expressions used herein are for illustrative purposes only.

[0022] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present invention belongs. The terms used herein in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.

[0023] See also Figure 1 The method for identifying a reagent bottle provided by the first embodiment of the present invention comprises the following steps: S10: when the label surface of the reagent bottle faces the CCD camera, a surface image of the reagent bottle is acquired, and the surface image is enhanced to acquire an enhanced image; The step S10 comprises: S110: converting the surface image into a total amount of incident light and a total amount of reflected light, performing logarithmic processing and Fourier transformation on the total amount of incident light and the total amount of reflected light, so as to convert the total amount of incident light and the total amount of reflected light into frequency domain respectively; The relationship between the surface image and the total amount of incident light and the total amount of reflected light is: , in, represents the surface image, represents the total amount of incident light, Indicates the total amount of reflected light.

[0024] After the logarithmic processing is performed, the product relationship between the total amount of incident light and the total amount of reflected light can be changed into an additive relationship, thereby achieving separation between the total amount of incident light and the total amount of reflected light, and then facilitating subsequent filtering processing of the total amount of incident light and the total amount of reflected light in the frequency domain.

[0025] S120: constructing a high-pass filter, and filtering the total amount of incident light and the total amount of reflected light in the frequency domain based on the high-pass filter to obtain a frequency domain image; The expression of the high-pass filter is: , in, represents the transfer function of the high-pass filter, represents the cut-off frequency, Indicates frequency point The distance to the origin of the frequency plane, Indicates the order of the high-pass filter.

[0026] S130: performing exponential processing and inverse Fourier transform on the frequency domain image to obtain an enhanced image; It will be appreciated that after processing is completed, the image is converted from the frequency domain back to the enhanced image.

[0027] S20: adaptively acquiring a segmentation threshold of the enhanced image to perform binary segmentation on the enhanced image, and acquiring a grayscale image, performing edge detection in the grayscale image to determine a label area in the grayscale image, and determining whether the label is completely captured based on the label area; The step S20 comprises: S210: Obtaining a grayscale range of the enhanced image, the grayscale range including a plurality of grayscales, and obtaining a first probability of occurrence of a pixel corresponding to each grayscale, and dividing the grayscale range into a first grayscale range and a second grayscale range based on an initial threshold; By obtaining the number of pixels corresponding to each grayscale level, the total number of pixels corresponding to the grayscale range can be obtained, and by dividing the number of pixels corresponding to each grayscale level by the total number of pixels corresponding to the grayscale range, the first probability of occurrence of the pixel corresponding to each grayscale level can be obtained. It can be understood that the first grayscale range and the second grayscale range are mixed to form the grayscale range.

[0028] S220: Obtain a second probability and a third probability of occurrence of pixels in the first grayscale range and the second grayscale range, respectively, obtain a first grayscale average value of the first grayscale range based on the first probability and the second probability, and obtain a second grayscale average value of the second grayscale range based on the first probability and the third probability; The calculation formula of the second probability is: , in, represents the second probability, represents the probability that a pixel with gray level i appears in the first gray range, represents the initial threshold, Indicates the minimum gray level within the gray level range; The calculation formula of the third probability is: , in, represents the third probability, represents the probability that a pixel with gray level j appears in the second gray range, Indicates the maximum gray level within the gray level range; The calculation formula of the first grayscale average value is: , in, represents the first grayscale average value, represents the first probability of the occurrence of a pixel with gray level i in the gray level range. The second gray level average value is obtained in the same manner as the first gray level average value, which will not be described in detail here.

[0029] S230: Obtaining a segmentation threshold based on the second probability, the first grayscale average value, the third probability and the second grayscale average value; The formula for obtaining the segmentation threshold is: , in, represents the segmentation threshold, Represents the second grayscale average value.

[0030] By adaptively acquiring the segmentation threshold, different surface images can be adapted to complete the accurate binarization of the image. The edge detection algorithm is now widely used and will not be described here. After completing the edge detection, the outline of the label can be obtained, and then the label area can be obtained.

[0031] S240: Obtain the total number of pixels in the label area, and determine whether the total number of pixels is within a pixel number threshold range; S250: If the total number of pixels is within the pixel number threshold range, it is determined that the tag is completely photographed; It should be noted that if the label is not completely photographed, the placement position of the reagent bottle is readjusted until the label is completely photographed.

[0032] S30: if the label is completely photographed, obtaining the coordinates of the upper left corner point and the lower left corner point of the label area, and performing tilt correction on the label area based on the coordinates of the upper left corner point and the lower left corner point; The step S30 comprises: S310: Acquire a horizontal spacing distance through the upper left horizontal coordinate and the lower left horizontal coordinate, and acquire a vertical spacing distance through the upper left vertical coordinate and the lower left vertical coordinate; S320: Acquire an offset angle based on the lateral spacing distance and the longitudinal spacing distance; S330: Compare the upper left horizontal coordinate with the lower left horizontal coordinate to complete tilt correction through the offset angle; After obtaining the offset angle, if the upper left horizontal coordinate is greater than the lower left horizontal coordinate, the upper left horizontal coordinate is used as a reference point to rotate the lower left horizontal coordinate in the direction of the upper left horizontal coordinate by the offset angle to complete the tilt correction; if the upper left horizontal coordinate is less than the lower left horizontal coordinate, the lower left horizontal coordinate is used as a reference point to rotate the upper left horizontal coordinate in the direction of the lower left horizontal coordinate by the offset angle to complete the tilt correction.

[0033] S40: Obtain the center point between the upper left corner point and the upper right corner point of the label area, and obtain the standard center point between the standard upper left corner point and the standard upper right corner point of the standard area, map the center point to the standard center point to obtain a first mapping matrix, map the upper left corner point to the standard upper left corner point to obtain a second mapping matrix, and map the upper right corner point to the standard upper right corner point to obtain a third mapping matrix; The relationship between the center point, the standard center point and the first mapping matrix is: , in, represents the coordinates of the standard center point, where Represents auxiliary coordinates, used for normalization processing, represents the coordinates of the center point, represents the first mapping matrix, where , , , They represent linear transformation parameters respectively. , are translation parameters, , Both represent projection transformation parameters. In this embodiment, , The value of is 0. The acquisition method of the second mapping matrix and the third mapping matrix is ​​consistent with the acquisition method of the first mapping matrix, which will not be repeated here.

[0034] If the tilt and arc surface distortion are solved synchronously by mapping processing directly, it is necessary to compensate for multiple geometric deformations in a single change, such as rotation, perspective, and arc surface flattening, which will significantly increase the difficulty of optimizing the parameters of the mapping matrix. Especially when the tilt angle is large, it may lead to the accumulation of interpolation errors. By performing the tilt correction, the non-horizontal alignment problem of the label area caused by the shooting angle deviation or the manual posting deviation is eliminated. Then, when the label area is in a horizontal state, the arc surface distortion problem is processed separately, which significantly reduces the complexity of the algorithm and improves the mapping accuracy and efficiency after the tilt correction. If the tilt correction is not performed, the tilt and arc surface distortion are directly processed synchronously by mapping, and the point position used for mapping and the ideal position will be offset, resulting in a certain error in the calculation of the mapping matrix. There may also be mutual interference between the rotation parameters and the arc surface flattening parameters, resulting in the optimization process falling into a local optimum, and multiple iterations are required to optimize and find the optimal parameters. Compared with the step-by-step processing method in this application, the number of key points of the mapping matrix obtained by direct mapping is also much larger than the number of key points required for the step-by-step processing. If a local optimum problem occurs during the optimization process, it may also cause the final standard label image to be distorted. For the label area of ​​500*200 pixels, it is processed by a single thread of the CPU. Without considering the distortion of direct mapping, the standard label image is obtained by direct mapping. Assuming that only four key points are set and iterative optimization is performed, the time for obtaining the standard label image is about 20ms. However, through the initial method of first performing the tilt correction and then mapping in the present application, it only takes 10ms to obtain the standard label image, which significantly increases the efficiency of obtaining the standard label image.

[0035] S50: mapping the label area to the standard area based on the first mapping matrix, the second mapping matrix, and the third mapping matrix to obtain a standard label image, performing text detection in the standard label image to obtain label text information, and completing the identification of the reagent bottle based on the label text information; The step S50 comprises: S510: Acquire a plurality of fourth mapping matrices from pixel points between the upper left corner point and the center point to pixel points between the standard upper left corner point and the standard center point based on the first mapping matrix and the second mapping matrix; S520: Acquire a plurality of fifth mapping matrices from pixel points between the center point and the upper right corner point to pixel points between the standard center point and the standard upper right corner point based on the first mapping matrix and the third mapping matrix; S530: Mapping the label area to the standard area through the first mapping matrix, the second mapping matrix, the third mapping matrix, a plurality of the fourth mapping matrices, and a plurality of the fifth mapping matrices; It can be understood that, because the label area has been corrected, the pixel points located on the same vertical line as the upper left corner point, the center point and the upper right corner point can be mapped to the standard area by adjusting the parameters of the first mapping matrix, the second mapping matrix and the third mapping matrix. After obtaining the first mapping matrix and the second mapping matrix, the fourth mapping matrix can be obtained for each pixel between the upper left corner point and the center point by combining the first mapping matrix and the second mapping matrix, and then all the pixel points on the same vertical line are mapped by adjusting the fourth mapping matrix based on the vertical spacing. The fifth mapping matrix is ​​the same and will not be described here. The fourth mapping matrix and the fifth mapping matrix are obtained by the first mapping matrix, the second mapping matrix and the third mapping matrix. The center point is used as the dividing point to divide the label area into two parts, and a more detailed mapping relationship is obtained to avoid the label area rotating too much to the left or too much to the right, resulting in different lengths of the left and right parts, thereby causing mapping deviations during the mapping process.

[0036] S540: Setting a training image, wherein the training image includes training text, obtaining target text features corresponding to the training text, constructing an initial text recognition model, using the training image as an input value of the initial text recognition model to obtain training text features in the initial text recognition model, comparing the training text features with a preset word library to select a number of benchmark text clusters from the preset word library, and combining the several benchmark text clusters into an original sample cluster; The benchmark text cluster includes several benchmark text features with high feature similarity. It should be noted that, in the process of obtaining the original sample cluster, the distance between the training text feature and the center vector of the benchmark text cluster is calculated by obtaining the center vector of the benchmark text cluster to obtain the distance between the training text feature and the benchmark text cluster, and the benchmark text cluster closest to the training text feature is eliminated, and the remaining benchmark text clusters are aggregated into the original sample cluster, and the original sample cluster includes several original text features, and the original text features are samples.

[0037] S550: Obtaining the distance between the training text feature and a plurality of the reference text clusters, selecting a plurality of comparison clusters from the plurality of the reference text clusters, and combining the plurality of comparison clusters into a negative sample cluster; Specifically, after obtaining the distances, compare several of the distances with a distance threshold respectively, and cluster and select the reference characters corresponding to the distances less than the distance threshold as the candidate character clusters. Among several candidate character clusters, eliminate the candidate character cluster with the closest distance to the training character features to obtain several comparison clusters, and its essence is the same as the method for obtaining the original sample clusters. Since there are target character features in the candidate character cluster with the closest distance to the training character features, by eliminating it, it can be avoided that the true value is mixed in the negative sample clusters, resulting in errors in the training of the model and affecting the accuracy of obtaining label character information. It can be understood that both the comparison clusters and the negative sample clusters include several reference character features, and the reference character features are the negative samples.

[0038] S560: Construct a first loss function based on the training character features and the reference character clusters, construct a second loss function based on the training character features, the target character features and the negative sample clusters, and construct a third loss function based on the training character features, the target character features and the original sample clusters.

[0039] The expression of the first loss function is: , where, represents the first loss function, represents the number of reference character clusters, represents the training character features, represents the center vector of the reference character cluster with the closest distance to the training character features, represents the center vector of the y-th reference character cluster, represents the set of center vectors of the reference character clusters, represents a hyperparameter, represents the dot product operation, represents the exponential function, represents the logarithmic function; taking oneself as an example, assuming there are 2 reference character clusters, the cluster containing oneself is , and the cluster containing already is . By setting the first loss function, according to the similarity between the training character features and all the reference character clusters, the training character features are distinguished from the approximate clusters, and the problem of blurred semantic boundaries of different categories is solved.

[0040] The expression of the second loss function is: , where, represents the second loss function, represents the number of negative samples in the negative sample cluster, represents the target text features, represents the pth negative sample in the negative sample cluster, Represents negative sample clustering. It should be noted that the target text feature is a cluster of variants of multiple training text features in the representation space. Taking "self" as an example, there may be variants such as rotation and flipping. By setting the second loss function, its purpose is to narrow the distance between the training text feature and the target text feature and solve the problem of fine-grained distinction between different variants.

[0041] The expression of the third loss function is: , in, represents the third loss function, represents the number of samples in the original sample cluster, represents the qth sample in the original sample cluster, Represents the original sample clustering. By setting the third loss function, its role is to globally distinguish the training text features from all other characters.

[0042] S570: constructing a total loss function through the first loss function, the second loss function and the third loss function, and training the initial text recognition model based on the total loss function to obtain a final text recognition model; The expression of the total loss function is: , in, represents the total loss function, , , By setting the first loss function, the second loss function and the third loss function to obtain the final loss function, the accuracy of text recognition can be effectively improved, thereby ensuring the accuracy of recognition.

[0043] S580: Using the standard label image as an input value of the final text recognition model to complete text detection; The final text recognition model can be used to obtain real text features and convert the real text features into the label text information.

[0044] By performing the definition enhancement processing on the surface graphics, the noise caused by uneven illumination can be avoided, thereby improving the accuracy of the subsequent information recognition of the label; when the label is completely photographed, by performing the tilt correction on the label area, the label area is parallel to the subsequent standard area in the horizontal direction, thereby improving the efficiency of subsequent text extraction; further, under the premise that the label area is parallel to the standard area, a first mapping matrix between the center point of the label area and the standard center point, a second mapping matrix between the upper left corner point and the standard upper left corner point, and a first mapping matrix between the upper right corner point and the standard upper right corner point are obtained. The three-mapping matrix can derive the mapping relationship from all the pixels in the standard area to the standard area through three mapping relationships, and then flatten the label that extends in an arc surface, thereby avoiding the information acquisition error caused by label distortion and improving the accuracy of reagent bottle recognition; by constructing the final text recognition model, the first loss function is used to shorten the distance between the input value and the true value, and the second loss function is used to improve the difference judgment between the input value and the similar value, thereby avoiding the occurrence of text recognition errors caused by similar characters, improving the accuracy of text information extraction, and further improving the accuracy of reagent bottle recognition.

[0045] See also Figure 2 , the second embodiment of the present invention provides a kind of identification system of reagent bottle, and this system is applied to the identification method of the reagent bottle described in the above-mentioned embodiment, and will not be repeated hereafter. As used below, the terms "module", "unit", "subunit" etc. can realize the combination of software and / or hardware of predetermined function. Although the device described in the following embodiments is preferably realized with software, the realization of hardware, or the combination of software and hardware is also possible and conceived.

[0046] The system comprises: The first processing module 10 is used to obtain a surface image of the reagent bottle when the label surface of the reagent bottle faces the CCD camera, and perform a clarity enhancement process on the surface image to obtain an enhanced image; The first processing module 10 comprises: A first unit is used to convert the surface image into a total amount of incident light and a total amount of reflected light, and perform logarithmic processing and Fourier transformation on the total amount of incident light and the total amount of reflected light to convert the total amount of incident light and the total amount of reflected light into frequency domains respectively; The second unit is used to construct a high-pass filter, and filter the total amount of incident light and the total amount of reflected light in the frequency domain based on the high-pass filter to obtain a frequency domain image; A third unit is used to perform exponential processing and inverse Fourier transform on the frequency domain image to obtain an enhanced image; The second processing module 20 is used to adaptively obtain the segmentation threshold of the enhanced image to perform binary segmentation on the enhanced image, obtain a grayscale image, perform edge detection in the grayscale image to determine the label area in the grayscale image, and determine whether the label is completely captured based on the label area; The second processing module 20 includes: A fourth unit is used to obtain a grayscale range of the enhanced image, the grayscale range includes a plurality of grayscales, obtain a first probability of occurrence of a pixel corresponding to each grayscale, and separate the grayscale range into a first grayscale range and a second grayscale range based on an initial threshold; A fifth unit is used to obtain a second probability and a third probability of occurrence of pixels in the first grayscale range and the second grayscale range, respectively, obtain a first grayscale average value of the first grayscale range based on the first probability and the second probability, and obtain a second grayscale average value of the second grayscale range based on the first probability and the third probability; A sixth unit, configured to obtain a segmentation threshold based on the second probability, the first grayscale average value, the third probability and the second grayscale average value; An adjustment module 30, configured to obtain the coordinates of the upper left corner point and the lower left corner point of the label area if the label is completely photographed, and perform tilt correction on the label area based on the coordinates of the upper left corner point and the coordinates of the lower left corner point; The adjustment module 30 includes: A seventh unit is used to obtain a horizontal spacing distance through the upper left horizontal coordinate and the lower left horizontal coordinate, and to obtain a vertical spacing distance through the upper left vertical coordinate and the lower left vertical coordinate; An eighth unit is used to obtain an offset angle based on the lateral spacing distance and the longitudinal spacing distance; A ninth unit, configured to compare the upper left horizontal coordinate with the lower left horizontal coordinate to complete tilt correction through the offset angle; The conversion module 40 is used to obtain the center point between the upper left corner point and the upper right corner point of the label area, and obtain the standard center point between the standard upper left corner point and the standard upper right corner point of the standard area, map the center point to the standard center point to obtain a first mapping matrix, map the upper left corner point to the standard upper left corner point to obtain a second mapping matrix, and map the upper right corner point to the standard upper right corner point to obtain a third mapping matrix; An execution module 50 is used to map the label area to the standard area based on the first mapping matrix, the second mapping matrix and the third mapping matrix to obtain a standard label image, perform text detection in the standard label image to obtain label text information, and complete the identification of the reagent bottle based on the label text information; The execution module 50 includes: A tenth unit, configured to obtain a plurality of fourth mapping matrices from pixel points between the upper left corner point and the center point to a plurality of fourth mapping matrices between the standard upper left corner point and the standard center point based on the first mapping matrix and the second mapping matrix; An eleventh unit is used to obtain a plurality of fifth mapping matrices from pixel points between the center point and the upper right corner point to pixel points between the standard center point and the standard upper right corner point based on the first mapping matrix and the third mapping matrix; A twelfth unit is used to map the label area to the standard area through the first mapping matrix, the second mapping matrix, the third mapping matrix, a plurality of the fourth mapping matrices and a plurality of the fifth mapping matrices; A thirteenth unit is used to set a training image, wherein the training image includes training text, obtain target text features corresponding to the training text, construct an initial text recognition model, use the training image as an input value of the initial text recognition model to obtain training text features in the initial text recognition model, compare the training text features with a preset word library to select a number of benchmark text clusters from the preset word library, and combine the several benchmark text clusters into an original sample cluster; A fourteenth unit is used to obtain the distance between the training text feature and the plurality of reference text clusters, so as to select a plurality of comparison clusters from the plurality of reference text clusters, and combine the plurality of comparison clusters into a negative sample cluster; A fifteenth unit is used to construct a first loss function based on the training text features and the benchmark text clusters, to construct a second loss function based on the training text features, the target text features and the negative sample clusters, and to construct a third loss function based on the training text features, the target text features and the original sample clusters; A sixteenth unit is used to construct a total loss function through the first loss function, the second loss function and the third loss function, and train the initial text recognition model based on the total loss function to obtain a final text recognition model; The seventeenth unit is used to use the standard label image as an input value of the final text recognition model to complete text detection.

[0047] The present invention also provides a computer, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the reagent bottle identification method as described in the above technical solution when executing the computer program.

[0048] The present invention also provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the method for identifying a reagent bottle as described in the above technical solution is implemented.

[0049] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0050] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the patent of the present invention. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.

Claims

1. A method for identifying a reagent bottle, characterized in that: The following steps are involved: When the label surface of the reagent bottle faces the CCD camera, a surface image of the reagent bottle is acquired, and the surface image is enhanced to acquire an enhanced image; Adaptively acquiring a segmentation threshold of the enhanced image to perform binary segmentation on the enhanced image, and acquiring a grayscale image, performing edge detection in the grayscale image to determine a label area in the grayscale image, and determining whether the label is completely captured based on the label area; If the label is completely photographed, the coordinates of the upper left corner point and the lower left corner point of the label area are obtained, and the tilt correction of the label area is performed based on the coordinates of the upper left corner point and the coordinates of the lower left corner point; Obtain the center point between the upper left corner point and the upper right corner point of the label area, and obtain the standard center point between the standard upper left corner point and the standard upper right corner point of the standard area, map the center point to the standard center point to obtain a first mapping matrix, map the upper left corner point to the standard upper left corner point to obtain a second mapping matrix, and map the upper right corner point to the standard upper right corner point to obtain a third mapping matrix; Based on the first mapping matrix, the second mapping matrix and the third mapping matrix, the label area is mapped to the standard area to obtain a standard label image, text detection is performed in the standard label image to obtain label text information, and the reagent bottle is identified based on the label text information.

2. The method for identifying a reagent bottle according to claim 1, characterized in that: The step of performing a definition enhancement process on the surface image to obtain an enhanced image comprises: Converting the surface image into a total amount of incident light and a total amount of reflected light, performing logarithmic processing and Fourier transformation on the total amount of incident light and the total amount of reflected light, so as to convert the total amount of incident light and the total amount of reflected light into frequency domain respectively; Constructing a high-pass filter, and filtering the total amount of incident light and the total amount of reflected light in the frequency domain based on the high-pass filter to obtain a frequency domain image; The frequency domain image is subjected to exponential processing and inverse Fourier transformation to obtain an enhanced image.

3. The method for identifying a reagent bottle according to claim 1, characterized in that: The step of adaptively acquiring the segmentation threshold of the enhanced image to perform binary segmentation on the enhanced image and acquire a grayscale image comprises: Acquire a grayscale range of the enhanced image, the grayscale range including a plurality of grayscales, and acquire a first probability of occurrence of a pixel corresponding to each of the grayscales, and divide the grayscale range into a first grayscale range and a second grayscale range based on an initial threshold; Obtaining a second probability and a third probability of occurrence of pixels in the first grayscale range and the second grayscale range respectively, obtaining a first grayscale average value of the first grayscale range based on the first probability and the second probability, and obtaining a second grayscale average value of the second grayscale range based on the first probability and the third probability; A segmentation threshold is obtained based on the second probability, the first grayscale average value, the third probability and the second grayscale average value.

4. The method for identifying a reagent bottle according to claim 3, characterized in that: The calculation formula of the second probability is: , in, represents the second probability, represents the probability that a pixel with gray level i appears in the first gray range, represents the initial threshold, Indicates the minimum gray level within the gray level range; The calculation formula of the third probability is: , in, represents the third probability, represents the probability that a pixel with gray level j appears in the second gray range, Indicates the maximum gray level within the gray level range; The calculation formula of the first grayscale average value is: , in, represents the first grayscale average value, represents the first probability of the occurrence of a pixel with gray level i in the gray level range; The formula for obtaining the segmentation threshold is: , in, represents the segmentation threshold, Represents the second grayscale average value.

5. The method for identifying a reagent bottle according to claim 1, characterized in that: The step of judging whether the tag is completely photographed based on the tag area comprises: Obtaining the total number of pixels in the label area, and determining whether the total number of pixels is within a pixel number threshold range; If the total number of pixels is within the pixel number threshold range, it is determined that the tag is completely photographed.

6. The method for identifying a reagent bottle according to claim 1, characterized in that: The coordinates of the upper left corner point include an upper left horizontal coordinate and an upper left vertical coordinate, and the coordinates of the lower left corner point include a lower left horizontal coordinate and a lower left vertical coordinate. The step of performing tilt correction on the label area based on the coordinates of the upper left corner point and the coordinates of the lower left corner point includes: Acquire the horizontal spacing distance through the upper left horizontal coordinate and the lower left horizontal coordinate, and acquire the vertical spacing distance through the upper left vertical coordinate and the lower left vertical coordinate; Acquire an offset angle based on the lateral spacing distance and the longitudinal spacing distance; The upper left horizontal coordinate is compared with the lower left horizontal coordinate to complete the tilt correction through the offset angle.

7. The method for identifying a reagent bottle according to claim 1, characterized in that: The step of mapping the label area to the standard area based on the first mapping matrix, the second mapping matrix and the third mapping matrix comprises: Acquire a plurality of fourth mapping matrices from pixel points between the upper left corner point and the center point to pixel points between the standard upper left corner point and the standard center point based on the first mapping matrix and the second mapping matrix; Acquire a plurality of fifth mapping matrices from pixel points between the center point and the upper right corner point to pixel points between the standard center point and the standard upper right corner point based on the first mapping matrix and the third mapping matrix; The label area is mapped to the standard area through the first mapping matrix, the second mapping matrix, the third mapping matrix, a plurality of the fourth mapping matrices and a plurality of the fifth mapping matrices.

8. The method for identifying a reagent bottle according to claim 1, characterized in that: The step of performing text detection in the standard label image comprises: Setting a training image, wherein the training image includes training text, obtaining target text features corresponding to the training text, constructing an initial text recognition model, using the training image as an input value of the initial text recognition model to obtain training text features in the initial text recognition model, comparing the training text features with a preset word library to select a number of benchmark text clusters from the preset word library, and combining the several benchmark text clusters into an original sample cluster; Obtaining the distance between the training text feature and a plurality of the benchmark text clusters, selecting a plurality of comparison clusters from the plurality of the benchmark text clusters, and combining the plurality of comparison clusters into a negative sample cluster; Constructing a first loss function based on the training text features and the benchmark text clustering, constructing a second loss function based on the training text features, the target text features and the negative sample clustering, and constructing a third loss function based on the training text features, the target text features and the original sample clustering; Constructing a total loss function through the first loss function, the second loss function and the third loss function, and training the initial text recognition model based on the total loss function to obtain a final text recognition model; The standard label image is used as an input value of the final text recognition model to complete text detection.

9. The method for identifying a reagent bottle according to claim 8, characterized in that: The expression of the first loss function is: , in, represents the first loss function, represents the number of benchmark text clusters, represents the training text features, Represents the center vector of the benchmark text cluster that is closest to the training text feature, represents the center vector of the y-th benchmark text cluster, represents the set of center vectors of the benchmark text clusters, represents the hyperparameter, represents the dot product operation, represents the exponential function, represents the logarithmic function; The expression of the second loss function is: , in, represents the second loss function, represents the number of negative samples in the negative sample cluster, represents the target text features, represents the pth negative sample in the negative sample cluster, Represents negative sample clustering; The expression of the third loss function is: , in, represents the third loss function, represents the number of samples in the original sample cluster, represents the qth sample in the original sample cluster, Represents the original sample clustering.

10. A reagent bottle identification system, applied to the reagent bottle identification method according to any one of claims 1 to 9, characterized in that: The system comprises: The first processing module is used to obtain a surface image of the reagent bottle when the label surface of the reagent bottle faces the CCD camera, and perform a clarity enhancement process on the surface image to obtain an enhanced image; A second processing module is used to adaptively obtain a segmentation threshold of the enhanced image to perform binary segmentation on the enhanced image, obtain a grayscale image, perform edge detection in the grayscale image to determine a label area in the grayscale image, and determine whether the label is completely captured based on the label area; an adjustment module, configured to obtain the coordinates of the upper left corner point and the lower left corner point of the label area if the label is completely photographed, and perform tilt correction on the label area based on the coordinates of the upper left corner point and the coordinates of the lower left corner point; a conversion module, used for obtaining a center point between the upper left corner point and the upper right corner point of the label area, and obtaining a standard center point between the standard upper left corner point and the standard upper right corner point of the standard area, mapping the center point to the standard center point to obtain a first mapping matrix, mapping the upper left corner point to the standard upper left corner point to obtain a second mapping matrix, and mapping the upper right corner point to the standard upper right corner point to obtain a third mapping matrix; An execution module is used to map the label area to the standard area based on the first mapping matrix, the second mapping matrix and the third mapping matrix to obtain a standard label image, perform text detection in the standard label image to obtain label text information, and complete the identification of the reagent bottle based on the label text information.

Citation Information

Patent Citations

  • Label identification method and device

    CN105844277A

  • Tank identification system based on improved Hu invariant moment and method thereof

    CN106203457A

  • Natural scene text detection method based on self-learning color clustering

    CN106874905A

  • Concealed target detection system based on multispectral polarization imaging and concealed target detection method based on multispectral polarization imaging

    CN108090490A

  • A method and system for image distortion correction

    CN109461126A