Drug traceability code acquisition method, system and device based on image recognition and medium

The image recognition method for pharmaceutical product codes addresses inefficiencies by preprocessing, edge detection, and barcode analysis, achieving high accuracy and adaptability, ensuring product safety and efficient management.

CN119647502APending Publication Date: 2025-03-18SUZHOU IRON TECH CO LTD
View PDF 0 Cites 6 Cited by

Patent Information

Application Number
CN202411616948.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-13
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

Current methods for collecting pharmaceutical product codes in hospitals are inefficient and prone to errors due to the complexity of backgrounds, lighting changes, and code deformation, leading to low scanning efficiency and accuracy.

Method used

A method involving image recognition that includes preprocessing, edge detection, region segmentation, image correction, and barcode analysis to accurately extract and verify pharmaceutical product codes, with optional steps for random sampling and validation through third-party platforms.

Benefits of technology

This approach significantly enhances the speed and accuracy of pharmaceutical product code collection, adapts to complex environments, and ensures product safety by verifying code validity, facilitating efficient management and tracking.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119647502A_ABST
    Figure CN119647502A_ABST
Patent Text Reader

Abstract

The invention discloses a drug traceability code acquisition method, system and device based on image recognition, and a medium. The method comprises the steps of obtaining a drug package image; preprocessing the medicine packaging image, and performing edge detection, region segmentation, image correction and barcode analysis on the preprocessed medicine packaging image to obtain medicine traceability code information; obtaining prescription data, and checking the drug traceability code information according to the prescription data; and when the drug traceability code information is checked to be correct, carrying out associative storage on the drug traceability code information and the prescription data. According to the invention, drug traceability code information can be rapidly and accurately identified, and environments such as complex backgrounds, illumination changes, traceability code deformation and the like can be adapted; meanwhile, multiple drug traceability codes can be collected, the purpose of batch collection is achieved, supervision of a drug dispensing end is achieved, medication safety of patients is ensured, drug management can be perfected, and subsequent drug traceability is facilitated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of medical treatment and artificial intelligence, and in particular to a method, system, device and medium for collecting drug traceability codes based on image recognition. Background Art

[0002] The drug traceability code is a one-dimensional or two-dimensional code consisting of a string of numbers and letters printed on drug packaging by drug manufacturers and issued by the State Drug Administration. Through the drug traceability code, the production, circulation, and sales of drugs can be traced, drug quality problems can be discovered and handled in a timely manner, and patient medication safety can be guaranteed. Therefore, the collection of drug traceability codes is extremely important.

[0003] Currently, drug traceability codes are mostly collected at the hospital's drug dispensing end by scanning the electronic supervision code on each medicine box one by one with a barcode scanner. The workload of the window pharmacist in dispensing medicines is large, so this method is prone to omissions. At the same time, this method takes a long time to scan codes and has low drug dispensing efficiency, resulting in long waiting times at the dispensing window and long queues for medicine, affecting patients' medical experience.

[0004] With the development of image processing technology, the use of image recognition to collect drug traceability codes can improve the scanning efficiency and recognition accuracy of drug traceability codes, and thus the technology of drug traceability codes based on image recognition has gradually attracted attention. However, the existing image recognition methods still have certain limitations when dealing with complex backgrounds, lighting changes, and traceability code deformation, resulting in the collection efficiency and accuracy of drug traceability codes not meeting the requirements. Summary of the invention

[0005] In view of this, the present invention provides a method, system, device and medium for collecting drug traceability codes based on image recognition to solve the problem of low efficiency and accuracy in collecting drug traceability codes using existing image recognition technology.

[0006] The present invention provides a method for collecting drug traceability codes based on image recognition, the method comprising:

[0007] Acquire drug packaging images;

[0008] Preprocessing the drug packaging image, and performing edge detection, region segmentation, image correction and barcode analysis on the preprocessed drug packaging image to obtain drug traceability code information;

[0009] Obtaining prescription data, and verifying the drug traceability code information according to the prescription data;

[0010] When the drug traceability code information is verified to be correct, the drug traceability code information and the prescription data are associated and stored.

[0011] Optionally, the pre-processed drug packaging image is subjected to edge detection, region segmentation, image correction and barcode analysis to obtain drug traceability code information, including:

[0012] Performing edge detection on the preprocessed drug packaging image, and determining a barcode area image from the drug packaging image;

[0013] Performing region segmentation on the barcode region image to obtain an initial barcode image;

[0014] Performing image correction on the initial barcode image to obtain a target barcode image;

[0015] The target barcode image is subjected to barcode analysis to obtain the drug traceability code information.

[0016] Optionally, performing edge detection on the preprocessed drug package image to determine a barcode region image from the drug package image includes:

[0017] Performing edge detection on the preprocessed drug packaging image to obtain multiple image edges;

[0018] Based on all image edges, multiple regional contour images are preliminarily constructed;

[0019] Respectively obtain the contour area and the first minimum circumscribed rectangle area of ​​each region contour image, and respectively calculate the area ratio between the contour area of ​​each region contour image and the first minimum circumscribed rectangle area;

[0020] Determine a plurality of first potential barcode regions from all the region contour images based on the contour area and area ratio of each region contour image;

[0021] Identify a plurality of black regions in each first potential barcode region, and respectively calculate an inertia ratio corresponding to each black region in each first potential barcode region;

[0022] Based on the inertia ratio of all black areas in each first potential barcode area, a plurality of second potential barcode areas are determined from all first potential barcode images, and at least one suspected black stripe corresponding to each second potential barcode area and the center coordinates of each suspected black stripe are determined from all black areas of each second potential barcode area;

[0023] A random sampling consensus method is used to fit the center point straight line of the black stripes of each second potential barcode area;

[0024] In each second potential barcode area, determine whether the center coordinates of each suspected black stripe fall on the corresponding black stripe center point straight line; if so, determine the corresponding second potential barcode area as the target barcode area; otherwise, determine the corresponding second potential barcode area as a non-barcode area;

[0025] According to all target barcode regions, the barcode region image is obtained.

[0026] Optionally, based on the contour area and area ratio of each region contour image, a plurality of first potential barcode regions are determined from all region contour images, including:

[0027] Select any regional contour image, and determine whether the contour area of ​​the selected regional contour image is less than a first preset threshold and whether the area ratio is less than a second preset threshold;

[0028] When the contour area of ​​the selected region contour image is smaller than the first preset threshold value and the area ratio is smaller than the second preset threshold value, the selected region contour image is determined to be a non-barcode region; otherwise, the selected region contour image is determined to be a first potential barcode region;

[0029] Each area contour image is traversed, and a plurality of first potential barcode areas are determined from all area contour images in the same manner.

[0030] Optionally, based on the inertia ratio of all black areas in each first potential barcode area, a plurality of second potential barcode areas are determined from all first potential barcode images, and at least one suspected black stripe corresponding to each second potential barcode area and the center coordinates of each suspected black stripe are respectively determined from all black areas of each second potential barcode area, including:

[0031] Select any first potential barcode area, and determine whether the inertia ratios of all black areas in the selected first potential barcode area are less than a third preset threshold; if so, determine that the selected first potential barcode area is a non-barcode area; otherwise, determine that the selected first potential barcode area is a second potential barcode area;

[0032] When the selected first potential barcode area is the second potential barcode area, a black area in the second potential barcode area whose inertia ratio is greater than or equal to a third preset threshold is determined as a suspected black stripe, and the center coordinates of each suspected black stripe in the second potential barcode area are identified;

[0033] Each first potential barcode area is traversed, and multiple second potential barcode areas are determined from all first potential barcode images in the same way, and at least one suspected black stripe corresponding to each second potential barcode area and the center coordinates of each suspected black stripe are determined respectively.

[0034] Optionally, performing region segmentation on the barcode region image to obtain an initial barcode image includes:

[0035] Performing region segmentation on the barcode region image to obtain a plurality of segmented barcode sub-images;

[0036] Calculate the second minimum bounding rectangle corresponding to each segmented barcode sub-image respectively, and determine the coordinates of four rectangle vertices corresponding to each second minimum bounding rectangle;

[0037] Identify the barcode centerline direction and the barcode vertical direction of the barcode area image, wherein the barcode vertical direction is greater than the barcode centerline direction;

[0038] For each segmented barcode sub-image, four rectangle vertex coordinates are used as references, and boundary searches are performed in the barcode centerline direction and the barcode vertical direction to determine the four barcode boundaries of each segmented barcode sub-image;

[0039] According to the four barcode boundaries of each segmented barcode sub-image, the four rectangle vertex coordinates corresponding to the second minimum circumscribed rectangle of each segmented barcode sub-image are adjusted to obtain four updated vertex coordinates of each segmented barcode sub-image;

[0040] According to the four updated vertex coordinates of each segmented barcode sub-image, an updated barcode sub-image corresponding to each segmented barcode sub-image is determined;

[0041] The initial barcode image is obtained according to all updated barcode sub-images.

[0042] Optionally, performing image correction on the initial barcode image to obtain a target barcode image includes:

[0043] Calculating the tilt angle of each updated barcode sub-image according to the four updated vertex coordinates corresponding to each updated barcode sub-image in the initial barcode image;

[0044] Obtaining the rectangular size corresponding to each updated barcode sub-image in the initial barcode image;

[0045] According to the rectangular size and tilt angle corresponding to each updated barcode sub-image, each updated barcode sub-image is rotationally corrected to obtain a corrected barcode sub-image corresponding to each updated barcode sub-image;

[0046] The target barcode image is obtained according to all corrected barcode sub-images.

[0047] Optionally, the barcode parsing of the target barcode image to obtain the drug traceability code information includes:

[0048] Calling a third-party tool library to scan and identify the target barcode image to obtain multiple element edges;

[0049] Calculating the distance between the edges of each two adjacent elements respectively to obtain multiple barcode element width data of the target barcode image;

[0050] All barcode element width data are placed in a preset sliding window array, each barcode element width data is converted into binary data in turn according to a preset encoding rule, and all binary data are assembled into characters to obtain the drug traceability code information.

[0051] Optionally, the checking the drug traceability code information according to the prescription data includes:

[0052] Find out drug data according to the drug traceability code information;

[0053] Determine whether the drug data is consistent with the drug information in the prescription data. If so, the verification is correct; otherwise, the verification is incorrect.

[0054] Optionally, before checking the drug traceability code information according to the prescription data, the method further includes:

[0055] Verify whether the drug traceability code information is valid;

[0056] When the drug traceability code information is verified to be valid, the drug traceability code information is checked according to the prescription data.

[0057] Optionally, the verifying whether the drug traceability code information is valid includes:

[0058] Sending the drug traceability code information to a third-party traceability code verification platform, and searching the drug traceability code information on the third-party traceability code verification platform;

[0059] If the drug traceability code information is found in the third-party traceability code verification platform, the validity period of the batch number corresponding to the drug traceability code information is returned; when the validity period of the batch number is after the current date, the drug traceability code information is determined to be valid, otherwise the drug traceability code information is determined to be invalid;

[0060] If the drug traceability code information is not found in the third-party traceability code verification platform, the drug traceability code information is determined to be invalid.

[0061] Optionally, when the drug traceability code information is verified to be correct, the drug traceability code information and the prescription data are associated and stored, including:

[0062] When the drug traceability code information is verified to be correct, the verified drug traceability code information is associated with the corresponding prescription data to generate associated information, and the associated drug traceability code information, the corresponding prescription data and the associated information are stored;

[0063] The associated information is uploaded to a third-party platform.

[0064] Optionally, the preprocessing of the drug packaging image includes:

[0065] grayscale the drug packaging image to obtain a grayscale image;

[0066] Performing noise reduction and binarization processing on the grayscale image to obtain a binarized image;

[0067] The binary image is subjected to dilation and corrosion processing to complete the preprocessing of the drug packaging image.

[0068] In addition, the present invention also provides a drug traceability code collection system based on image recognition, which is applied to the aforementioned drug traceability code collection method based on image recognition, and the system includes:

[0069] An image acquisition module, used for acquiring images of drug packaging;

[0070] An image processing module, used for preprocessing drug packaging images;

[0071] An image recognition module is used to perform edge detection, region segmentation, image correction and barcode analysis on the preprocessed drug packaging image to obtain drug traceability code information;

[0072] A data verification module, used to obtain prescription data and verify the drug traceability code information according to the prescription data;

[0073] The associated storage module is used to associate and store the drug traceability code information with the prescription data when the data verification module verifies that the drug traceability code information is correct.

[0074] In addition, the present invention also provides a drug traceability code collection device based on image recognition, including a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the method steps in the aforementioned drug traceability code collection method based on image recognition when running.

[0075] In addition, the present invention also provides a computer storage medium, which includes: at least one instruction, which implements the method steps in the aforementioned image recognition-based drug traceability code collection method when the instruction is executed by the computer.

[0076] The beneficial effects of the present invention are as follows: firstly, a drug packaging image is obtained, and the image includes an image of a drug traceability code on the drug packaging. By preprocessing the drug packaging image, the purpose of optimizing the image effect can be achieved, so that the drug traceability code information can be identified more quickly and accurately in the subsequent process; secondly, by performing edge detection, region segmentation, image correction and barcode analysis on the preprocessed drug packaging image, the drug traceability code can be decoded and collected with high accuracy and high efficiency, and can adapt to environments such as complex backgrounds, changes in illumination and deformation of traceability codes; at the same time, the collection of multiple drug traceability codes can be achieved, so as to achieve the purpose of batch collection; after obtaining the drug traceability code information, the correlation between the drug traceability code and the prescription can be verified by checking the drug traceability code information with the prescription data, so as to realize the supervision of the drug distribution end and ensure the safety of the patient's medication; finally, by the associated storage of the drug traceability code information and the prescription data, the drug management can be improved, and the subsequent drug traceability can be convenient. BRIEF DESCRIPTION OF THE DRAWINGS

[0077] The features and advantages of the present invention will be more clearly understood by referring to the accompanying drawings, which are schematic and should not be construed as limiting the present invention in any way. In the accompanying drawings:

[0078] Figure 1 A flowchart of a method for collecting drug traceability codes based on image recognition in Embodiment 1 of the present invention is shown;

[0079] Figure 2 A flowchart of preprocessing a drug packaging image and obtaining drug traceability code information in the first embodiment of the present invention is shown;

[0080] Figure 3 A flow chart of checking drug traceability code information in the first embodiment of the present invention is shown;

[0081] Figure 4 A flowchart of another method for collecting drug traceability codes based on image recognition in Embodiment 1 of the present invention is shown;

[0082] Figure 5 A flowchart of verifying whether drug traceability code information is valid in Embodiment 1 of the present invention is shown;

[0083] Figure 6 A flowchart showing the associated storage of drug traceability code information and prescription data in the first embodiment of the present invention is shown;

[0084] Figure 7 The structure diagram of a drug traceability code collection system based on image recognition in the second embodiment of the present invention is shown. DETAILED DESCRIPTION

[0085] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0086] Embodiment 1

[0087] This embodiment provides a method for collecting drug traceability codes based on image recognition. Figure 1 As shown, the method includes:

[0088] S1: Acquire drug packaging images;

[0089] S2: Preprocessing the drug packaging image, and performing edge detection, region segmentation, image correction and barcode analysis on the preprocessed drug packaging image to obtain drug traceability code information;

[0090] S3: Obtain prescription data, and verify the drug traceability code information according to the prescription data;

[0091] S4: When the drug traceability code information is verified to be correct, the drug traceability code information and the prescription data are associated and stored.

[0092] In this embodiment, firstly, a drug packaging image is obtained, which includes an image of a drug traceability code on the drug packaging. By preprocessing the drug packaging image, the purpose of optimizing the image effect can be achieved, so that the drug traceability code information can be identified more quickly and accurately in the subsequent process. Secondly, by performing edge detection, region segmentation, image correction and barcode analysis on the preprocessed drug packaging image, the drug traceability code can be decoded and collected with high accuracy and high efficiency, and can adapt to environments such as complex backgrounds, changes in illumination and deformation of traceability codes. At the same time, the collection of multiple drug traceability codes can be achieved to achieve the purpose of batch collection. After obtaining the drug traceability code information, the correlation between the drug traceability code and the prescription can be verified by checking the drug traceability code information with the prescription data, so as to realize the supervision of the drug distribution end and ensure the safety of the patient's medication. Finally, by associating and storing the drug traceability code information with the prescription data, the drug management can be improved and the subsequent drug traceability can be facilitated.

[0093] Each step of the method for collecting drug traceability codes based on image recognition in this embodiment is described in detail below.

[0094] Preferably, in this embodiment S1, when acquiring drug packaging images, the drug packaging boxes to be captured are placed in a designated area, with the side printed with the drug traceability code facing upward, and a high-definition camera is used to face the drug packaging boxes, so that drug packaging images containing drug traceability codes can be captured. When multiple drug packaging information needs to be acquired, all drug packaging boxes are placed in a designated area, with the sides printed with drug traceability codes facing upward, and then a high-definition camera is used to shoot, so that multiple drug packaging images can be captured, and each drug packaging image contains a drug traceability code.

[0095] Preferably, if Figure 2 As shown, in this embodiment S2, the drug packaging image is preprocessed, including:

[0096] S21: grayscale the drug packaging image to obtain a grayscale image;

[0097] S22: performing noise reduction and binarization processing on the grayscale image to obtain a binarized image;

[0098] S23: Performing dilation and corrosion processing on the binary image to complete the preprocessing of the drug packaging image.

[0099] Grayscale processing of drug packaging images facilitates subsequent image analysis and recognition based on grayscale values; noise reduction processing can remove noise information in the image and reduce the interference of noise on subsequent image recognition; binarization processing can facilitate subsequent edge detection and improve image recognition efficiency; expansion and corrosion processing can make the outline of the target area clearer, thereby further improving the efficiency and accuracy of subsequent image recognition.

[0100] Specifically, in S11 of the present embodiment, a conventional image processing method is used for grayscale processing; in S22, a Gaussian blur method is used for noise reduction processing, and a conventional image processing method is used for binarization processing; in S23, an expansion operation is first performed in the horizontal direction to expand the range of the target area and fill the gap in the middle of the barcode in the image, and then an erosion operation is performed in the vertical direction to shrink the range of the target area, remove some small and meaningless targets, and separate the barcode and characters in the image.

[0101] Preferably, if Figure 2 As shown, in this embodiment S2, edge detection, region segmentation, image correction and barcode analysis are performed on the pre-processed drug packaging image to obtain drug traceability code information, including:

[0102] S24: performing edge detection on the preprocessed drug packaging image, and determining a barcode area image from the drug packaging image;

[0103] S25: performing region segmentation on the barcode region image to obtain an initial barcode image;

[0104] S26: performing image correction on the initial barcode image to obtain a target barcode image;

[0105] S27: performing barcode analysis on the target barcode image to obtain the drug traceability code information.

[0106] Through edge detection, the image corresponding to the barcode area (i.e., the barcode area image) can be determined from the preprocessed drug packaging image, which can facilitate subsequent area segmentation; the identified barcode area image is then segmented to obtain a segmentable barcode image (i.e., the initial barcode image), which is convenient for subsequent accurate image correction of the image; by correcting the initial barcode image, the barcode can be prevented from tilting, deforming, etc., and a standard barcode image (i.e., the target barcode image) can be obtained, which is convenient for subsequent faster and more accurate barcode parsing and obtains drug traceability code information with high accuracy.

[0107] Preferably, S24 includes:

[0108] S241: performing edge detection on the preprocessed drug packaging image to obtain a plurality of image edges;

[0109] S242: Preliminarily construct multiple regional contour images based on all image edges;

[0110] S243: respectively obtaining the contour area and the first minimum circumscribed rectangle area of ​​each region contour image, and respectively calculating the area ratio between the contour area of ​​each region contour image and the first minimum circumscribed rectangle area;

[0111] S244: determining a plurality of first potential barcode regions from all the region contour images based on the contour area and area ratio of each region contour image;

[0112] S245: identifying a plurality of black regions in each first potential barcode region, and respectively calculating an inertia ratio corresponding to each black region in each first potential barcode region;

[0113] S246: Based on the inertia ratio of all black areas in each first potential barcode area, a plurality of second potential barcode areas are determined from all first potential barcode images, and at least one suspected black stripe corresponding to each second potential barcode area and the center coordinates of each suspected black stripe are determined from all black areas of each second potential barcode area;

[0114] S247: using a random sampling consensus method, respectively fitting a straight line of the center point of the black stripe of each second potential barcode region;

[0115] S248: In each second potential barcode area, determine whether the center coordinates of each suspected black stripe fall on the corresponding black stripe center point straight line; if so, determine the corresponding second potential barcode area as the target barcode area; otherwise, determine the corresponding second potential barcode area as a non-barcode area;

[0116] S249: Obtain the barcode area image according to all target barcode areas.

[0117] By determining the contour area and area ratio of each area contour image, the barcode area (i.e., the first potential barcode area) can be preliminarily determined based on the code system specification of the drug traceability code; after the first potential barcode area is determined, the inertia ratio of each black area in each first potential barcode area is calculated, and the area that may be a black stripe (i.e., suspected black stripe) and its corresponding center coordinates are further determined based on the inertia ratio. Only the area corresponding to the suspected black stripe may be a barcode area, so the barcode area (i.e., the second potential barcode area) can be further determined; finally, for the second potential barcode area, based on the principle that the height of the black stripes in the drug traceability code is the same, the final target barcode area can be determined by fitting the center point straight line of the black stripes and the center coordinates of the suspected black stripes obtained, and these areas constitute the barcode area image obtained in the edge detection process; the present embodiment determines the barcode area image by the above method, which can fully meet the code system specification of the drug traceability code and can accurately determine the real barcode area image.

[0118] Specifically, the edge detection described in S241 and the preliminary contour construction described in S242 use conventional image processing methods, and the specific details are not repeated here.

[0119] Specifically, in S243, when constructing a regional contour image, for any regional contour image, use the findContours function to extract the contours in the image, and for each extracted contour, use the contourArea function to calculate its area to obtain the corresponding contour area. At the same time, use the minAreaRect function to calculate the minimum bounding rectangle of each contour, which returns a tuple containing the coordinates of the center point of the rectangle, the width, height, and the rotation angle. Using the returned tuple of the coordinates of the center point of the rectangle, the width, height, and the rotation angle, combined with the principles of mathematical geometry, the corresponding minimum bounding rectangle area (specifically referred to as the first minimum bounding rectangle area) can be calculated. After calculating the contour area and the first minimum bounding rectangle area, the area ratio between the two can be obtained.

[0120] Specifically, S244 includes:

[0121] S2441: Select any region contour image, and determine whether the contour area of ​​the selected region contour image is less than a first preset threshold and whether the area ratio is less than a second preset threshold;

[0122] S2442: When the contour area of ​​the selected region contour image is less than the first preset threshold and the area ratio is less than the second preset threshold, determining that the selected region contour image is a non-barcode region; otherwise, determining that the selected region contour image is a first potential barcode region;

[0123] S2443: traverse each area outline image, and determine a plurality of first potential barcode areas from all area outline images in the same manner.

[0124] According to the printing specification of drug traceability code and the code specification of Code128 barcode, the height of the black stripes of the drug traceability code barcode is the same, the minimum barcode width is 28mm, and the minimum height is 8mm. Therefore, the first preset threshold satisfied by the contour area belonging to the barcode area and the second preset threshold satisfied by the area ratio can be pre-set. For any area contour image, if its contour area is less than the first preset threshold and the area ratio is less than the second preset threshold, it means that the area is a non-barcode area, otherwise it may be a barcode area (that is, it is judged as the first potential barcode area). According to the above method, the first potential barcode area that meets the real drug traceability code can be preliminarily screened out.

[0125] Specifically, in this embodiment, the first preset threshold is 200 pixels, and the second preset threshold is 0.75.

[0126] Specifically, in S245, the black area in the first potential barcode area is identified by a conventional image recognition method, and the specific details are not repeated here. After the black area is identified, the major axis length and the minor axis length of the black area can be determined, and the ratio between the major axis length and the minor axis length can be calculated to obtain the inertia ratio corresponding to the black area.

[0127] Specifically, S246 includes:

[0128] S2461: Select any first potential barcode area, and determine whether the inertia ratios of all black areas in the selected first potential barcode area are less than a third preset threshold; if so, determine that the selected first potential barcode area is a non-barcode area; otherwise, determine that the selected first potential barcode area is a second potential barcode area;

[0129] S2462: When the selected first potential barcode area is the second potential barcode area, a black area in the second potential barcode area whose inertia ratio is greater than or equal to a third preset threshold is determined as a suspected black stripe, and the center coordinates of each suspected black stripe in the second potential barcode area are identified;

[0130] S2463: traverse each first potential barcode area, and determine multiple second potential barcode areas from all first potential barcode images in the same way, and respectively determine at least one suspected black stripe corresponding to each second potential barcode area and the center coordinates of each suspected black stripe.

[0131] According to the code system specification of Code128 barcode, the inertia ratio of black stripes in the drug traceability code will not be less than the third preset threshold (specifically 5), so the inertia ratio of all black stripes in the barcode area will not be less than the third preset threshold. By comparing the inertia ratio of all black areas in the first potential barcode area with the third preset threshold, the possible barcode area (i.e., the second potential barcode area) can be further determined; after the second potential barcode area is determined, the black in these areas with an inertia ratio greater than or equal to the third preset threshold is the possible black stripe (i.e., suspected black stripe). According to the above method, it is possible to quickly and accurately further screen the barcode area that conforms to the actual situation and screen out the black stripes in the barcode area. Among them, by identifying the center coordinates of each suspected black stripe, it is convenient to further determine whether the second potential barcode area is the final barcode area (i.e., the target barcode area).

[0132] Specifically, in S247, the random sampling consensus method, namely the RANSAC (Random Sample Consensus) algorithm, is an iterative method for estimating a parameter model from a set of data containing a large amount of noise and outliers. This method can fit the center point straight line of all black stripes in the second potential barcode area, and based on the principle that the black stripes in the barcode have the same height, it is convenient to finally determine the target stripe area in the subsequent step S248. Among them, the specific operation method of using the random sampling consensus method to fit the center point straight line of the black stripes adopts the conventional operation method, and the specific details are not repeated here.

[0133] Preferably, S25 includes:

[0134] S251: performing region segmentation on the barcode region image to obtain a plurality of segmented barcode sub-images;

[0135] S252: Calculate the second minimum bounding rectangle corresponding to each segmented barcode sub-image respectively, and determine the coordinates of four rectangle vertices corresponding to each second minimum bounding rectangle;

[0136] S253: Identify the barcode centerline direction and the barcode vertical direction of the barcode area image, wherein the barcode vertical direction is greater than the barcode centerline direction;

[0137] S254: for each segmented barcode sub-image, four rectangle vertex coordinates are used as references, and boundary searches are performed in the barcode centerline direction and the barcode vertical direction to determine four barcode boundaries of each segmented barcode sub-image;

[0138] S255: adjusting the coordinates of four rectangle vertices corresponding to the second minimum circumscribed rectangle of each segmented barcode sub-image according to the four barcode boundaries of each segmented barcode sub-image, to obtain four updated vertex coordinates of each segmented barcode sub-image;

[0139] S256: determining an updated barcode sub-image corresponding to each segmented barcode sub-image according to the four updated vertex coordinates of each segmented barcode sub-image;

[0140] S257: Obtain the initial barcode image according to all updated barcode sub-images.

[0141] First, the minimum bounding rectangle (i.e., the second minimum bounding rectangle) of the segmented barcode sub-image after region segmentation and its corresponding four rectangle vertex coordinates are determined. On the one hand, it is convenient to determine the benchmark for the subsequent boundary search, and on the other hand, it is convenient to adjust the original second minimum bounding rectangle based on the four barcode boundaries obtained after the boundary search, so that it more accurately surrounds the barcode area and extracts a more accurate initial barcode image. When the four rectangle vertex coordinates corresponding to the second minimum bounding rectangle of the segmented barcode sub-image are obtained, the barcode centerline direction (i.e., the direction of the long axis) and the barcode vertical direction (perpendicular to the barcode centerline direction and parallel to the short axis direction) of the barcode area image can be identified through image recognition technology. The four barcode boundaries can be determined by pixel-by-pixel detection along the barcode centerline direction and the barcode vertical direction, and the four rectangle vertex coordinates can be adjusted based on the four barcode boundaries to obtain new rectangle vertex coordinates (i.e., update vertex coordinates), thereby realizing the adjustment of the segmented barcode sub-image and obtaining a more accurate initial barcode image.

[0142] Specifically, in the present embodiment S254, the pixel grayscale value can be detected by detecting pixel by pixel along the center line direction of the barcode and the vertical direction of the barcode based on the coordinates of the rectangle vertices. When the detected pixel grayscale value meets certain conditions, such as the pixel grayscale values ​​of 20 consecutive pixels are all 255 (i.e., 20 consecutive pixels are all white pixels), it means that the barcode boundary has been searched, the boundary search in the current direction is ended, and the boundary search in the next direction is performed. In the present embodiment S255, when four barcode boundaries are searched, the four barcode boundaries can be fitted with four vertex coordinates, and the four vertex coordinates are directly replaced by the four rectangle vertex coordinates, that is, the four updated vertex coordinates. In the present embodiment S256, the four updated vertex coordinates can be used to fit a new second minimum bounding rectangle, and the image enclosed in the new second minimum bounding rectangle is the updated barcode sub-image.

[0143] Preferably, this embodiment S26 includes:

[0144] S261: Calculating the tilt angle of each updated barcode sub-image according to the four updated vertex coordinates corresponding to each updated barcode sub-image in the initial barcode image;

[0145] S262: Obtain the rectangular size corresponding to each updated barcode sub-image in the initial barcode image;

[0146] S263: performing rotation correction on each updated barcode sub-image according to the rectangular size and tilt angle corresponding to each updated barcode sub-image, to obtain a corrected barcode sub-image corresponding to each updated barcode sub-image;

[0147] S264: Obtain the target barcode image according to all corrected barcode sub-images.

[0148] Correcting the initial barcode image to a uniform specified direction (such as correcting the long axis of the barcode to be parallel to the horizontal direction) can facilitate subsequent barcode parsing and help improve the efficiency of batch collection and identification of drug traceability codes. In actual images, the coordinates of the upper left corner of the image are usually the origin of the coordinate system. Based on the updated vertex coordinates obtained in the previous steps and the coordinate system with the coordinates of the upper left corner of the image as the origin of the coordinate system, combined with mathematical knowledge, the inclination angle of the updated barcode sub-image corresponding to the four updated vertex coordinates relative to the specified direction can be calculated. At the same time, based on the updated vertex coordinates obtained in the previous steps, the rectangular size of the corresponding updated barcode sub-image can be determined. According to the rectangular size and the inclination angle, the original updated barcode sub-image can be quickly rotated and corrected to the specified direction while ensuring that the size of the original updated barcode sub-image remains unchanged, so as to ensure subsequent fast barcode parsing.

[0149] Specifically, in S261, for a coordinate system with the coordinates of the upper left corner of the image as the origin of the coordinate system, take the coordinates of two adjacent updated vertices of an updated barcode sub-image, use the straight line equation y=kx+b to calculate the slope k of the line connecting the two updated vertex coordinates, and then use the inverse tangent function arctan(k) to calculate the inclination angle of the updated barcode sub-image. In the actual process of rotation correction described in S263, first, based on the size of the rectangle corresponding to the updated barcode sub-image, a new rectangle with the same size and the long axis direction as the specified direction is created, and then based on the rotation angle, the corresponding relationship between each position of the rectangle and the pixel point at each position in the updated barcode sub-image is determined, and based on the corresponding relationship, the grayscale value of the pixel point at each position in the updated barcode sub-image is assigned to the rectangle, so as to realize the rotation correction of the updated barcode sub-image.

[0150] Preferably, this embodiment S27 includes:

[0151] S271: calling a third-party tool library to scan and identify the target barcode image to obtain multiple element edges;

[0152] S272: Calculate the distance between each two adjacent element edges to obtain multiple barcode element width data of the target barcode image;

[0153] S273: Put all barcode element width data into a preset sliding window array, convert each barcode element width data into binary data in turn according to a preset encoding rule, and assemble all binary data into characters to obtain the drug traceability code information.

[0154] By scanning and identifying the target barcode image through a third-party tool library, on the one hand, the built-in functions in the third-party tool library can be used to implement filtering processing, eliminate the influence of image noise, and improve the accuracy of barcode recognition; on the other hand, each element in the barcode can be accurately located to further improve the accuracy of recognition. The distance between the edges of adjacent elements is determined as the width of the barcode element, which has a certain fault tolerance for the deformation and distortion of the barcode and can adapt to environments such as complex backgrounds, changes in lighting, and deformation of traceability codes. Using a preset sliding window array and preset encoding rules to convert and assemble barcode element width data can, on the one hand, enable faster processing when parsing and assembling barcode data, further improving the overall efficiency; on the other hand, using unified rules to parse and assemble data can be applicable to barcode images of different sizes and resolutions, improving the versatility of the entire method.

[0155] Specifically, in S271, the third-party tool library can be a tool library such as ZBar, ZXing, etc.; in the process of scanning and recognition, the target barcode image is scanned line by line, filtered by EWMA (exponential weighted moving average algorithm) to eliminate the influence of image noise, and then the gradient change is calculated to determine the edge of the element. In S272, the distance between the edges of each adjacent element represents the width of a barcode element. Therefore, by calculating the distance between the edges of each two adjacent elements, the width data of multiple barcode elements of the target barcode image can be obtained. In S273, the preset encoding rule is also the Code128 encoding rule.

[0156] Specifically, in this embodiment S3, when obtaining prescription data, the prescription data (including the drug name, specification, manufacturer, quantity, drug identification code (the first seven digits of the traceability code) contained in the prescription, etc.) that needs to collect the drug traceability code is obtained by calling the HIS interface. Among them, HIS is Hospital Information System, which uses modern means such as computer software and hardware technology, network communication technology, etc. to collect, store, process, extract, transmit, summarize, and process the data generated by the hospital at various stages of medical activities to generate various information, thereby providing comprehensive, automated management and various services for the overall operation of the hospital. The HIS interface refers to an interface that can interact and share background data flows with the information system, which can achieve seamless connection between various systems within the hospital to ensure the accuracy and timeliness of information.

[0157] Preferably, in this embodiment S3, if Figure 3 As shown, according to the prescription data, the drug traceability code information is checked, including:

[0158] S31: Finding drug data according to the drug traceability code information;

[0159] S32: Determine whether the drug data is consistent with the drug information in the prescription data. If so, the verification is correct; otherwise, the verification is incorrect.

[0160] This method can directly and quickly check the consistency between drug traceability code information and prescription data, which can ensure the accuracy of information collection and identification on the one hand, and realize supervision at the drug distribution end on the other hand to ensure the safety of patient medication.

[0161] Preferably, if Figure 4 As shown, before checking the drug traceability code information according to the prescription data, the method further includes:

[0162] S5: Verify whether the drug traceability code information is valid;

[0163] When the drug traceability code information is verified to be valid, the drug traceability code information is checked according to the prescription data.

[0164] Before checking the drug traceability code information, its validity is verified first. Only when it is valid is the subsequent data verification performed (i.e., executing step S3). This can avoid dispensing drugs after the drugs have expired, thereby causing patients to use expired drugs, further effectively ensuring the safety of patients' medication.

[0165] Specifically, Figure 5 As shown, S5 includes:

[0166] S51: sending the drug traceability code information to a third-party traceability code verification platform, and searching the drug traceability code information on the third-party traceability code verification platform;

[0167] S52A: If the drug traceability code information is found in the third-party traceability code verification platform, the validity period of the batch number corresponding to the drug traceability code information is returned; when the validity period of the batch number is after the current date, the drug traceability code information is determined to be valid, otherwise the drug traceability code information is determined to be invalid;

[0168] S52B: If the drug traceability code information is not found in the third-party traceability code verification platform, the drug traceability code information is determined to be invalid.

[0169] The drug traceability code is issued by the State Drug Administration. Therefore, the batch number and batch validity period corresponding to all drug traceability codes will be stored on the third-party traceability code verification platform. Using the third-party traceability code verification platform to search for drug traceability code information can not only initially realize the validity of the drug traceability code, but also further verify the accuracy of the drug traceability code identification in the aforementioned steps. If the third-party traceability code verification platform can find the identified drug traceability code information, on the one hand, it means that the drug traceability code is formally issued, and on the other hand, it means that the drug traceability code identification in the aforementioned steps is correct. When the drug traceability code is found, the corresponding batch validity period is returned. When the drug traceability code is not found, it means that the drug traceability code may not be formally issued, or there may be an error in the drug traceability code identification in the aforementioned steps, that is, the drug traceability code information is determined to be invalid. When the third-party traceability code verification platform finds the drug traceability code, it will compare the returned batch number validity period with the current date (specifically the date corresponding to the verification). If the batch number validity period is after the current date, it means that the drug corresponding to the drug traceability code has not expired, and the patient will not use expired drugs; otherwise, it means that the drug corresponding to the drug traceability code has expired, that is, the corresponding drug traceability code information is invalid.

[0170] Specifically, the third-party traceability code verification platform of this embodiment can be a "Code on Peace of Mind" platform interface. In this embodiment, when it is determined that the drug traceability code information is invalid, an alarm message can be sent to remind relevant personnel, and the drug traceability code can be re-identified and the legitimacy of the drug can be checked.

[0171] Preferably, if Figure 6 As shown, this embodiment S4 includes:

[0172] S41: When the drug traceability code information is verified to be correct, the verified drug traceability code information is associated with the corresponding prescription data to generate associated information, and the associated drug traceability code information, the corresponding prescription data and the associated information are stored;

[0173] S42: Upload the associated information to a third-party platform.

[0174] When the drug traceability code information is verified to be correct, it will be associated with the corresponding prescription information, and the generated associated information as well as the traceability code information and prescription data will be stored, so that the flow, quantity and status of the drugs can be grasped more accurately, which can facilitate the improvement of the entire hospital information management system and optimize drug management and supervision; the associated information can also be uploaded to a third-party platform, which can facilitate the grasp of the entire drug process and achieve full traceability of drugs, ensuring that the source and destination of the drugs can be checked, and at the same time, it can also crack down on illegal incidents such as counterfeit and illegal drugs, and strengthen the implementation and supervision of medical insurance policies.

[0175] Embodiment 2

[0176] A drug traceability code collection system based on image recognition is applied to the drug traceability code collection method based on image recognition in embodiment 1, such as Figure 7 As shown, the system includes:

[0177] An image acquisition module, used for acquiring images of drug packaging;

[0178] An image processing module, used for preprocessing drug packaging images;

[0179] An image recognition module is used to perform edge detection, region segmentation, image correction and barcode analysis on the preprocessed drug packaging image to obtain drug traceability code information;

[0180] A data verification module, used to obtain prescription data and verify the drug traceability code information according to the prescription data;

[0181] The associated storage module is used to associate and store the drug traceability code information with the prescription data when the data verification module verifies that the drug traceability code information is correct.

[0182] In this embodiment, the image acquisition module is first used to acquire the drug packaging image, which contains the image of the drug traceability code on the drug packaging. Then, the image processing module is used to preprocess the drug packaging image, which can achieve the purpose of optimizing the image effect, so as to facilitate the subsequent faster and more accurate identification of the drug traceability code information. Secondly, the image recognition module performs edge detection, region segmentation, image correction and barcode analysis on the preprocessed drug packaging image, which can realize the decoding and acquisition of the drug traceability code, with high accuracy and high efficiency, and can adapt to complex backgrounds, lighting changes, traceability code deformation and other environments. At the same time, it can also realize the acquisition of multiple drug traceability codes to achieve the purpose of batch acquisition. After obtaining the drug traceability code information, the data verification module verifies the drug traceability code information and the prescription data, which can verify the correlation between the drug traceability code and the prescription, realize the supervision of the drug distribution end, and ensure the safety of the patient's medication. Finally, the association storage module stores the drug traceability code information and the prescription data, which can improve the drug management and facilitate the subsequent drug traceability.

[0183] The functions of each module in the drug traceability code collection system based on image recognition described in this embodiment are the same as the method steps of the drug traceability code collection method based on image recognition described in Example 1. Therefore, for details not included in this embodiment, please refer to Example 1 and Figures 1 to 6 The detailed description will not be repeated here.

[0184] Embodiment 3

[0185] A drug traceability code collection device based on image recognition includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed, the method steps in the drug traceability code collection method based on image recognition of embodiment 1 are implemented.

[0186] Through the computer program stored in the memory and running on the processor, efficient and accurate collection and identification of drug traceability codes are achieved, with high precision and efficiency, and can adapt to environments such as complex backgrounds, lighting changes, and deformation of traceability codes. At the same time, it can also realize the collection of multiple drug traceability codes to achieve the purpose of batch collection; and realize the supervision of the drug distribution end to ensure the safety of patient medication, which can improve drug management and facilitate subsequent drug traceability.

[0187] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of a computer device, and uses various interfaces and lines to connect various parts of the entire computer device.

[0188] The memory can be used to store computer programs and / or models. The processor realizes various functions of the computer device by running or executing the computer programs and / or models stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and at least one application required for a function (such as a sound playback function, an image playback function, etc.); the data storage area can store data created according to the use of the mobile phone (such as audio data, video data, etc.). In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0189] It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by a computer program. These computer programs can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0190] These computer programs may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the process Figure 1A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0191] These computer programs can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0192] This embodiment also provides a computer storage medium, which includes: at least one instruction, which implements the method steps in the drug traceability code collection method based on image recognition in embodiment 1 when the instruction is executed by the computer.

[0193] By executing a computer storage medium containing at least one instruction, efficient and accurate collection and identification of drug traceability codes are achieved, with high precision and efficiency, and can adapt to environments such as complex backgrounds, changes in lighting, and deformation of traceability codes; at the same time, the collection of multiple drug traceability codes can be achieved to achieve the purpose of batch collection; and supervision at the drug distribution end can be achieved to ensure the safety of patient medication, improve drug management, and facilitate subsequent drug traceability.

[0194] Similarly, for details not yet provided in this embodiment, please refer to Embodiment 1, Embodiment 2 and Figures 1 to 7 The detailed description will not be repeated here.

[0195] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A method for collecting drug traceability codes based on image recognition, characterized in that: The method comprises: Acquire drug packaging images; Preprocessing the drug packaging image, and performing edge detection, region segmentation, image correction and barcode analysis on the preprocessed drug packaging image to obtain drug traceability code information; Obtaining prescription data, and verifying the drug traceability code information according to the prescription data; When the drug traceability code information is verified to be correct, the drug traceability code information and the prescription data are associated and stored.

2. The method for collecting drug traceability codes based on image recognition according to claim 1, characterized in that: The pre-processed drug packaging image is subjected to edge detection, region segmentation, image correction and barcode analysis to obtain drug traceability code information, including: Performing edge detection on the preprocessed drug packaging image, and determining a barcode area image from the drug packaging image; Performing region segmentation on the barcode region image to obtain an initial barcode image; Performing image correction on the initial barcode image to obtain a target barcode image; The target barcode image is subjected to barcode analysis to obtain the drug traceability code information.

3. The method for collecting drug traceability codes based on image recognition according to claim 2 is characterized in that: The step of performing edge detection on the preprocessed drug packaging image and determining a barcode region image from the drug packaging image includes: Performing edge detection on the preprocessed drug packaging image to obtain multiple image edges; Based on all image edges, multiple regional contour images are preliminarily constructed; Respectively obtain the contour area and the first minimum circumscribed rectangle area of ​​each region contour image, and respectively calculate the area ratio between the contour area of ​​each region contour image and the first minimum circumscribed rectangle area; Determine a plurality of first potential barcode regions from all the region contour images based on the contour area and area ratio of each region contour image; Identify a plurality of black regions in each first potential barcode region, and respectively calculate an inertia ratio corresponding to each black region in each first potential barcode region; Based on the inertia ratio of all black areas in each first potential barcode area, a plurality of second potential barcode areas are determined from all first potential barcode images, and at least one suspected black stripe corresponding to each second potential barcode area and the center coordinates of each suspected black stripe are determined from all black areas of each second potential barcode area; A random sampling consensus method is used to fit the center point straight line of the black stripes of each second potential barcode area; In each second potential barcode area, determine whether the center coordinates of each suspected black stripe fall on the corresponding black stripe center point straight line; if so, determine the corresponding second potential barcode area as the target barcode area; otherwise, determine the corresponding second potential barcode area as a non-barcode area; According to all target barcode regions, the barcode region image is obtained.

4. The method for collecting drug traceability codes based on image recognition according to claim 3 is characterized in that: Based on the contour area and area ratio of each region contour image, a plurality of first potential barcode regions are determined from all region contour images, including: Select any regional contour image, and determine whether the contour area of ​​the selected regional contour image is less than a first preset threshold and whether the area ratio is less than a second preset threshold; When the contour area of ​​the selected region contour image is smaller than the first preset threshold value and the area ratio is smaller than the second preset threshold value, the selected region contour image is determined to be a non-barcode region; otherwise, the selected region contour image is determined to be a first potential barcode region; Each area contour image is traversed, and a plurality of first potential barcode areas are determined from all area contour images in the same manner.

5. The method for collecting drug traceability codes based on image recognition according to claim 3 is characterized in that: Based on the inertia ratio of all black areas in each first potential barcode area, a plurality of second potential barcode areas are determined from all first potential barcode images, and at least one suspected black stripe corresponding to each second potential barcode area and the center coordinates of each suspected black stripe are respectively determined from all black areas of each second potential barcode area, including: Select any first potential barcode area, and determine whether the inertia ratios of all black areas in the selected first potential barcode area are less than a third preset threshold; if so, determine that the selected first potential barcode area is a non-barcode area; otherwise, determine that the selected first potential barcode area is a second potential barcode area; When the selected first potential barcode area is the second potential barcode area, a black area in the second potential barcode area whose inertia ratio is greater than or equal to a third preset threshold is determined as a suspected black stripe, and the center coordinates of each suspected black stripe in the second potential barcode area are identified; Each first potential barcode area is traversed, and multiple second potential barcode areas are determined from all first potential barcode images in the same way, and at least one suspected black stripe corresponding to each second potential barcode area and the center coordinates of each suspected black stripe are determined respectively.

6. The method for collecting drug traceability codes based on image recognition according to claim 2, characterized in that: The performing region segmentation on the barcode region image to obtain an initial barcode image includes: Performing region segmentation on the barcode region image to obtain a plurality of segmented barcode sub-images; Calculate the second minimum bounding rectangle corresponding to each segmented barcode sub-image respectively, and determine the coordinates of four rectangle vertices corresponding to each second minimum bounding rectangle; Identify the barcode centerline direction and the barcode vertical direction of the barcode area image, wherein the barcode vertical direction is greater than the barcode centerline direction; For each segmented barcode sub-image, four rectangle vertex coordinates are used as references, and boundary searches are performed in the barcode centerline direction and the barcode vertical direction to determine the four barcode boundaries of each segmented barcode sub-image; According to the four barcode boundaries of each segmented barcode sub-image, the four rectangle vertex coordinates corresponding to the second minimum circumscribed rectangle of each segmented barcode sub-image are adjusted to obtain four updated vertex coordinates of each segmented barcode sub-image; According to the four updated vertex coordinates of each segmented barcode sub-image, an updated barcode sub-image corresponding to each segmented barcode sub-image is determined; The initial barcode image is obtained according to all updated barcode sub-images.

7. The method for collecting drug traceability codes based on image recognition according to claim 6 is characterized in that: The performing image correction on the initial barcode image to obtain a target barcode image includes: Calculating the tilt angle of each updated barcode sub-image according to the four updated vertex coordinates corresponding to each updated barcode sub-image in the initial barcode image; Obtaining the rectangular size corresponding to each updated barcode sub-image in the initial barcode image; According to the rectangular size and tilt angle corresponding to each updated barcode sub-image, each updated barcode sub-image is rotationally corrected to obtain a corrected barcode sub-image corresponding to each updated barcode sub-image; The target barcode image is obtained according to all corrected barcode sub-images.

8. The method for collecting drug traceability codes based on image recognition according to claim 7 is characterized in that: The barcode parsing of the target barcode image to obtain the drug traceability code information includes: Calling a third-party tool library to scan and identify the target barcode image to obtain multiple element edges; Calculating the distance between the edges of each two adjacent elements respectively to obtain multiple barcode element width data of the target barcode image; All barcode element width data are placed in a preset sliding window array, each barcode element width data is converted into binary data in turn according to a preset encoding rule, and all binary data are assembled into characters to obtain the drug traceability code information.

9. The method for collecting drug traceability codes based on image recognition according to claim 1, characterized in that: The checking of the drug traceability code information according to the prescription data includes: Find out drug data according to the drug traceability code information; Determine whether the drug data is consistent with the drug information in the prescription data. If so, the verification is correct; otherwise, the verification is incorrect.

10. The method for collecting drug traceability codes based on image recognition according to claim 9, characterized in that: Before checking the drug traceability code information according to the prescription data, the method further includes: Verify whether the drug traceability code information is valid; When the drug traceability code information is verified to be valid, the drug traceability code information is checked according to the prescription data.

11. The method for collecting drug traceability codes based on image recognition according to claim 10, characterized in that: The verification of whether the drug traceability code information is valid includes: Sending the drug traceability code information to a third-party traceability code verification platform, and searching the drug traceability code information on the third-party traceability code verification platform; If the drug traceability code information is found in the third-party traceability code verification platform, the validity period of the batch number corresponding to the drug traceability code information is returned; when the validity period of the batch number is after the current date, the drug traceability code information is determined to be valid, otherwise the drug traceability code information is determined to be invalid; If the drug traceability code information is not found in the third-party traceability code verification platform, the drug traceability code information is determined to be invalid.

12. The method for collecting drug traceability codes based on image recognition according to claim 1, characterized in that: When the drug traceability code information is verified to be correct, the drug traceability code information and the prescription data are associated and stored, including: When the drug traceability code information is verified to be correct, the verified drug traceability code information is associated with the corresponding prescription data to generate associated information, and the associated drug traceability code information, the corresponding prescription data and the associated information are stored; The associated information is uploaded to a third-party platform.

13. The method for collecting drug traceability codes based on image recognition according to any one of claims 1 to 12, characterized in that: The preprocessing of the drug packaging image includes: grayscale the drug packaging image to obtain a grayscale image; Performing noise reduction and binarization processing on the grayscale image to obtain a binarized image; The binary image is subjected to dilation and corrosion processing to complete the preprocessing of the drug packaging image.

14. A drug traceability code collection system based on image recognition, characterized in that: Applied to the method for collecting drug traceability codes based on image recognition as described in any one of claims 1 to 13, the system comprises: An image acquisition module, used for acquiring images of drug packaging; An image processing module, used for preprocessing drug packaging images; An image recognition module is used to perform edge detection, region segmentation, image correction and barcode analysis on the preprocessed drug packaging image to obtain drug traceability code information; A data verification module, used to obtain prescription data and verify the drug traceability code information according to the prescription data; The associated storage module is used to associate and store the drug traceability code information with the prescription data when the data verification module verifies that the drug traceability code information is correct.

15. A drug traceability code collection device based on image recognition, characterized in that: It includes a processor, a memory, and a computer program stored in the memory and executable on the processor, and when the computer program is executed, the method steps in the method for collecting drug traceability codes based on image recognition as described in any one of claims 1 to 13 are implemented.

16. A computer storage medium, characterized in that: The computer storage medium includes: at least one instruction, which, when executed by a computer, implements the method steps in the method for collecting drug traceability codes based on image recognition as described in any one of claims 1 to 13.

Citation Information

Cited By

  • Tracing code-based drug management method and system

    CN120072239A

  • A drug management method and system based on traceability codes

    CN120072239B

  • AI traceability code identification system and transcoding packaging method

    CN120338822A

  • AI trace code recognition system and transcoding packaging method

    CN120338822B

  • Medicine package anti-counterfeiting tracing method and system

    CN120598580A