Pharmaceutical Detection Method, Device, Electronic Device and Storage Medium
By using pharmaceutical image recognition and fitting technology, the problem of low efficiency in pharmaceutical shape qualification detection has been solved, achieving efficient and accurate pharmaceutical shape detection, which is applicable to pharmaceutical detection in the process of drug production and dispensing.
Patent Information
- Application Number
- CN202111063911.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-10
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2041-09-10
AI Technical Summary
Existing technologies have low efficiency in detecting the shape conformity of single-tablet medications, especially during drug production or distribution, where existing testing methods cannot efficiently detect whether the shape of the medication meets the requirements.
By establishing a positioning coordinate system based on drug image recognition and fitting technology, the fitted data of the drug is obtained and compared with the specified shape data to determine whether the shape of the drug is qualified, including the detection of indicators such as diameter, center, color difference and weight difference.
It improves the efficiency and accuracy of drug shape detection, reduces reliance on manual measurement and weight sensors, and ensures that the size uniformity, regularity, color difference and weight difference of the drug meet the requirements.
Smart Images

Figure CN113781437B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of pharmaceutical detection. Specifically, it relates to a method, device, electronic device, and storage medium for detecting pharmaceuticals. Background Art
[0002] During the process of pharmaceutical production or dispensing, it is necessary to classify pharmaceuticals. Due to the safety and dosage requirements of drugs, the dosage control of pharmaceuticals has a crucial impact on medication safety. And the dosage of a single pharmaceutical tablet is directly related to the shape and size of the pharmaceutical, so the dosage safety of pharmaceuticals can be achieved by controlling the shape of the pharmaceuticals.
[0003] In the prior art, the detection of pharmaceuticals usually uses techniques such as hyperspectral to detect the active ingredients of a certain type of pill, or uses image recognition to check the quantity or type of pharmaceuticals. There is a problem of low detection efficiency for the qualified shape of a single pharmaceutical tablet. Summary of the Invention
[0004] In view of this, the purpose of the embodiments of this application is to provide a method, device, electronic device, and storage medium for detecting pharmaceuticals, so as to improve the problem of low detection efficiency for the qualified shape of a single pharmaceutical tablet existing in the prior art.
[0005] The embodiments of this application provide a method for detecting pharmaceuticals. The method includes: detecting the shape type of the pharmaceutical based on the pharmaceutical image; determining the specified shape data of the pharmaceutical based on the shape type; obtaining the fitting data of the pharmaceutical image; and determining whether the shape of the pharmaceutical is qualified based on the comparison result between the fitting data and the specified shape data.
[0006] In the above implementation, image recognition and fitting are performed on the pharmaceutical, and the fitting data and the specified shape data are compared based on the shape type of the pharmaceutical, so as to determine whether the shape of the pharmaceutical is qualified. It is not necessary to perform manual size measurement, nor is it necessary to use devices such as weight sensors to measure each pharmaceutical individually, improving the efficiency of pharmaceutical shape measurement.
[0007] Optionally, the shape type includes pills. The obtaining of the fitting data of the pharmaceutical image includes: establishing a positioning coordinate system according to the inclination angle of the discharge platform of the pill. The horizontal axis of the positioning coordinate system coincides with the discharge edge of the discharge platform, and the discharge edge is the edge of the discharge platform parallel to the discharge direction. The vertical axis of the positioning coordinate system is perpendicular to the discharge edge; fitting the pharmaceutical image in the positioning coordinate system to obtain the fitting data, and the fitting data includes the diameter and the center of the pharmaceutical image.
[0008] In the above implementation, a positioning coordinate system is established based on the inclination angle of the discharging platform to obtain the fitting data of the pills. By utilizing the characteristic that the coordinates of the centers and diameters of pills with different shapes will vary when rolling on a plane, differential shape data is obtained, providing basic data for subsequent shape determination.
[0009] Optionally, the specified shape data of the pills includes the diameter difference threshold between pills. Determining whether the shape of the pills is qualified based on the comparison result of the fitting data and the specified shape data includes: calculating the diameter difference between pills based on the diameters of the pill images of multiple pills in the pills; when the diameter difference between pills is less than the diameter difference threshold between pills, determining that the size uniformity of the shape of the pills is qualified.
[0010] In the above implementation, by utilizing the characteristic that the diameters of pills with different shapes are different when rolling on a plane, that is, the distance from the pill to the farthest point of the discharging platform is different, it is determined whether the size uniformity of different pills in a batch of pills is qualified based on the difference between the fitting data of the pill images, without the need for one-by-one dimensional measurement with a measuring scale, etc., improving the detection efficiency.
[0011] Optionally, the specified shape data of the pills includes the center coordinate threshold between pills. Determining whether the shape of the pills is qualified based on the comparison result of the fitting data and the specified shape data includes: calculating the center coordinate difference between pills based on the centers of the pill images of multiple pills in the pills; when the center coordinate difference between pills is less than the center coordinate threshold between pills, determining that the regularity of the shape of the pills is qualified.
[0012] In the above implementation, by utilizing the characteristic that the vertical coordinate values of the centers of pills with different shapes will vary when rolling on a plane, it is determined whether the regularity of the shapes of different pills in a batch of pills is qualified based on the difference between the fitting data of the pill images, without the need for one-by-one dimensional measurement with a measuring scale, etc., improving the detection efficiency.
[0013] Optionally, the shape types include round tablets, square tablets, and oval tablets. Determining whether the shape of the pills is qualified based on the comparison result of the fitting data and the specified shape data includes: when the diameter difference in the fitting data of the round tablets is less than the diameter difference threshold in the specified shape data, determining that the regularity of the shape of the pills is qualified; when the side length difference in the fitting data of the square tablets is less than the side length difference threshold in the specified shape data, determining that the regularity of the shape of the pills is qualified; when the major and minor axis difference in the fitting data of the oval tablets is less than the major and minor axis difference threshold in the specified shape data, determining that the regularity of the shape of the pills is qualified.
[0014] In the above implementation, according to the shape type of the medicament, different specified shape data is determined for round tablets, square tablets, and oval tablets respectively to determine whether the regularity of the shape of the medicament is qualified, improving the detection efficiency of the regularity.
[0015] Optionally, the method further includes: calculating the color difference between medicaments based on the RGB values of the medicament images of multiple medicaments in the medicament; determining whether the color difference of the medicament is qualified based on the comparison result between the color difference between medicaments and the color difference threshold between medicaments.
[0016] In the above implementation, the detection of whether the color difference between medicaments meets the requirements is performed through the medicament image, further ensuring the detection accuracy of the qualification of the medicament.
[0017] Optionally, the method further includes: obtaining the weight difference between multiple medicaments in the medicament; determining whether the weight difference of the medicament is qualified based on the comparison result between the weight difference between medicaments and the weight difference threshold between medicaments.
[0018] In the above implementation, the qualification of the weight difference between medicaments is determined based on the weight difference between medicaments, further ensuring the detection accuracy of the qualification of the medicament.
[0019] An embodiment of the present application provides a medicament detection device, which includes: a type detection module for detecting the shape type of the medicament based on the medicament image; a data determination module for determining the specified shape data of the medicament based on the shape type; a fitting module for obtaining the fitting data of the medicament image; and a qualification detection module for determining whether the shape of the medicament is qualified based on the comparison result between the fitting data and the specified shape data.
[0020] In the above implementation, image recognition and fitting of the medicament are performed, and the fitting data and the specified shape data are compared based on the shape type of the medicament, so as to determine whether the shape of the medicament is qualified. It is not necessary to perform manual dimension measurement, nor is it necessary to measure each medicament individually with equipment such as a weight sensor, improving the efficiency of measuring the shape of the medicament.
[0021] Optionally, the shape type includes pills, and the fitting module is specifically used for: establishing a positioning coordinate system according to the inclination angle of the discharge platform of the pills, the horizontal axis of the positioning coordinate system coincides with the discharge edge of the discharge platform, the discharge edge is the edge of the discharge platform parallel to the discharge direction, and the vertical axis of the positioning coordinate system is perpendicular to the discharge edge; fitting the medicament image in the positioning coordinate system to obtain the fitting data, and the fitting data includes the diameter and the center of the medicament image.
[0022] In the above implementation, a positioning coordinate system is established based on the inclination angle of the discharging platform to obtain the fitting data of the pills. By utilizing the characteristic that the coordinates of the center and diameter of pills with different shapes will show differences when rolling on a plane, differential shape data is obtained, providing basic data for subsequent shape determination.
[0023] Optionally, the specified shape data of the pills includes the diameter difference threshold between pills. The qualified detection module is specifically configured to: calculate the diameter difference between pills based on the diameters of the pill images of multiple pills in the medicine; when the diameter difference between pills is less than the diameter difference threshold between pills, determine that the size uniformity of the shape of the medicine is qualified.
[0024] In the above implementation, by utilizing the characteristic that the diameters of pills with different shapes are different when rolling on a plane, that is, the distance from the pill to the farthest point of the discharging platform is different, it is determined whether the size uniformity of different pills in a batch of medicine is qualified according to the difference between the fitting data of the pill images, without the need for one-by-one dimensional measurement with a ruler or the like, improving the detection efficiency.
[0025] Optionally, the specified shape data of the pills includes the center coordinate threshold between pills. The qualified detection module is specifically configured to: calculate the center coordinate difference between pills based on the centers of the pill images of multiple pills in the medicine; when the center coordinate difference between pills is less than the center coordinate threshold between pills, determine that the regularity of the shape of the medicine is qualified.
[0026] In the above implementation, by utilizing the characteristic that the vertical coordinate values of the centers of pills with different shapes will show coordinate differences when rolling on a plane, it is determined whether the regularity of the shapes of different pills in a batch of medicine is qualified according to the difference between the fitting data of the pill images, without the need for one-by-one dimensional measurement with a ruler or the like, improving the detection efficiency.
[0027] Optionally, the shape types include round tablets, square tablets, and oval tablets. The qualified detection module is specifically configured to: when the side length difference in the fitting data of the round tablets is less than the side length difference threshold in the specified shape data, determine that the regularity of the shape of the medicine is qualified; when the diameter difference in the fitting data of the square tablets is less than the diameter difference threshold in the specified shape data, determine that the regularity of the shape of the medicine is qualified; when the major and minor axis difference in the fitting data of the oval tablets is less than the major and minor axis difference threshold in the specified shape data, determine that the regularity of the shape of the medicine is qualified.
[0028] In the above implementation, according to the shape types of the medicine, different specified shape data is respectively determined for round tablets, square tablets, and oval tablets to determine whether the regularity of the shape of the medicine is qualified, improving the detection efficiency of the regularity.
[0029] Optionally, the medicament detection device further includes: a color difference detection module, configured to calculate the color difference between medicaments based on the RGB values of the medicament images of multiple medicaments in the medicament; and determine whether the color difference of the medicament is qualified based on the comparison result between the color difference between medicaments and the color difference threshold between medicaments.
[0030] In the above implementation, the detection of whether the color difference between medicaments meets the requirements by using the medicament images further ensures the accuracy of the detection of the qualification of medicaments.
[0031] Optionally, the medicament detection device further includes: a weight detection module, configured to obtain the weight difference between multiple medicaments in the medicament; and determine whether the weight difference of the medicament is qualified based on the comparison result between the weight difference between medicaments and the weight difference threshold between medicaments.
[0032] In the above implementation, the qualification of the weight difference between medicaments is determined based on the weight difference between medicaments, which further ensures the accuracy of the detection of the qualification of medicaments.
[0033] An embodiment of the present application further provides an electronic device, which includes a memory and a processor. When the processor reads and runs program instructions stored in the memory, the steps in any of the above implementations are executed.
[0034] An embodiment of the present application further provides a readable storage medium, in which computer program instructions are stored. When the computer program instructions are read and run by a processor, the steps in any of the above implementations are executed. Description of the Drawings
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required to be used in the embodiments of the present application. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.
[0036] Figure 1 It is a schematic flowchart of a medicament detection method provided by an embodiment of the present application.
[0037] Figure 2 It is a schematic flowchart of a step for obtaining pill fitting data provided by an embodiment of the present application.
[0038] Figure 3 It is a schematic structural diagram of a positioning coordinate system provided by an embodiment of the present application.
[0039] Figure 4Schematic diagram of modules of a pharmaceutical detection device provided by an embodiment of the present application.
[0040] Icons: 20 - Pharmaceutical detection device; 21 - Type detection module; 22 - Data determination module; 23 - Fitting module; 24 - Qualified detection module. Detailed implementation manners
[0041] The technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings in the embodiments of the present application.
[0042] After research by the applicant, it is found that in the prior art, the detection of pharmaceuticals usually uses technologies such as hyperspectral to detect the active ingredients of a certain pill, or uses image recognition to check the quantity or type of pharmaceuticals, resulting in a relatively low detection efficiency for the qualified shape of a single pharmaceutical. To solve the above problems, an embodiment of the present application provides a pharmaceutical detection method.
[0043] Please refer to Figure 1 , Figure 1 which is a schematic flowchart of a pharmaceutical detection method provided by an embodiment of the present application. The specific steps of the pharmaceutical detection method can be as follows:
[0044] Step S12: Detect the shape type of the pharmaceutical based on the pharmaceutical image.
[0045] It should be understood that in this embodiment, the pharmaceutical refers to a solid pharmaceutical, and the corresponding shape types of the pharmaceutical can be pills, tablets, etc. Among them, the tablets can also include round tablets, square tablets, and oval tablets, etc.
[0046] Optionally, the above pharmaceutical image can be an image containing the background and the pharmaceutical obtained by photographing the pharmaceutical with an image acquisition device such as a camera, or an image only containing the pharmaceutical extracted, for example, after obtaining an image with the pharmaceutical and the background existing at the same time by a camera and performing image segmentation on it to obtain an image only containing the pharmaceutical.
[0047] Optionally, the recognition of the shape type of the pharmaceutical in this embodiment can be achieved by any image recognition technology.
[0048] Optionally, the recognition of the shape type of the pharmaceutical can be based on the combination of template matching and neural network model in image processing, and its steps can be as follows:
[0049] Step S121: Perform binarization processing on the pharmaceutical image to obtain a binarized picture, and obtain the pharmaceutical image from the binarized picture based on the connected domain characteristics of the binarized picture.
[0050] The acquisition of the binary image can be achieved by using the Otsu method to obtain the binary threshold of the image containing the pharmaceutical agent, setting the gray level of the pixel points with a gray level greater than the binary threshold to 1, and setting the gray level of the pixel points with a gray level less than the binary threshold to 0, thereby obtaining the binary image of the pharmaceutical agent image.
[0051] Next, perform connected component analysis on the binary image, and merge the connected components according to the positions of the outer bounding boxes of the connected components of the binary image, so as to preliminarily determine the pharmaceutical agent image from the binary image.
[0052] Optionally, the outer bounding box conditions can be specifically specified according to the specific shape of the pharmaceutical agent. For example, for the outer bounding box conditions of specific shapes such as rectangles and circles, it can identify the rectangular or circular bounding boxes in the connected components.
[0053] Step S122: Use a bounding box refinement neural network to determine the bounding box of the pharmaceutical agent image, so as to extract the accurate pharmaceutical agent image from the pharmaceutical agent image.
[0054] Optionally, in this embodiment, step S122 can be specifically as follows:
[0055] Step S1221: Use a deep convolutional neural network to identify the pharmaceutical agent image to obtain a first recognition result.
[0056] The deep convolutional neural network can be a commonly used ordinary deep convolutional neural network, which includes convolutional, pooling, fully connected, and output steps.
[0057] Step S1222: Use a template matching algorithm to perform character recognition on the accurate pharmaceutical agent image to obtain a second recognition result. [[ID=......]]
[0058] It should be understood that before performing the recognition of the template matching algorithm, it is also necessary to input images of spherical agents and tablets of various shapes for comparison as templates in the processing device. Optionally, the template matching algorithm can be commonly used template matching algorithms such as the correlation method and the error method.
[0059] Step S1223: Select the one with a higher recognition accuracy rate from the first recognition result and the second recognition result as the shape recognition result.
[0060] When a certain image recognition method is not suitable for the pharmaceutical agent image, there are other image recognition results for reference, thereby improving the accuracy rate of the pharmaceutical agent shape recognition and at the same time improving the applicability of the pharmaceutical agent recognition method provided in this embodiment.
[0061] Step S14: Determine the specified shape data of the pharmaceutical agent based on the shape type.
[0062] Determine the specified shape data of the medicament according to the corresponding relationship between different shape types of different medicaments and the shape data. The above-mentioned corresponding relationship between the shape type and the shape data can vary flexibly in different detection methods and standards.
[0063] For example, the specified shape data corresponding to pills can be the threshold of the diameter difference between medicaments, the threshold of the center coordinate of the medicaments, etc. The specified shape data corresponding to round tablets can be the threshold of the side length difference, the specified shape data corresponding to square tablets can be the threshold of the diameter difference, and the specified shape data corresponding to oval tablets can be the threshold of the difference between the long and short axes.
[0064] Step S16: Obtain the fitting data of the medicament image.
[0065] Fitting is to connect a series of points on a plane with a smooth curve. Since there are countless possibilities for this curve, there are various fitting methods. The fitted curve can generally be represented by a function, and there are different fitting names according to the different functions. Common fitting methods include the least squares curve fitting method, etc.
[0066] In this embodiment, the way to obtain the fitting data can be to extract the contour of the medicament image, then perform contour fitting, and then perform numerical measurement on the fitting result to obtain the corresponding fitting data. The fitting data corresponding to different shape types of medicaments can be different data.
[0067] Optionally, the contour extraction in this embodiment can be implemented by using Sobel operator, Isotropic Sobel operator, Roberts operator, Prewitt operator, etc.
[0068] For the medicament image with the shape type of pills, please refer to Figure 2 , Figure 2 , which is a schematic flow chart of the steps for obtaining the fitting data of pills provided by the embodiment of the present application. The specific steps for obtaining the fitting data can include the following:
[0069] Step S161: Establish a positioning coordinate system according to the inclination angle of the discharging platform of the pills.
[0070] Please refer to Figure 3 , Figure 3 , which is a schematic structural diagram of a positioning coordinate system provided by the embodiment of the present application.
[0071] The horizontal axis of the positioning coordinate system coincides with the discharging edge of the discharging platform. The discharging edge is the edge of the discharging platform parallel to the discharging direction. The vertical axis of the positioning coordinate system is perpendicular to the discharging edge.
[0072] Step S162: Fit the medicament image in the positioning coordinate system to obtain the fitting data. The fitting data includes the diameter and the center of the medicament image.
[0073] Optionally, the contour fitting in this embodiment can be performed based on formulas such as Bezier curves and elliptic curve equations.
[0074] Taking the iterative endpoint fitting method as an example in this embodiment, its steps are as follows:
[0075] Step a: Set the fitting threshold.
[0076] Optionally, the above fitting threshold can be specifically adjusted according to the pharmaceutical image.
[0077] Step b: Select two points A and B on the boundary curve of the pharmaceutical image.
[0078] Step c: Calculate the distances from all points between points A and B on the boundary curve to the straight line AB, and determine the point C with the maximum distance from the straight line AB. Denote the maximum distance as H.
[0079] Step d: Compare the maximum distance H with the fitting threshold T. If H is less than T, the iteration ends.
[0080] Step e: Point C divides the boundary curve of the target image into two curves AC and CB. Repeat steps S161 - S165 for these two curves.
[0081] Since the discharging platform has a certain inclination angle, when the pills roll on the discharging platform, if the shape of the medicine is completely regular, the movement trajectories of the centers of different pills should be straight lines parallel to the y-axis. If the shape of the medicine is irregular, the center coordinates will deviate from the straight line parallel to the y-axis. Therefore, in this embodiment, the center can be used as the fitting data for subsequent determination of the shape qualification.
[0082] The size of the pill is positively correlated with the diameter of the pill. Therefore, the size uniformity of the pill can be determined based on the diameter difference of the medicine. Optionally, since the discharging platform is a plane, the longest perpendicular line from the pill to the discharging platform when the pill rolls on the discharging platform is the diameter of the pill.
[0083] Similarly, when the medicine is a tablet, in this embodiment, circular tablets can be fitted to obtain the diameter of their circular surfaces as fitting data, square tablets can be fitted to obtain the side lengths of their square surfaces as fitting data, elliptical tablets can be fitted to obtain the major and minor axis lengths of their elliptical surfaces as fitting data, and then subsequent comparison and judgment of the shape qualification can be made based on the diameter, side length, and major and minor axis lengths.
[0084] Step S18: Determine whether the shape of the medicine is qualified based on the comparison result between the fitting data and the specified shape data.
[0085] For pills, in this embodiment, the diameter difference between pills can be calculated based on the diameters of the pill images of two or more pills. For example, the diameter difference between two pills or the average value of the diameter differences of multiple pills. When the diameter difference between pills is less than the pill diameter difference threshold, it is determined that the size uniformity of the pill shape is qualified; otherwise, the size uniformity of the pill shape is unqualified.
[0086] For pills, in this embodiment, the difference in the center coordinates between pills can be calculated based on the centers of the pill images of multiple pills. For example, the difference in the center coordinates between two pills or the average value of the differences in the center coordinates of multiple pills. When the difference in the center coordinates between pills is less than the pill center coordinate threshold, it is determined that the regularity of the pill shape is qualified; otherwise, the regularity of the pill shape is unqualified.
[0087] For round tablets, in this embodiment, the diameter difference can be calculated based on the diameters of the pill images of the round surfaces of multiple round tablets. For example, the diameter difference between two round tablets or the average value of the diameter differences of multiple round tablets. When the diameter difference is less than the diameter difference threshold, it is determined that the regularity of the tablet shape is qualified; otherwise, the regularity of the tablet is unqualified.
[0088] For square tablets, in this embodiment, the side length difference can be calculated based on the side lengths of the pill images of the square surfaces of multiple square tablets. For example, the side length difference between two square tablets or the average value of the side length differences of multiple square tablets. When the side length difference is less than the side length difference threshold, it is determined that the regularity of the tablet shape is qualified; otherwise, the regularity of the tablet is unqualified.
[0089] For oval tablets, in this embodiment, the major and minor axis difference can be calculated based on the lengths of the major and minor axes of the pill images of the square surfaces of multiple oval tablets. For example, the major and minor axis difference between two oval tablets or the average value of the major and minor axis differences of multiple oval tablets. When the major and minor axis difference is less than the major and minor axis difference threshold, it is determined that the regularity of the tablet shape is qualified; otherwise, the regularity of the tablet is unqualified.
[0090] Optionally, the color difference of the pills can also be detected in this embodiment. Specifically, the color difference between pills is calculated based on the RGB values of the pill images of multiple pills, and whether the color difference of the pills is qualified is determined based on the comparison result between the color difference between pills and the pill color difference threshold.
[0091] Optionally, the weight difference of the pills can also be detected in this embodiment. Specifically, the weight difference between pills among multiple pills in the medicine is obtained, and whether the weight difference of the pills is qualified is determined based on the comparison result between the weight difference between pills and the pill weight difference threshold.
[0092] The above weight difference can be detected by a weight sensor for the pills, and the weight sensor can be set on the discharge platform.
[0093] Optionally, in this embodiment, internal scanning of the medicament can also be performed by means such as spectral analysis and acoustic scanning to obtain internal structure data of the medicament. Based on the comparison between the internal structure data and the preset standard internal structure data of the medicament, it is determined whether the medicament is sufficient, whether there are missing pieces, etc., so as to determine whether the integrity of the internal structure of the medicament is qualified.
[0094] It should be understood that the above side length difference threshold, diameter difference threshold, long and short axis difference threshold, weight difference threshold between medicaments, and color difference threshold between medicaments in this embodiment can be flexibly adjusted according to the strictness of the qualification of the medicament.
[0095] In addition, whether the result of the medicament detection in this embodiment is qualified can be determined that the detection result is qualified when the size uniformity, regularity, color difference, and weight difference are all qualified, or it can be determined that the detection result is qualified when any one of them is qualified, and the judgment order of the qualification of the size uniformity, regularity, color difference, and weight difference is not limited.
[0096] In scenarios such as hospitals and pharmacies for dispensing and dispensing medicaments to patient pharmacies, for the electronic prescription of each user, the corresponding medicament can be matched in the medicament database of the dispensing system, and then the automatic identification and dispensing of the medicament can be performed. The medicament database can store data such as the production batch and production qualification test results of the medicament.
[0097] Optionally, after the medicament detection method in this embodiment completes the medicament detection, it can also send the result of whether the shape of the medicament is qualified to the dispensing system to feedback the production qualification test result of the medicament corresponding to the production batch of the medicament in the dispensing system.
[0098] To cooperate with the above medicament detection method, an embodiment of the present application also provides a medicament detection device 20. Please refer to Figure 4 , Figure 4 which is a module schematic diagram of a medicament detection device provided by an embodiment of the present application.
[0099] The medicament detection device 20 includes:
[0100] A type detection module 21 for detecting the shape type of the medicament based on the medicament image;
[0101] A data determination module 22 for determining the specified shape data of the medicament based on the shape type;
[0102] A fitting module 23 for obtaining the fitting data of the medicament image;
[0103] A qualification detection module 24 for determining whether the shape of the medicament is qualified based on the comparison result between the fitting data and the specified shape data.
[0104] Optionally, the shape type includes pills, and the fitting module 23 is specifically configured to: establish a positioning coordinate system according to the inclination angle of the discharging platform of the pills, where the horizontal axis of the positioning coordinate system coincides with the discharging edge of the discharging platform, and the discharging edge is the edge of the discharging platform parallel to the discharging direction, and the vertical axis of the positioning coordinate system is perpendicular to the discharging edge; fit the pharmaceutical images in the positioning coordinate system to obtain fitting data, where the fitting data includes the diameter and the center of the circle of the pharmaceutical images.
[0105] Optionally, the specified shape data of the pills includes the diameter difference threshold between the pharmaceuticals, and the qualified detection module 24 is specifically configured to: calculate the diameter difference between the pharmaceuticals based on the diameters of the pharmaceutical images of multiple pharmaceuticals in the medicine; when the diameter difference between the pharmaceuticals is less than the diameter difference threshold between the pharmaceuticals, determine that the size uniformity of the shape of the pharmaceuticals is qualified.
[0106] Optionally, the specified shape data of the pills includes the center coordinate threshold between the pharmaceuticals, and the qualified detection module 24 is specifically configured to: calculate the center coordinate difference between the pharmaceuticals based on the centers of the circles of the pharmaceutical images of multiple pharmaceuticals in the medicine; when the center coordinate difference between the pharmaceuticals is less than the center coordinate threshold between the pharmaceuticals, determine that the regularity of the shape of the pharmaceuticals is qualified.
[0107] Optionally, the shape type includes round tablets, square tablets, and oval tablets, and the qualified detection module 24 is specifically configured to: when the side length difference in the fitting data of the round tablets is less than the side length difference threshold in the specified shape data, determine that the regularity of the shape of the pharmaceuticals is qualified; when the diameter difference in the fitting data of the square tablets is less than the diameter difference threshold in the specified shape data, determine that the regularity of the shape of the pharmaceuticals is qualified; when the major and minor axis difference in the fitting data of the oval tablets is less than the major and minor axis difference threshold in the specified shape data, determine that the regularity of the shape of the pharmaceuticals is qualified.
[0108] Optionally, the pharmaceutical detection device 20 may further include: a color difference detection module, configured to calculate the color difference between the pharmaceuticals based on the RGB values of the pharmaceutical images of multiple pharmaceuticals in the medicine; and determine whether the color difference of the pharmaceuticals is qualified based on the comparison result between the color difference between the pharmaceuticals and the color difference threshold between the pharmaceuticals.
[0109] Optionally, the pharmaceutical detection device 20 may further include: a weight detection module, configured to obtain the weight difference between the pharmaceuticals by acquiring multiple pharmaceuticals in the medicine; and determine whether the weight difference of the pharmaceuticals is qualified based on the comparison result between the weight difference between the pharmaceuticals and the weight difference threshold between the pharmaceuticals.
[0110] The embodiment of the present application further provides an electronic device, which includes a memory and a processor. When the processor reads and runs the program instructions stored in the memory, the steps in any one of the pharmaceutical detection methods provided in this embodiment are executed.
[0111] It should be understood that the electronic device can be an electronic device with logical computing functions such as a personal computer (PC), a tablet computer, a smart phone, a personal digital assistant (PDA), etc.
[0112] An embodiment of the present application also provides a readable storage medium, in which computer program instructions are stored. When the computer program instructions are read and run by a processor, the steps in the pharmaceutical detection method are executed.
[0113] In summary, an embodiment of the present application provides a pharmaceutical detection method, device, electronic device and storage medium. The method includes: detecting the shape type of the pharmaceutical based on the pharmaceutical image; determining the specified shape data of the pharmaceutical based on the shape type; obtaining the fitting data of the pharmaceutical image; and determining whether the shape of the pharmaceutical is qualified based on the comparison result between the fitting data and the specified shape data.
[0114] In the above implementation, image recognition and fitting are performed on the pharmaceutical, and the fitting data and the specified shape data are compared based on the shape type of the pharmaceutical, so as to determine whether the shape of the pharmaceutical is qualified. It is not necessary to perform manual dimension measurement, nor is it necessary to measure each pharmaceutical individually with equipment such as a weight sensor, which improves the efficiency of pharmaceutical shape measurement.
[0115] In several embodiments provided by the present application, it should be understood that the disclosed device can also be implemented in other ways. The device embodiments described above are only illustrative. For example, the block diagrams in the drawings show the possible architectures, functions, and operations of the devices according to multiple embodiments of the present application. In this regard, each block in the block diagram can represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the drawings. For example, two consecutive blocks can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram, as well as the combination of the block diagrams, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0116] In addition, each functional module in the various embodiments of the present application can be integrated together to form an independent part, or each module can exist alone, or two or more modules can be integrated to form an independent part.
[0117] If the above-mentioned functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Therefore, this embodiment also provides a computer-readable storage medium storing computer program instructions. When the computer program instructions are read and run by a processor, the steps in any of the methods of the block data storage method are executed. Based on such an understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, RanDom Access Memory), magnetic disks, or optical discs that can store program codes.
[0118] The above are only the embodiments of this application and are not used to limit the protection scope of this application. For those skilled in the art, this application can have various changes and modifications. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of this application shall be included in the protection scope of this application. It should be noted that similar reference numerals and letters indicate similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.
[0119] It should be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "including", "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitations, the elements defined by the statement "including..." do not exclude the existence of additional identical elements in the process, method, article or device including the said elements.
Claims
1. A pharmaceutical detection method, characterized in that, The method includes: Detecting the shape type of the medicament based on the medicament image; Determining the specified shape data of the medicament based on the shape type; Obtaining the fitting data of the medicament image; Determining whether the shape of the medicament is qualified based on the comparison result between the fitting data and the specified shape data; The shape type includes pills, and obtaining the fitting data of the medicament image includes: Establishing a positioning coordinate system according to the inclination angle of the discharging platform of the pills, where the horizontal axis of the positioning coordinate system coincides with the discharging edge of the discharging platform, the discharging edge is the edge of the discharging platform parallel to the discharging direction, and the vertical axis of the positioning coordinate system is perpendicular to the discharging edge; wherein, the included angle between the discharging platform and the horizontal plane is in the interval of (0, 90°); Fitting the medicament image in the positioning coordinate system to obtain the fitting data, the fitting data includes the diameter and the center of the medicament image; the specified shape data of the pills includes the diameter difference threshold between medicaments, and determining whether the shape of the medicament is qualified based on the comparison result between the fitting data and the specified shape data further includes: Calculating the diameter difference between medicaments based on the diameters of the medicament images of multiple medicaments in the medicament; When the diameter difference between medicaments is less than the diameter difference threshold between medicaments, determining that the size uniformity of the shape of the medicament is qualified; The specified shape data of the pills includes the center coordinate threshold between medicaments, and determining whether the shape of the medicament is qualified based on the comparison result between the fitting data and the specified shape data further includes: Calculating the center coordinate difference between medicaments based on the centers of the medicament images of multiple medicaments in the medicament; When the center coordinate difference between medicaments is less than the center coordinate threshold between medicaments, determining that the regularity of the shape of the medicament is qualified.
2. The method according to claim 1, characterized in that, The shape type includes round tablets, square tablets and oval tablets, and determining whether the shape of the medicament is qualified based on the comparison result between the fitting data and the specified shape data includes: When the diameter difference in the fitting data of the round tablets is less than the diameter difference threshold in the specified shape data, determining that the regularity of the shape of the medicament is qualified; When the side length difference in the fitting data of the square tablets is less than the side length difference threshold in the specified shape data, determining that the regularity of the shape of the medicament is qualified; When the major and minor axis difference in the fitting data of the oval tablets is less than the major and minor axis difference threshold in the specified shape data, determining that the regularity of the shape of the medicament is qualified.
3. The method according to claim 1, wherein The method further includes: Calculating the color difference between medicaments based on the RGB values of the medicament images of multiple medicaments in the medicament; Determining whether the color difference of the medicament is qualified based on the comparison result between the color difference between medicaments and the color difference threshold between medicaments.
4. The method according to claim 1, characterized in that, The method further includes: Obtaining the weight difference between medicaments of multiple medicaments in the medicament; Determining whether the weight difference of the medicament is qualified based on the comparison result between the weight difference between medicaments and the weight difference threshold between medicaments.
5. A pharmaceutical detection device, characterized in that, The device includes: A type detection module for detecting the shape type of the medicament based on the medicament image; A data determination module for determining specified shape data of a medicament based on the shape type; A fitting module for obtaining fitting data of the medicament image; A qualification detection module for determining whether the shape of the medicament is qualified based on a comparison result between the fitting data and the specified shape data; The shape type includes pills. During the process of obtaining the fitting data of the medicament image, the fitting module is specifically configured to: establish a positioning coordinate system according to the inclination angle of the discharging platform of the pills, where the horizontal axis of the positioning coordinate system coincides with the discharging edge of the discharging platform, the discharging edge is the edge of the discharging platform parallel to the discharging direction, and the vertical axis of the positioning coordinate system is perpendicular to the discharging edge; fit the medicament image in the positioning coordinate system to obtain the fitting data, and the fitting data includes the diameter and the center of the medicament image; wherein, the included angle between the discharging platform and the horizontal plane is in the interval of (0, 90°); The specified shape data of the pills includes a diameter difference threshold between medicaments. During the process of determining whether the shape of the medicament is qualified based on a comparison result between the fitting data and the specified shape data, the qualification detection module is specifically configured to: calculate the diameter difference between medicaments based on the diameters of the medicament images of multiple medicaments in the medicament; when the diameter difference between medicaments is less than the diameter difference threshold between medicaments, determine that the size uniformity of the shape of the medicament is qualified; The specified shape data of the pills includes a center coordinate threshold between medicaments. During the process of determining whether the shape of the medicament is qualified based on a comparison result between the fitting data and the specified shape data, the qualification detection module is specifically configured to: calculate the center coordinate difference between medicaments based on the centers of the medicament images of multiple medicaments in the medicament; when the center coordinate difference between medicaments is less than the center coordinate threshold between medicaments, determine that the regularity of the shape of the medicament is qualified.
6. An electronic device, characterized in that, The electronic device includes a memory and a processor. When the processor runs the program instructions stored in the memory, it executes the steps in the method according to any one of claims 1 - 4.
7. A storage medium, characterized in that, The computer program instructions are stored in the storage medium. When the computer program instructions are run by a processor, it executes the steps in the method according to any one of claims 1 - 4.
Citation Information
Patent Citations
Method and system for detecting drug blister package defect based on machine vision
CN108344743A