Drug review method and system
Using image recognition technology to identify drug characters and specifications, combined with color recognition scores, solves the problem of low accuracy in drug review and achieves fast and safe drug review.
Patent Information
- Application Number
- CN202410748869.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-06-12
AI Technical Summary
Drug review mainly relies on manual labor, which results in a heavy workload and can easily lead to errors in drug distribution, affecting drug safety. The similarity of drug packaging makes review difficult.
Use image recognition technology to obtain drug image data through testing equipment, use preset character and image recognition models to identify drug characters and specification data, and perform weighted calculations based on character and color recognition scores to improve the accuracy of drug review.
It achieves fast and accurate drug review, reduces manual errors, improves the safety of drug distribution, and reduces the risk of drug-related accidents.
Smart Images

Figure CN118334639B
Abstract
Description
Technical Field
[0001] The present application relates to the field of drug testing management, and more specifically, to a drug review method and system. Background Art
[0002] Pharmacies and nurse stations are the workplaces where drugs are most frequently issued. They are also service windows that need to strictly implement drug issuance regulations and prevent drug issuance errors. The objects of their service are usually patients with common diseases. Their professional knowledge is limited and they cannot effectively check the drugs issued. Drug issuance errors will directly lead to safety hazards of medication, causing treatment failures, and in serious cases, drug-related accidents. In order to prevent drug issuance errors, more advanced and reliable technical measures need to be implemented for drug issuance errors.
[0003] Currently, drug review is basically completed manually, such as in outpatient pharmacies. The heavy workload causes visual fatigue and lack of concentration for pharmacists. Due to the similarity of drug packaging and drug names, it is easy to cause drug dispensing errors, such as missed, over-dispensing, and wrong dispensing of drugs.
[0004] Therefore, the prior art has defects and is in urgent need of improvement. Summary of the invention
[0005] In view of the above problems, an object of the present invention is to provide a drug review method and system, which can review drugs more effectively and quickly and improve the accuracy of drug review.
[0006] The first aspect of the present invention provides a drug review method, comprising:
[0007] Determine the data of the medicines to be taken through the doctor's order data, and obtain the detection image data through the detection equipment;
[0008] Performing image recognition on the detection image data to determine character image data of the detection image data;
[0009] Analyzing the character image data by using a preset character recognition model to determine recognition data of a first character and a second character;
[0010] determining first recognition data according to the recognition data of the first character and the second character, and calculating a character recognition score of the first recognition data;
[0011] Traversing the character area based on the first character to determine coordinate data of the first area, analyzing the detection image data based on the coordinate data of the first area to determine specification data and color distribution data of the first area;
[0012] Inputting the specification data and color distribution data of the first area into a preset image recognition model, traversing the drug samples in the database, determining that there is second recognition data of the second area, and calculating the color recognition score of the second recognition data;
[0013] Based on the analysis of the first recognition data and the second recognition data, a character recognition score and a color recognition score of the same recognition data are weighted to determine a recognition score of the third recognition data;
[0014] The third identification data with the highest identification score is used to determine the drug identification data, and the drug identification data is compared with the drug data to be taken to determine the drug review data.
[0015] In this solution, performing image recognition on the detection image data to determine the character image data of the detection image data includes:
[0016] Performing image denoising and image correction on the detected image data to obtain preprocessed image data;
[0017] Binarization is performed on the pre-processed image data to determine binary image data;
[0018] Performing edge extraction on the binary image data to determine edge features;
[0019] By analyzing the edge features, character image data of the detection image data is determined.
[0020] In this solution, the character image data is analyzed by a preset character recognition model to determine the recognition data of the first character and the second character, including:
[0021] Comparing the character image data with character samples in a database to determine character confidences of sub-character images and character samples in the character image data;
[0022] Determine the sub-character image whose maximum character confidence is greater than a first preset threshold as the first character, and the character sample corresponding to the maximum character confidence is the recognition data of the first character;
[0023] The sub-character image whose maximum character confidence is between the first preset threshold and the second preset threshold is determined as the second character, and the character sample whose character confidence is greater than the second preset threshold is determined as the recognition data of the second character.
[0024] In this solution, determining the first recognition data according to the recognition data of the first character and the second character, and calculating the character recognition score of the first recognition data includes:
[0025] Based on the drug information template in the database, the identification data of the first character and the second character are combined to determine one or more first identification data;
[0026] Accumulating the character confidence of each character in the first recognition data to determine a recognition score for each first recognition data;
[0027] When there is only one first recognition data whose recognition score is greater than a third preset threshold, determining the first recognition data as the drug recognition data of the detection image data;
[0028] On the contrary, the first recognition data having a recognition score less than the fourth preset threshold is filtered, and the character recognition scores of the remaining first recognition data are calculated according to the character confidences of the first character and the second character.
[0029] This plan also includes:
[0030] The calculation method of the character recognition score of the first recognition data is expressed by the formula:
[0031] ;
[0032] Where p1 is the character recognition score of the first recognition data, P 1(i) is the character confidence of the i-th first character in the first recognition data, n is the total number of first characters in the first recognition data, k1 is the influence weight of the character confidence of the first character, P 2(j) is the character confidence of the jth second character in the first recognition data, m is the total number of second characters in the first recognition data, and k2 is the influence weight of the character confidence of the second character.
[0033] In this solution, the character area based on the first character is traversed to determine the coordinate data of the first area, and the detection image data is analyzed based on the coordinate data of the first area to determine the specification data and color distribution data of the first area, including:
[0034] Determine the character area of each character according to the coordinate data of the character;
[0035] A traversal point is randomly generated based on the edge of the character area of the first character, and the traversal is performed clockwise around the edge of the character area of the first character. When the traversal reaches the edge area of the drug detection surface or the character area of other characters other than the first character, the traversal ends, and the traversal end point of the current direction is determined;
[0036] Determine the coordinate data of the first area according to the coordinate data of the traversal end point of the character area of the first character in each direction;
[0037] Calculating specification data of the first area according to the coordinate data of the first area;
[0038] Segmenting the detection image data based on the coordinate data of the first area to determine first image data of the first area;
[0039] The first image data is analyzed to determine color distribution data of the first area; the color distribution data includes color types and distribution areas of each color.
[0040] In this solution, the specification data and color distribution data of the first area are input into a preset image recognition model, the drug samples in the database are traversed, the second recognition data of the second area is determined, and the color recognition score of the second recognition data is calculated, including:
[0041] Screening the drug samples in the database based on the specification data and color distribution data of the first area, and filtering the drug samples whose drug detection area is smaller than the specification data of the first area;
[0042] Traversing the drug detection surface of the remaining drug samples based on the specification data of the first area, and determining the traversed area with an image similarity greater than a fifth preset threshold as the second area;
[0043] determining the drug sample existing in the second area as second identification data;
[0044] determining a color recognition score of the second recognition data based on the image similarity and the area of each second area in the second recognition data;
[0045] The calculation method of the color recognition score of the second recognition data is expressed by the formula:
[0046] ;
[0047] Where p2 is the color recognition score of the second recognition data, S (q1) , S (q2) and S (qn) are the image areas of the first, second and nth second regions in the second recognition data, r (q1) 、r (q2) and r (qn) are the image similarities of the 1st, 2nd and nth second areas in the second recognition data respectively, and S1 is the image area of the drug detection surface of the second recognition data.
[0048] This plan also includes:
[0049] The calculation method of the recognition score of the third recognition data is expressed by the formula:
[0050] ;
[0051] Among them, p 3(x) is the recognition score of the third recognition data x, p 1(x) is the character recognition score of the recognition data x, p 2(x) is the color recognition score of the recognition data x, k p1 , k p2 are the influence weights of character recognition score and color recognition score respectively.
[0052] This plan also includes:
[0053] The drug identification data is assisted in verification through the drug inventory data.
[0054] A second aspect of the present invention provides a drug review system, comprising:
[0055] A data acquisition module, used to determine the data of drugs to be taken through the doctor's order data, and to acquire the detection image data through the detection equipment;
[0056] An image recognition module, used for performing image recognition on the detection image data to determine character image data of the detection image data;
[0057] A character recognition module, configured to analyze the character image data through a preset character recognition model to determine recognition data of a first character and a second character; determine first recognition data based on the recognition data of the first character and the second character, and calculate a character recognition score of the first recognition data;
[0058] A color recognition module is used to traverse the character area based on the first character, determine the coordinate data of the first area, analyze the detection image data based on the coordinate data of the first area, and determine the specification data and color distribution data of the first area; input the specification data and color distribution data of the first area into a preset image recognition model, traverse the drug samples in the database, determine that there is second recognition data of the second area, and calculate the color recognition score of the second recognition data;
[0059] A drug recognition module, configured to perform analysis based on the first recognition data and the second recognition data, weightedly calculate the character recognition score and the color recognition score of the same recognition data, and determine the recognition score of the third recognition data;
[0060] The drug review module is used to determine the drug recognition data using the third recognition data with the highest recognition score, compare the drug recognition data with the drug data to be obtained, and determine the drug review data.
[0061] A third aspect of the present invention provides a computer-readable storage medium, which includes a drug review method program. When the drug review method program is executed by a processor, the steps of the drug review method as described above are implemented.
[0062] The present invention discloses a drug review method and system, the method comprising: determining character image data by detecting image data; analyzing the character image data by a preset character recognition model to determine the recognition data of a first character and a second character; calculating the character recognition score of the first recognition data; determining the coordinate data of the first area based on the character area of the first character, and determining the specification data and color distribution data of the first area; traversing the drug samples in the database by a preset image recognition model to determine the second recognition data, and calculating the color recognition score of the second recognition data; calculating the recognition score of the third recognition data; determining the drug recognition data by the third recognition data with the highest recognition score, comparing the drug recognition data with the drug data to be taken, and determining the drug review data. The present invention reviews drugs by combining character recognition with color recognition of the area around the recognized characters, thereby improving the accuracy of drug review. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] Figure 1 A flow chart of a drug review method provided by the present invention is shown;
[0064] Figure 2 A flow chart showing a method for obtaining recognition data of a first character and a second character provided by the present invention is shown;
[0065] Figure 3 A flow chart showing a method for calculating a character recognition score of first recognition data provided by the present invention;
[0066] Figure 4 A block diagram of a drug review system provided by the present invention is shown. DETAILED DESCRIPTION
[0067] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0068] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.
[0069] Figure 1 A flow chart of a drug review method provided by the present invention is shown.
[0070] like Figure 1 As shown, the present invention discloses a drug review method, comprising:
[0071] S102, determining the drug data to be taken through the doctor's order data, and obtaining the detection image data through the detection equipment;
[0072] S104, performing image recognition on the detection image data to determine character image data of the detection image data;
[0073] S106, analyzing the character image data by using a preset character recognition model to determine recognition data of the first character and the second character;
[0074] S108, determining first recognition data according to the recognition data of the first character and the second character, and calculating a character recognition score of the first recognition data;
[0075] S110, traversing the character area based on the first character to determine coordinate data of the first area, analyzing the detection image data based on the coordinate data of the first area to determine specification data and color distribution data of the first area;
[0076] S112, inputting the specification data and color distribution data of the first area into a preset image recognition model, traversing the drug samples in the database, determining that there is second recognition data of the second area, and calculating the color recognition score of the second recognition data;
[0077] S114, analyzing the first recognition data and the second recognition data, performing weighted calculation on the character recognition score and the color recognition score of the same recognition data, and determining a recognition score of the third recognition data;
[0078] S116, determining drug identification data using the third identification data having the highest identification score, comparing the drug identification data with the drug data to be retrieved, and determining drug review data.
[0079] According to an embodiment of the present invention, medical order data can be obtained through multiple channels, such as the patient's ID number, medical insurance number, hospitalization ID number, bed number, and other medical information issued by the doctor in the associated system. The detection equipment can be a GigE industrial camera or other shooting equipment, and the detection image data of the drug in multiple directions is obtained through multiple detection equipment set in the drug review area.
[0080] The preset character recognition model and the preset image recognition model are both trained by collecting historical drug inspection image data during the drug review and drug inspection process. By analyzing the historical drug inspection image data, the drug recognition data of different drugs are counted, including drug name, specification, production batch number, shelf life and other information, and a corresponding drug recognition template is established. Each character image is labeled, and the character sample is determined. The drug recognition template and character sample are saved in the database, and the preset character recognition model and the preset image recognition model are established respectively.
[0081] The detected image data is subjected to image preprocessing such as image denoising and image correction, the preprocessed image data is subjected to grayscale processing, and a suitable grayscale threshold is selected for binarization processing, the binarized image data is subjected to edge extraction, and the character image data of the detected image data is determined based on the edge features.
[0082] Due to the placement of drugs and mutual occlusion, it is impossible to obtain a complete drug detection surface from a single detection direction. Through coordinate conversion, the detection image data obtained by detection equipment in different directions are converted to the same coordinate system, and the detection image data are spliced to obtain a complete drug detection surface. At the same time, duplicate data is deduplicated to avoid multiple analyses of the same drug. Among them, the drug detection surface is the detection image data of any side of the drug box, including the front, back, left side, right side, top, and bottom. The detection images of different sides can also be converted to the same coordinate system for splicing through coordinate conversion, and the image spliced from the six sides is determined as the drug detection surface.
[0083] Based on the preset character recognition model, the character image data is compared with the character samples in the database, and the first character and the second character are determined according to the character confidence of the sub-character image and the character sample in the character image data, and the character samples whose character confidence meets the preset conditions of the system are respectively determined as the recognition data of the first character and the second character. At the same time, the character image data can be recognized by OCR technology, and the recognition data of the characters can be determined by setting the character spacing, character width and height range, etc.
[0084] Based on the drug information template in the database, the recognition data of the first character and the second character are combined to determine one or more first recognition data, and the character recognition score of the first recognition data is calculated by the character confidence of each character in the first recognition data. Traverse the character area based on the first character, end the traversal when traversing to the edge area of the drug detection surface or the character area of other characters other than the first character, determine the traversal end point of the current direction, determine the coordinate data and the first image data of the first area according to the traversal end points of the character area of the first character in four directions, and determine the specification data and color distribution data of the first area according to the coordinate data of the first area. Input the first image data into the preset image recognition model, screen the drug samples according to the specification data of the first area, determine the drug samples with the second area whose color similarity is greater than the fifth preset threshold as the second recognition data, and calculate the color recognition score of the second recognition area according to the area area and relative image similarity of all the second areas in the second recognition area. Determine the recognition score of the third recognition data by weighted summation of the character recognition score and color recognition score of the same recognition area, determine the drug recognition data with the third recognition data with the highest recognition score, and compare it with the drug data to be taken in the doctor's order data to determine the drug review data, and complete the drug review. When the drug review fails, the detection equipment is started again to obtain the detection image data for analysis. When the number of repeated detections exceeds the system preset number, an alarm prompts.
[0085] In addition, when the drug review program is started, the required testing equipment and testing systems are loaded and initialized, including the loading and training of template images, so that when performing photo recognition, the image can be passed in to directly run and obtain the result, thereby improving the recognition speed; multi-threading technology is used in the drug review process, and multiple drugs can be recognized and output at the same time, thereby improving the recognition speed; the output of the result adopts event registration, that is, registering a recognition event completion processing function, and the main interface does not need to poll and wait for the result. The function can be automatically triggered after all the recognition tools are run, which can prevent the page from waiting in suspended animation and reduce CPU usage; such as in the drug review process, after the photo review of the current doctor's order is completed, the review completion event is automatically triggered, and the photo scanning process is exited, and the main interface no longer keeps polling whether there is a photo action.
[0086] According to an embodiment of the present invention, performing image recognition on the detection image data to determine character image data of the detection image data includes:
[0087] Performing image denoising and image correction on the detected image data to obtain preprocessed image data;
[0088] Binarization processing is performed on the pre-processed image data to determine the binary image data;
[0089] Perform edge extraction on the binary image data and determine the edge features;
[0090] By analyzing the edge features, character image data of the detection image data is determined.
[0091] It should be noted that due to the influence of the shooting environment, such as uneven light intensity, noise exists in the acquired detection image data, image quality decreases, and subsequent image analysis and recognition are affected. Therefore, the detection image data is denoised by Gaussian filtering and other methods. Due to the influence of the placement of medicines, the detection image data may be tilted. The detection image data is tilted by the perspective correction method, and the coordinate positions of the feature points such as the corner points, edges and boundaries of the drug detection surface of the drug box in the detection image data are determined. The tilt direction of the image is detected by using algorithms such as Hough circle transformation, and the corresponding correction matrix is calculated. The detection image data is affine transformed to complete the image correction. The system performs grayscale processing on the preprocessed image data. By selecting a suitable grayscale threshold, different grayscale values are processed into two contrasting grayscale values of 0 and 255, and the character part and the non-character background part in the drug detection surface are represented separately, completing the binarization processing of the preprocessed image data. By extracting the edge of the binary image data, the binary image data is segmented by the edge feature to determine the character image data of the detection image data.
[0092] Figure 2 A flow chart of a method for acquiring recognition data of a first character and a second character provided by the present invention is shown.
[0093] like Figure 2 As shown, according to an embodiment of the present invention, character image data is analyzed by a preset character recognition model to determine recognition data of a first character and a second character, including:
[0094] S202, comparing the character image data with the character samples in the database to determine the character confidence of the sub-character images and the character samples in the character image data;
[0095] S204, determining the sub-character image whose maximum character confidence is greater than a first preset threshold as the first character, and the character sample corresponding to the maximum character confidence is the recognition data of the first character;
[0096] S206, determining the sub-character image whose maximum character confidence is between the first preset threshold and the second preset threshold as the second character, and determining the character sample whose character confidence is greater than the second preset threshold as the recognition data of the second character.
[0097] It should be noted that the character image data may be composed of multiple character images. The character image data is divided into multiple sub-character images of a single character through the character width and height range set by the system. Each sub-character image is compared with the character sample in the database, and the similarity between the sub-character image and the character sample is calculated. The recognition result between each sub-character image and the character sample is represented by the character confidence. Among them, the higher the character confidence, the higher the recognition accuracy of the sub-character image. When the maximum character confidence is greater than the first preset threshold, the character recognition accuracy meets the preset recognition requirements of the system, and the character sample corresponding to the maximum character confidence is determined as the recognition data of the sub-character image, and the sub-character image is determined as the first character, that is, the character image recognition result is determined. When the maximum character confidence is between the first preset threshold and the second preset threshold, it means that the final recognition result of the sub-character image cannot be determined, and the sub-character image is determined as the second character. The character sample with a character confidence greater than the second preset threshold is determined as the pending recognition result of the sub-character image, that is, the recognition data of the second character.
[0098] In addition, when a sub-character image has multiple character confidences greater than a first preset threshold, the sub-character image is determined as a second character, and all character samples with character confidences greater than a second preset threshold are determined as recognition data of the second character.
[0099] The first preset threshold and the second preset threshold are set by those skilled in the art according to actual needs.
[0100] Figure 3 A flow chart of a method for calculating a character recognition score of first recognition data provided by the present invention is shown.
[0101] like Figure 3 As shown, according to an embodiment of the present invention, determining the first recognition data according to the recognition data of the first character and the second character, and calculating the character recognition score of the first recognition data include:
[0102] S302, combining the recognition data of the first character and the second character based on the drug information template in the database to determine one or more first recognition data;
[0103] S304, accumulating the character confidence of each character in the first recognition data to determine a recognition score of each first recognition data;
[0104] S306, when there is only one first recognition data whose recognition score is greater than the third preset threshold, determining the first recognition data as the drug recognition data of the detection image data;
[0105] S308 , on the contrary, filtering the first recognition data whose recognition scores are less than the fourth preset threshold, and calculating the character recognition scores of the remaining first recognition data according to the character confidences of the first character and the second character.
[0106] It should be noted that the drug information template includes information such as drug name, specification, production batch number, shelf life, etc., and also includes the number of characters and character spacing distance in each drug information. According to the coordinate data of each first character and second character, the recognition data of the first character and the second character are combined. The recognition data of the first character is a fixed character, and the recognition data of the second character is a plurality of candidate characters. The recognition data corresponding to each coordinate data is determined, and a character string consisting of a plurality of characters is generated to obtain the first recognition data. In the first recognition data, the recognition results of other characters other than the first character and the second character are determined by the corresponding drug information template.
[0107] The character confidence of each character in the first recognition data includes the character confidence of the first character, the second character, other characters and each character sample in the corresponding drug information template. The recognition score of the first recognition data is determined by accumulating the character confidence of each character and the corresponding character sample. When there is only one first recognition data with a recognition score greater than the third preset threshold, it means that there is unique recognition data that meets the system recognition requirements, and the first recognition data is output as the drug recognition data of the current detection image data; on the contrary, if there are multiple first recognition data with a recognition score greater than the third preset threshold or there is no first recognition data with a recognition score greater than the third preset threshold, the character recognition score of each first recognition data is calculated. Among them, the first recognition data with a recognition score less than the fourth preset threshold can basically be judged as not the drug recognition data of the current detection image data, and it is filtered to reduce the data size of subsequent analysis and improve the data analysis speed.
[0108] The third preset threshold and the fourth preset threshold are set by those skilled in the art according to actual needs, and the value of the third preset threshold is greater than the fourth preset threshold.
[0109] According to an embodiment of the present invention, it also includes:
[0110] The calculation method of the character recognition score of the first recognition data is expressed by the formula:
[0111] ;
[0112] Where p1 is the character recognition score of the first recognition data, P 1(i) is the character confidence of the i-th first character in the first recognition data, n is the total number of first characters in the first recognition data, k1 is the influence weight of the character confidence of the first character, P 2(j)is the character confidence of the jth second character in the first recognition data, m is the total number of second characters in the first recognition data, and k2 is the influence weight of the character confidence of the second character.
[0113] It should be noted that the character recognition score of the first recognition data is determined according to the ratio of the sum of the weighted calculations of the character confidences of all the first characters and the second characters in the first recognition data to the number of the first characters and the second characters. The influence weight of the character confidence of each first character is the same, represented by k1, and the influence weight of the character confidence of each second character is the same, represented by k2.
[0114] According to an embodiment of the present invention, traversing a character area based on a first character to determine coordinate data of the first area, analyzing the detection image data based on the coordinate data of the first area to determine specification data and color distribution data of the first area includes:
[0115] Determine the character area of each character according to the coordinate data of the character;
[0116] A traversal point is randomly generated based on the edge of the character area of the first character, and the traversal is performed clockwise around the edge of the character area of the first character. When the traversal reaches the edge area of the drug detection surface or the character area of other characters other than the first character, the traversal ends, and the traversal end point of the current direction is determined;
[0117] Determine the coordinate data of the first area according to the coordinate data of the traversal end point of the character area of the first character in each direction;
[0118] Calculate specification data of the first area according to the coordinate data of the first area;
[0119] Segmenting the detection image data based on the coordinate data of the first area to determine first image data of the first area;
[0120] The first image data is analyzed to determine color distribution data of the first area; the color distribution data includes color types and distribution areas of each color.
[0121] It should be noted that the character area is a rectangular area. The coordinate axis is established with the center coordinates of the drug detection surface in the detection image data as the coordinate origin. The x and y axes represent the length and width of the drug detection surface respectively. The minimum circumscribed rectangle, that is, the character area of the character, is determined by the coordinate data of the character.
[0122] During the traversal process, the coordinate data of the edge pixels of the character area of the first character and the traversed pixels are traversed clockwise around the character area of the first character. When the coordinates of the traversal point and the edge area of the drug detection surface or the character areas of other characters other than the first character coincide with each other, the traversal in the current direction is terminated, and the previous traversal coordinates of the traversal point are determined as the traversal end point of the current direction. In the subsequent traversal process, the current direction is no longer traversed. After the traversal end points of the character area of the first character in the upper, lower, left, and right directions are determined, the current traversal is terminated, and the rectangular area enclosed by the coordinate data corresponding to the traversal end points in the upper, lower, left, and right directions of the character area of the first character is determined as the first area.
[0123] Wherein, each character region of the first character corresponds to a first region, and the character regions of adjacent first characters can be analyzed as a whole region to determine the first region.
[0124] The detection image data is segmented and cropped according to the coordinate data of each edge of the first area to determine the first image data of the first area. The first image data is divided into a plurality of color areas composed of different colors by analyzing the color data of each pixel in the first image data and setting the color threshold interval, and the color represented by each color area is represented by the middle value of the corresponding color threshold interval. The color type is determined according to the number of color areas in the first image data, and the distribution area of each color is determined according to the coordinate data of each color area.
[0125] According to an embodiment of the present invention, the specification data and color distribution data of the first area are input into a preset image recognition model, the drug samples in the database are traversed, the second recognition data of the second area is determined, and the color recognition score of the second recognition data is calculated, including:
[0126] Screening the drug samples in the database based on the specification data and color distribution data of the first area, filtering the drug samples whose drug detection area is smaller than the specification data of the first area;
[0127] Traversing the drug detection surface of the remaining drug samples based on the specification data of the first area, and determining the traversed area with an image similarity greater than a fifth preset threshold as the second area;
[0128] determining the drug sample existing in the second area as second identification data;
[0129] determining a color recognition score of the second recognition data based on the image similarity and the area of each second area in the second recognition data;
[0130] The calculation method of the color recognition score of the second recognition data is expressed by the formula:
[0131] ;
[0132] Where p2 is the color recognition score of the second recognition data, S (q1) , S (q2) and S (qn) are the image areas of the first, second and nth second regions in the second recognition data, r (q1) 、r (q2) and r (qn) are the image similarities of the 1st, 2nd and nth second areas in the second recognition data respectively, and S1 is the image area of the drug detection surface of the second recognition data.
[0133] It should be noted that the drug detection surfaces of the drug samples in the database are screened according to the specification data of the first area, and the drug samples whose drug detection surfaces are smaller than the specification data of the first area are filtered to reduce the number of samples. A traversal frame is generated based on the specification data of the first area to traverse the drug detection surfaces of the remaining drug samples. The traversal frame traverses the drug detection surfaces of the remaining drug samples in the order from left to right and from top to bottom according to the traversal pixel distance preset by the system. The color data (color type and distribution area of each color) of each pixel point in the image data in the traversal frame and the first image data are analyzed by a preset image recognition model, and the image similarity between the two is calculated. When the image similarity is greater than the fifth preset threshold, the traversal area corresponding to the current traversal frame is determined as the second area, and the drug sample currently analyzed is determined as the second identification data, that is, the identification data determined by the local area color similarity. Among them, each first area can only have one corresponding second area on the drug detection surface of the same drug sample.
[0134] After all the first regions in the detected image data are analyzed, the color recognition score of each second recognition data is calculated in turn according to the similarity between each second region in the second recognition data and the corresponding image.
[0135] In addition, when there are multiple second areas corresponding to different first areas in the second identification data, the second area can be verified according to the distribution relationship (relative direction, distance, etc.) between the first areas. If the distribution relationship between the multiple second areas is the same as the distribution relationship between the corresponding multiple first areas, the verification is successful; otherwise, the verification fails, and the current second identification data is not the drug identification data of the detection image data.
[0136] According to an embodiment of the present invention, it also includes:
[0137] The calculation method of the recognition score of the third recognition data is expressed by the formula:
[0138] ;
[0139] Among them, p 3(x) is the recognition score of the third recognition data x, p 1(x) is the character recognition score of the recognition data x, p 2(x) is the color recognition score of the recognition data x, k p1 , k p2 are the influence weights of character recognition score and color recognition score respectively.
[0140] It should be noted that the recognition data x includes the first recognition data and the second recognition data. When the recognition data x does not contain a character recognition score or a color recognition score, the corresponding score is set to 0 by default.
[0141] According to an embodiment of the present invention, it also includes:
[0142] The drug identification data is assisted in verification through the drug inventory data.
[0143] It should be noted that the accuracy of the drug identification data is verified by comparing the production batch number, production date and shelf life in the drug storage data with the first and second characters of the same type of data in the drug identification data. If there are different characters between the two, the drug identification data is wrong, and the third identification data with the highest next recognition score is selected to determine the drug identification data for verification again until the two are exactly the same, and the final drug identification data is determined.
[0144] Figure 4 A block diagram of a drug review system provided by the present invention is shown.
[0145] like Figure 4 As shown, the second aspect of the present invention provides a drug review system, comprising:
[0146] A data acquisition module, used to determine the data of drugs to be taken through the doctor's order data, and to acquire the detection image data through the detection equipment;
[0147] An image recognition module, used to perform image recognition on the detection image data and determine character image data of the detection image data;
[0148] A character recognition module is used to analyze the character image data through a preset character recognition model to determine the recognition data of the first character and the second character; determine the first recognition data according to the recognition data of the first character and the second character, and calculate the character recognition score of the first recognition data;
[0149] A color recognition module is used to traverse the character area based on the first character, determine the coordinate data of the first area, analyze the detection image data based on the coordinate data of the first area, and determine the specification data and color distribution data of the first area; input the specification data and color distribution data of the first area into a preset image recognition model, traverse the drug samples in the database, determine that there is second recognition data of the second area, and calculate the color recognition score of the second recognition data;
[0150] A drug recognition module, configured to perform analysis based on the first recognition data and the second recognition data, weightedly calculate the character recognition score and the color recognition score of the same recognition data, and determine the recognition score of the third recognition data;
[0151] The drug review module is used to determine the drug recognition data using the third recognition data with the highest recognition score, compare the drug recognition data with the drug data to be taken, and determine the drug review data.
[0152] A third aspect of the present invention provides a computer-readable storage medium, which includes a drug review method program. When the drug review method program is executed by a processor, the steps of the above drug review method are implemented.
[0153] The present invention discloses a drug review method and system, the method comprising: determining character image data by detecting image data; analyzing the character image data by a preset character recognition model to determine the recognition data of a first character and a second character; calculating the character recognition score of the first recognition data; determining the coordinate data of the first area based on the character area of the first character, and determining the specification data and color distribution data of the first area; traversing the drug samples in the database by a preset image recognition model to determine the second recognition data, and calculating the color recognition score of the second recognition data; calculating the recognition score of the third recognition data; determining the drug recognition data by the third recognition data with the highest recognition score, comparing the drug recognition data with the drug data to be taken, and determining the drug review data. The present invention reviews drugs by combining character recognition with color recognition of the area around the recognized characters, thereby improving the accuracy of drug review.
[0154] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0155] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0156] In addition, all functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0157] A person of ordinary skill in the art can understand that: all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: a mobile storage device, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0158] Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present invention can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, magnetic disks or optical disks.
Claims
1. A drug review method, characterized in that: include: Determine the data of the medicines to be taken through the doctor's order data, and obtain the detection image data through the detection equipment; Performing image recognition on the detection image data to determine character image data of the detection image data; Analyzing the character image data by using a preset character recognition model to determine recognition data of a first character and a second character; determining first recognition data according to the recognition data of the first character and the second character, and calculating a character recognition score of the first recognition data; Traversing the character area based on the first character to determine coordinate data of the first area, analyzing the detection image data based on the coordinate data of the first area to determine specification data and color distribution data of the first area; Inputting the specification data and color distribution data of the first area into a preset image recognition model, traversing the drug samples in the database, determining that there is second recognition data of the second area, and calculating the color recognition score of the second recognition data; Based on the analysis of the first recognition data and the second recognition data, a character recognition score and a color recognition score of the same recognition data are weighted to determine a recognition score of the third recognition data; Determine drug identification data by using the third identification data with the highest identification score, and compare the drug identification data with the drug data to be taken to determine drug review data; The character image data is analyzed by a preset character recognition model to determine recognition data of the first character and the second character, including: Comparing the character image data with character samples in a database to determine character confidences of sub-character images and character samples in the character image data; Determine the sub-character image whose maximum character confidence is greater than a first preset threshold as the first character, and the character sample corresponding to the maximum character confidence is the recognition data of the first character; Determine the sub-character image whose maximum character confidence is between the first preset threshold and the second preset threshold as the second character, and determine the character sample whose character confidence is greater than the second preset threshold as the recognition data of the second character; The step of determining the first recognition data according to the recognition data of the first character and the second character, and calculating the character recognition score of the first recognition data comprises: Based on the drug information template in the database, the identification data of the first character and the second character are combined to determine one or more first identification data; Accumulating the character confidence of each character in the first recognition data to determine a recognition score for each first recognition data; When there is only one first recognition data whose recognition score is greater than a third preset threshold, determining the first recognition data as the drug recognition data of the detection image data; On the contrary, the first recognition data whose recognition scores are less than the fourth preset threshold are filtered, and the character recognition scores of the remaining first recognition data are calculated according to the character confidences of the first character and the second character; The step of inputting the specification data and color distribution data of the first area into a preset image recognition model, traversing the drug samples in the database, determining that there is second recognition data of the second area, and calculating the color recognition score of the second recognition data includes: Screening the drug samples in the database based on the specification data and color distribution data of the first area, and filtering the drug samples whose drug detection area is smaller than the specification data of the first area; Traversing the drug detection surface of the remaining drug samples based on the specification data of the first area, and determining the traversed area with an image similarity greater than a fifth preset threshold as the second area; determining the drug sample existing in the second area as second identification data; determining a color recognition score of the second recognition data based on the image similarity and the area of each second area in the second recognition data; The calculation method of the color recognition score of the second recognition data is expressed by the formula: ; Where p2 is the color recognition score of the second recognition data, S (q1) , S (q2) and S (qn) are the image areas of the first, second and nth second regions in the second recognition data, r (q1) 、r (q2) and r (qn) are the image similarities of the 1st, 2nd and nth second areas in the second recognition data respectively, and S1 is the image area of the drug detection surface of the second recognition data.
2. The drug review method according to claim 1, characterized in that: The performing image recognition on the detection image data to determine the character image data of the detection image data includes: Performing image denoising and image correction on the detected image data to obtain preprocessed image data; Binarization is performed on the pre-processed image data to determine binary image data; Performing edge extraction on the binary image data to determine edge features; By analyzing the edge features, character image data of the detection image data is determined.
3. The drug review method according to claim 1, characterized in that: Also includes: The calculation method of the character recognition score of the first recognition data is expressed by the formula: ; Where p1 is the character recognition score of the first recognition data, P 1(i) is the character confidence of the i-th first character in the first recognition data, n is the total number of first characters in the first recognition data, k1 is the influence weight of the character confidence of the first character, P 2(j) is the character confidence of the jth second character in the first recognition data, m is the total number of second characters in the first recognition data, and k2 is the influence weight of the character confidence of the second character.
4. The drug review method according to claim 1, characterized in that: The traversing of the character area based on the first character to determine the coordinate data of the first area, analyzing the detection image data based on the coordinate data of the first area to determine the specification data and color distribution data of the first area, includes: Determine the character area of each character according to the coordinate data of the character; A traversal point is randomly generated based on the edge of the character area of the first character, and the traversal is performed clockwise around the edge of the character area of the first character. When the traversal reaches the edge area of the drug detection surface or the character area of other characters other than the first character, the traversal ends, and the traversal end point of the current direction is determined; Determine the coordinate data of the first area according to the coordinate data of the traversal end point of the character area of the first character in each direction; Calculating specification data of the first area according to the coordinate data of the first area; Segmenting the detection image data based on the coordinate data of the first area to determine first image data of the first area; The first image data is analyzed to determine color distribution data of the first area; the color distribution data includes color types and distribution areas of each color.
5. The drug review method according to claim 1, characterized in that: Also includes: The calculation method of the recognition score of the third recognition data is expressed by the formula: ; Among them, p 3(x) is the recognition score of the third recognition data x, p 1(x) is the character recognition score of the recognition data x, p 2(x) is the color recognition score of the recognition data x, k p1 , k p2 are the influence weights of character recognition score and color recognition score respectively.
6. The drug review method according to claim 1, characterized in that: Also includes: The drug identification data is assisted in verification through the drug inventory data.
7. A drug review system, used to implement the drug review method according to any one of claims 1 to 6, characterized in that: include: A data acquisition module, used to determine the data of drugs to be taken through the doctor's order data, and to acquire the detection image data through the detection equipment; An image recognition module, used for performing image recognition on the detection image data to determine character image data of the detection image data; A character recognition module, configured to analyze the character image data through a preset character recognition model to determine recognition data of a first character and a second character; determine first recognition data based on the recognition data of the first character and the second character, and calculate a character recognition score of the first recognition data; A color recognition module is used to traverse the character area based on the first character to determine the coordinate data of the first area, analyze the detection image data based on the coordinate data of the first area, and determine the specification data and color distribution data of the first area; input the specification data and color distribution data of the first area into a preset image recognition model, traverse the drug samples in the database, determine that there is second recognition data of the second area, and calculate the color recognition score of the second recognition data; A drug recognition module, configured to perform analysis based on the first recognition data and the second recognition data, weightedly calculate the character recognition score and the color recognition score of the same recognition data, and determine the recognition score of the third recognition data; A drug review module, used to determine drug recognition data using the third recognition data with the highest recognition score, and compare the drug recognition data with the drug data to be retrieved to determine drug review data; The character image data is analyzed by a preset character recognition model to determine recognition data of the first character and the second character, including: Comparing the character image data with character samples in a database to determine character confidences of sub-character images and character samples in the character image data; Determine the sub-character image whose maximum character confidence is greater than a first preset threshold as the first character, and the character sample corresponding to the maximum character confidence is the recognition data of the first character; Determine the sub-character image whose maximum character confidence is between the first preset threshold and the second preset threshold as the second character, and determine the character sample whose character confidence is greater than the second preset threshold as the recognition data of the second character; The step of determining the first recognition data according to the recognition data of the first character and the second character, and calculating the character recognition score of the first recognition data comprises: Based on the drug information template in the database, the identification data of the first character and the second character are combined to determine one or more first identification data; Accumulating the character confidence of each character in the first recognition data to determine a recognition score for each first recognition data; When there is only one first recognition data whose recognition score is greater than a third preset threshold, determining the first recognition data as the drug recognition data of the detection image data; On the contrary, the first recognition data whose recognition scores are less than the fourth preset threshold are filtered, and the character recognition scores of the remaining first recognition data are calculated according to the character confidences of the first character and the second character; The step of inputting the specification data and color distribution data of the first area into a preset image recognition model, traversing the drug samples in the database, determining that there is second recognition data of the second area, and calculating the color recognition score of the second recognition data includes: Screening the drug samples in the database based on the specification data and color distribution data of the first area, and filtering the drug samples whose drug detection area is smaller than the specification data of the first area; Traversing the drug detection surface of the remaining drug samples based on the specification data of the first area, and determining the traversed area with an image similarity greater than a fifth preset threshold as the second area; determining the drug sample existing in the second area as second identification data; determining a color recognition score of the second recognition data based on the image similarity and the area of each second area in the second recognition data; The calculation method of the color recognition score of the second recognition data is expressed by the formula: ; Where p2 is the color recognition score of the second recognition data, S (q1) , S (q2) and S (qn) are the image areas of the first, second and nth second regions in the second recognition data, r (q1) 、r (q2) and r (qn) are the image similarities of the 1st, 2nd and nth second areas in the second recognition data respectively, and S1 is the image area of the drug detection surface of the second recognition data.
