Drug packaging defect detection method and system based on artificial intelligence

Through the artificial intelligence-based drug packaging defect detection method, image processing technology is used to automatically detect drug packaging defects, solving the problems of low efficiency and poor accuracy in the existing technology, and achieving efficient and accurate defect detection.

CN119006406APending Publication Date: 2024-11-22江西省药品检查员中心
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411078833.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-07
Publication Date
2024-11-22

AI Technical Summary

Technical Problem

The inspection of traditional Chinese medicine packaging defects relies on manual quality inspection, which is low in efficiency and low accuracy, making it difficult to meet the needs of large-scale production.

Method used

Using an artificial intelligence-based method, the medicine board image is obtained for smoothing, background segmentation, correction processing, scaling processing and area segmentation, the identification code is extracted, and the image is converted to the Lab color space for grayscale transformation and defect determination, so as to achieve Automated detection.

Benefits of technology

It improves the efficiency and accuracy of drug packaging defect detection, reduces human identification errors, and ensures the accuracy of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119006406A_ABST
    Figure CN119006406A_ABST
Patent Text Reader

Abstract

The invention provides a drug package defect detection method and system based on artificial intelligence, and the method comprises the steps: obtaining a drug plate image, and carrying out the smoothing of the drug plate image, so as to obtain a first to-be-processed image; performing background segmentation on the first to-be-processed image to obtain a second to-be-processed image, performing correction processing and zooming processing on the second to-be-processed image to form a third to-be-processed image, performing region segmentation on the third to-be-processed image to segment the third to-be-processed image into a peripheral image and a central image, and extracting an identification code from the peripheral image; and converting the central image into a Lab color space to obtain a first channel image, carrying out gray scale transformation processing on the first channel image to obtain an identification image, and carrying out defect determination on the identification image based on the identification code to determine whether the drug package has defects. The packaging defect detection is completed in an automatic and intelligent mode, and compared with a manual detection mode, the defect detection efficiency is improved, and the defect detection accuracy is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to a drug packaging defect detection method and system based on artificial intelligence. Background Art

[0002] With the continuous expansion of the pharmaceutical industry market, the quality requirements for pharmaceutical products, that is, the quality of medicines, have also increased. The quality of medicines lies not only in the quality of the medicine itself, but also in the quality of its packaging.

[0003] Nowadays, many drugs are packaged in aluminum foil medicine plates, on which a number of uniformly distributed medicine capsules are arranged, and the packaging work is completed by encapsulating the drugs in the medicine capsules. Drug packaging defects generally refer to the absence, cracking, and damage of drugs during the packaging process.

[0004] Currently, the detection of drug packaging defects still relies heavily on manual quality inspection. However, with the increase in production, the speed of manual quality inspection has gradually been unable to meet production needs. In addition, there are certain human recognition errors in the process of manual quality inspection, and the detection accuracy is low. Summary of the invention

[0005] In view of the shortcomings of the prior art, the purpose of the present invention is to provide a method and system for drug packaging defect detection based on artificial intelligence, aiming to solve the technical problems in the prior art of drug packaging defect detection through manual quality inspection, which has low efficiency and low detection accuracy.

[0006] In order to achieve the above objectives, in a first aspect, an embodiment of the present application provides a drug packaging defect detection method based on artificial intelligence, comprising the following steps:

[0007] Acquire a medicine plate image of an aluminum-plastic medicine plate packaged with medicines, and perform smoothing processing on the medicine plate image to obtain a first image to be processed;

[0008] Performing background segmentation on the first image to be processed to obtain a second image to be processed, and performing correction processing on the second image to be processed to make the second image to be processed in a horizontal state;

[0009] Scaling the second image to be processed to adjust the second image to be processed to a standard size to form a third image to be processed, segmenting the third image to be processed into a peripheral image and a central image, and extracting an identification code corresponding to the aluminum-plastic medicine plate from the peripheral image;

[0010] The central image is converted into Lab color space to obtain a first channel image, the first channel image is subjected to grayscale transformation processing to obtain a recognition image, and a defect determination is performed on the recognition image based on the identification code to determine whether there is a defect in the drug packaging.

[0011] Compared with the prior art, the beneficial effects of the present invention are as follows: since the plane of the aluminum-plastic medicine plate is relatively rough, there is noise influence when acquiring the medicine plate image. By smoothing the medicine plate image, a certain noise suppression effect can be produced, which is convenient for subsequent defect detection; by performing the background segmentation, the area where the aluminum-plastic medicine plate is located can be extracted, the amount of calculation can be reduced, and the defect recognition efficiency can be improved; by making the second image to be processed in a horizontal state, the recognition difficulty caused by the uneven placement of the aluminum-plastic medicine plate during the detection process can be avoided; by extracting the identification code, the defect-free packaging sample can be determined, and it can be compared with the identification image, thereby automatically and intelligently completing the detection of packaging defects. Compared with the manual detection method, not only the defect detection efficiency is improved, but also the accuracy of defect detection is ensured.

[0012] Further, the step of smoothing the medicine plate image includes:

[0013] Setting one of the initial pixel points in the medicine plate image as a center point, and obtaining an initial pixel value of the center point;

[0014] Detecting the initial pixel point adjacent to the center point to obtain a number of neighboring points and a number of neighboring pixel values;

[0015] A median process is performed on a plurality of the neighboring pixel values ​​and the initial pixel value to obtain an updated pixel value, and the initial pixel value is replaced by the updated pixel value.

[0016] Furthermore, the step of performing correction processing on the second image to be processed includes:

[0017] Obtaining the corner point coordinates of two adjacent corner points in the second image to be processed;

[0018] Determine a first distance between the two corner points in the horizontal direction and a second distance between the two corner points in the vertical direction based on the coordinates of the two corner points, and determine one of the corner points as a reference point based on the coordinates of the two corner points;

[0019] Determining a rotation angle of the second image to be processed according to the first spacing and the second spacing;

[0020] The position of the second image to be processed is corrected using the reference point and the rotation angle.

[0021] Furthermore, the step of scaling the second image to be processed includes:

[0022] Comparing the length of the long side of the second image to be processed with the first standard length to obtain a long side adjustment coefficient, and comparing the length of the short side of the second image to be processed with the second standard length to obtain a short side adjustment coefficient;

[0023] Taking the center of the second image to be processed as the origin, scaling processing is performed on the second image to be processed using the long side adjustment coefficient and the short side adjustment coefficient.

[0024] Furthermore, the step of dividing the third image to be processed into regions is specifically as follows:

[0025] The outer contour line of the third image to be processed is obtained, and the center of the third image to be processed is used as the origin, and the outer contour line is shrunk based on a preset scaling ratio to form a segmentation contour line, and the third image to be processed is segmented by the segmentation contour line.

[0026] Furthermore, the step of performing defect determination on the recognition image based on the identification code includes:

[0027] Retrieving the medicine board type and packaging reference diagram corresponding to the identification code in the database;

[0028] Determine a segmentation line by the type of the medicine plate, and segment the recognition image based on the segmentation line to obtain a plurality of area maps corresponding to the medicines;

[0029] The area map is obtained and compared with the packaging reference map to obtain a similarity value between the area map and the packaging reference map, and a defect determination is performed on the recognition image based on the similarity value.

[0030] Furthermore, after the step of determining the segmentation line by the type of the medicine plate and segmenting the recognition image based on the segmentation line to obtain a plurality of area maps corresponding to the medicines, the method further includes:

[0031] The region map is sequentially subjected to an opening operation and a closing operation to filter out noise of the region map and fill holes of the region map.

[0032] Furthermore, after the steps of converting the central image into the Lab color space to obtain a first channel image, performing grayscale transformation processing on the first channel image to obtain a recognition image, and performing defect determination on the recognition image based on the identification code to determine whether the drug packaging has defects, the method further includes:

[0033] If there is a defect in the drug packaging, a difference process is performed between the area map and the packaging reference map to obtain a defective area, and the defect type is determined based on the defective area.

[0034] In a second aspect, an embodiment of the present application provides a drug packaging defect detection system based on artificial intelligence, which is applied to the drug packaging defect detection method based on artificial intelligence as described in the first aspect above, and the system includes:

[0035] An acquisition module, used for acquiring a medicine plate image of an aluminum-plastic medicine plate packaging medicines, and performing smoothing processing on the medicine plate image to acquire a first image to be processed;

[0036] A first adjustment module is used to perform background segmentation on the first image to be processed to obtain a second image to be processed, and to perform correction processing on the second image to be processed to make the second image to be processed in a horizontal state;

[0037] a second adjustment module, configured to perform scaling processing on the second image to be processed so as to adjust the second image to be processed to a standard size to form a third image to be processed, perform region segmentation on the third image to be processed so as to divide the third image to be processed into a peripheral image and a central image, and extract an identification code corresponding to the aluminum-plastic medicine plate from the peripheral image;

[0038] The analysis module is used to convert the central image into the Lab color space to obtain a first channel image, perform grayscale transformation processing on the first channel image to obtain a recognition image, and perform defect determination on the recognition image based on the identification code to determine whether there is a defect in the drug packaging.

[0039] In a third aspect, an embodiment of the present application provides a computer, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the artificial intelligence-based drug packaging defect detection method as described in the first aspect above is implemented.

[0040] In a fourth aspect, an embodiment of the present application provides a storage medium having a computer program stored thereon, which, when executed by a processor, implements the artificial intelligence-based drug packaging defect detection method as described in the first aspect above. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 This is a flow chart of a drug packaging defect detection method based on artificial intelligence in the first embodiment of the present invention;

[0042] Figure 2 It is a structural block diagram of a drug packaging defect detection system based on artificial intelligence in the second embodiment of the present invention;

[0043] The following specific implementation manner will further illustrate the present invention in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION

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

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

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

[0047] See also Figure 1 The first embodiment of the present invention provides a drug packaging defect detection method based on artificial intelligence, which is applied to a defect detection device. The defect detection device includes a conveyor belt, which is used to transport aluminum-plastic medicine plates packaged with medicines. A shooting device is arranged on the conveyor belt. Preferably, the shooting device is located directly above the conveyor belt. The drug packaging defect detection method based on artificial intelligence includes the following steps:

[0048] S10: Acquire a medicine plate image of an aluminum-plastic medicine plate packaged with medicines, and perform smoothing on the medicine plate image to acquire a first image to be processed;

[0049] That is, the medicine plate image is photographed by the photographing device.

[0050] Specifically, the step S10 includes:

[0051] S110: setting one of the initial pixel points in the medicine plate image as a center point, and obtaining an initial pixel value of the center point;

[0052] S120: Detecting the initial pixel point adjacent to the center point to obtain a plurality of adjacent points and a plurality of adjacent pixel values;

[0053] A circular frame selection area or a rectangular frame selection area may be set based on the center point, and the initial pixel point in the circular frame selection area or the rectangular frame selection area is used as the neighboring point.

[0054] S130: Perform median processing on a plurality of the neighboring pixel values ​​and the initial pixel value to obtain an updated pixel value, and replace the initial pixel value with the updated pixel value.

[0055] After obtaining the neighboring pixel values ​​and the initial pixel values, several of the neighboring pixel values ​​and the initial pixel values ​​are sorted, and the pixel value in the middle is taken as the updated pixel value. It should be noted that if the number of the neighboring pixel values ​​and the initial pixel values ​​is an even number, that is, there are two pixel values ​​in the middle, then the two pixel values ​​in the middle are averaged to obtain the updated pixel value.

[0056] It can be understood that the above operation is performed on each of the initial pixel points in the medicine plate image to obtain the first image to be processed.

[0057] S20: performing background segmentation on the first image to be processed to obtain a second image to be processed, and performing correction processing on the second image to be processed to make the second image to be processed in a horizontal state;

[0058] By determining the segmentation threshold, the background segmentation can be performed on the first image to be processed to determine the region of interest, that is, the region where the aluminum-plastic medicine plate is located, from the first image to be processed. It can be understood that the aluminum-plastic medicine plates are all rectangular medicine plates, and their overall structure is relatively regular, with two equal long sides and two equal short sides.

[0059] The step S20 comprises:

[0060] S210: Obtaining the corner point coordinates of two adjacent corner points in the second image to be processed;

[0061] In this embodiment, two end points of the long side located at the bottom are selected as the two corner points, and the corner point coordinates of the two corner points can be determined by constructing a coordinate system.

[0062] S220: determining a first distance between the two corner points in the horizontal direction and a second distance between the two corner points in the vertical direction based on the coordinates of the two corner points, and determining one of the corner points as a reference point based on the coordinates of the two corner points;

[0063] The y-axis coordinates of the two corner point coordinates are compared, and the corner point with the smaller y-axis coordinate is determined as the reference point. The first spacing can be determined by the difference in the x-axis coordinates of the two corner point coordinates, and the second spacing can be determined by the difference in the y-axis coordinates of the two corner point coordinates.

[0064] S230: determining a rotation angle of the second image to be processed according to the first spacing and the second spacing;

[0065] After obtaining the first spacing and the second spacing, the rotation angle may be determined by a tangent formula.

[0066] S240: performing position correction on the second image to be processed by using the reference point and the rotation angle;

[0067] The rotation direction can be determined by the positional relationship between the reference point and another corner point. Specifically, if the reference point is located on the left side of another corner point, it rotates right; if the reference point is located on the right side of another corner point, it rotates left.

[0068] S30: scaling the second image to be processed to adjust the second image to be processed to a standard size to form a third image to be processed, segmenting the third image to be processed into a peripheral image and a central image, and extracting an identification code corresponding to the aluminum-plastic medicine plate from the peripheral image;

[0069] Based on the regularity of the structure of the aluminum-plastic medicine plate, after obtaining the second image to be processed, it needs to be adjusted to the same size as the entity to facilitate subsequent detection and comparison.

[0070] The step S30 comprises:

[0071] S310: comparing the length of the long side of the second image to be processed with the first standard length to obtain a long side adjustment coefficient, and comparing the length of the short side of the second image to be processed with the second standard length to obtain a short side adjustment coefficient;

[0072] S320: Taking the center of the second image to be processed as the origin, scaling the second image to be processed using the long side adjustment coefficient and the short side adjustment coefficient.

[0073] It should be noted that if the length of the long side is less than the first standard length, it needs to be enlarged; if the length of the long side is less than the first standard length, it needs to be reduced.

[0074] S330: acquiring an outer contour line of the third image to be processed, taking the center of the third image to be processed as the origin, shrinking the outer contour line based on a preset scaling ratio to form a segmentation contour line, and performing region segmentation on the third image to be processed by using the segmentation contour line;

[0075] It can be understood that the outer contour line is also a rectangular structure, and the segmented contour line after scaling by the preset scaling ratio is also a rectangular structure. It should be noted that the preset scaling ratio includes a length scaling ratio and a width scaling ratio, so as to perform center contraction on the long side direction and the wide side direction of the segmented contour line respectively. After the area segmentation is performed, the area outside the medicine bag of the aluminum-plastic medicine plate can be segmented, further reducing the amount of data processing in the subsequent processing process and improving the speed of defect detection. At the same time, the identification code can also be determined from the segmented outer image. In this embodiment, the identification code is the batch number of the medicine plate.

[0076] The step of extracting the identification code corresponding to the aluminum-plastic medicine plate from the peripheral image is specifically as follows:

[0077] The identification areas of different medicine plate models are extracted from the database, the different identification areas are marked on the peripheral image, and text is extracted from the identification areas to obtain the identification code.

[0078] There are many algorithms for extracting text from images, which will not be described in detail here.

[0079] S40: converting the central image into a Lab color space to obtain a first channel image, performing grayscale transformation processing on the first channel image to obtain a recognition image, and performing defect determination on the recognition image based on the identification code to determine whether the drug packaging has defects;

[0080] The Lab color space includes a brightness channel (L channel), an a channel and a b channel, wherein the a channel represents the component from green to red, and the b channel represents the component from blue to yellow, and the first channel image is the a channel image. The steps of converting the central image to the Lab color space are as follows:

[0081] The central image is converted into a calibration space to obtain a transfer image, and the transfer image is converted into a Lab color space.

[0082] The expression of the transfer image is:

[0083]

[0084] in, Indicates the transfer image. Indicates the center image.

[0085] The expression of the transfer image in the Lab color space is:

[0086]

[0087] Wherein, L represents the brightness channel of the transfer image in the Lab color space, a represents the a channel of the transfer image in the Lab color space, b represents the b channel of the transfer image in the Lab color space, and f(·) represents a piecewise function.

[0088] By converting the central image to the Lab color space, the influence of light during the image capture process can be avoided in the process of acquiring the medicine plate image, so as to improve the accuracy of subsequent defect detection. By performing grayscale transformation processing on the first channel image, the contrast between the medicine and the aluminum-plastic medicine plate in the first channel image can be improved, so as to facilitate the subsequent separation of the area corresponding to the medicine therefrom.

[0089] The aluminum-plastic medicine plate is provided with a plurality of medicine capsules, that is, a plurality of medicines are stored. If the detection is performed simultaneously, the different regions are intertwined and disorderly, which may easily affect the accuracy of defect detection. In this embodiment, the standardized structure of the aluminum-plastic medicine plate is utilized to split the regions where different medicines are located, and then compare them separately to improve the accuracy of defect detection. Specifically, the step S40 includes:

[0090] S410: searching the database for the medicine board type and packaging reference diagram corresponding to the identification code;

[0091] It can be understood that different identification codes correspond to different medicine board types. Based on the medicine board type, the packaging reference image of the medicine after being packaged in the aluminum-plastic medicine board can be determined in the absence of defects.

[0092] S420: Determine a segmentation line according to the type of the medicine plate, and segment the recognition image based on the segmentation line to obtain a plurality of area maps corresponding to the medicines;

[0093] Different types of medicine boards have different distribution positions of medicine capsules. Therefore, after determining the type of medicine board, the segmentation lines for separating the individual medicines can be automatically planned, thereby completing the acquisition of the area map.

[0094] S430: obtaining the area map and performing a similarity comparison with the packaging reference map to obtain a similarity value between the area map and the packaging reference map, and performing defect determination on the recognition image based on the similarity value;

[0095] It can be understood that the packaging reference image undergoes the same processing as the area map to ensure the similarity between the two. In this embodiment, by setting a similarity threshold, the similarity value is compared with the similarity threshold. If the similarity value is less than the similarity threshold, it is determined that the recognition image has defects. Furthermore, in different area maps of the same aluminum-plastic medicine plate, if any of the area maps has defects, it is determined that the drug packaging has defects. By setting the identification code, the aluminum-plastic medicine plate with defects can also be marked and stored, which is convenient for subsequent review and rectification.

[0096] Preferably, after step S420, the method further includes:

[0097] S440: performing an opening operation and a closing operation on the region map in sequence to filter out noise of the region map and fill holes of the region map;

[0098] The opening operation processing is to perform corrosion processing and expansion processing on the area map in sequence, and the closing operation processing is to perform expansion processing and corrosion processing on the area map in sequence. Through the opening operation processing and the closing operation processing, not only can the area map be made smoother, but also the partial missing parts caused by image processing in the process of obtaining the area map can be filled, thereby further improving the accuracy of defect detection.

[0099] Since the plane of the aluminum-plastic medicine plate is relatively rough, there is noise influence when acquiring the medicine plate image. By smoothing the medicine plate image, a certain noise suppression effect can be produced, which is convenient for subsequent defect detection; by performing the background segmentation, the area where the aluminum-plastic medicine plate is located can be extracted, the amount of calculation can be reduced, and the efficiency of defect recognition can be improved; by making the second image to be processed in a horizontal state, the recognition difficulty caused by the uneven placement of the aluminum-plastic medicine plate during the detection process can be avoided; by extracting the identification code, the defect-free packaging sample can be determined and compared with the identification image, thereby completing the detection of packaging defects automatically and intelligently. Compared with the manual detection method, not only the defect detection efficiency is improved, but also the accuracy of defect detection is ensured.

[0100] Preferably, the method further comprises:

[0101] S50: If the drug package has defects, performing a difference set process on the area map and the package reference map to obtain a defective area, and determining a defect type based on the defective area;

[0102] It can be understood that the difference processing is to eliminate the overlapping area between the area map and the packaging reference map to retain the defective area. If the defective area is located in the entire medicine capsule, there is a drug missing defect. If the defective area is located in the edge area of ​​the medicine capsule or in part of the internal area of ​​the medicine capsule, there is a drug defect. If the defective area extends from the internal area of ​​the medicine capsule to the edge area, there is a drug cracking defect.

[0103] See also Figure 2 The second embodiment of the present invention provides a drug packaging defect detection system based on artificial intelligence, which is applied to the drug packaging defect detection method based on artificial intelligence in the above embodiment, and will not be repeated here. As used below, the terms "module", "unit", "subunit", etc. can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0104] The system comprises:

[0105] An acquisition module 10 is used to acquire a medicine plate image of an aluminum-plastic medicine plate packaged with medicines, and to perform smoothing processing on the medicine plate image to acquire a first image to be processed;

[0106] The acquisition module 10 includes:

[0107] The first unit is used to set one of the initial pixel points in the medicine plate image as a center point and obtain an initial pixel value of the center point;

[0108] The second unit is used to detect the initial pixel point adjacent to the center point to obtain a plurality of adjacent points and a plurality of adjacent pixel values;

[0109] The third unit is used to perform median processing on a plurality of the adjacent pixel values ​​and the initial pixel value to obtain an updated pixel value, and replace the initial pixel value with the updated pixel value.

[0110] A first adjustment module 20 is used to perform background segmentation on the first image to be processed to obtain a second image to be processed, and to perform correction processing on the second image to be processed so that the second image to be processed is in a horizontal state;

[0111] The first adjustment module 20 includes:

[0112] A fourth unit is used to obtain the corner point coordinates of two adjacent corner points in the second image to be processed;

[0113] A fifth unit is used to determine a first spacing between the two corner points in the horizontal direction and a second spacing between the two corner points in the vertical direction based on the coordinates of the two corner points, and determine one of the corner points as a reference point based on the coordinates of the two corner points;

[0114] A sixth unit, configured to determine a rotation angle of the second image to be processed according to the first spacing and the second spacing;

[0115] A seventh unit, configured to perform position correction on the second image to be processed by using the reference point and the rotation angle;

[0116] The second adjustment module 30 is used to perform scaling processing on the second image to be processed to adjust the second image to be processed to a standard size to form a third image to be processed, perform region segmentation on the third image to be processed to divide the third image to be processed into a peripheral image and a central image, and extract the identification code corresponding to the aluminum-plastic medicine plate from the peripheral image;

[0117] The second adjustment module 30 includes:

[0118] An eighth unit is used to compare the length of the long side of the second image to be processed with the first standard length to obtain a long side adjustment coefficient, and compare the length of the short side of the second image to be processed with the second standard length to obtain a short side adjustment coefficient;

[0119] A ninth unit, configured to scale the second image to be processed by using the long side adjustment coefficient and the short side adjustment coefficient with the center of the second image to be processed as the origin;

[0120] A tenth unit is used to obtain an outer contour line of the third image to be processed, take the center of the third image to be processed as the origin, shrink the outer contour line based on a preset scaling ratio to form a segmentation contour line, and perform region segmentation on the third image to be processed by the segmentation contour line;

[0121] An analysis module 40 is used to convert the central image into a Lab color space to obtain a first channel image, perform grayscale transformation processing on the first channel image to obtain a recognition image, and perform defect determination on the recognition image based on the identification code to determine whether the drug packaging has defects;

[0122] The analysis module 40 includes:

[0123] The eleventh unit is used to retrieve the medicine board type and packaging reference diagram corresponding to the identification code in the database;

[0124] A twelfth unit is used to determine a segmentation line according to the type of the medicine plate, and segment the recognition image based on the segmentation line to obtain a plurality of area maps corresponding to the medicines;

[0125] A thirteenth unit is used to obtain the area map and the packaging reference map for similarity comparison to obtain a similarity value between the area map and the packaging reference map, and perform defect determination on the recognition image based on the similarity value;

[0126] The analysis module 40 also includes:

[0127] A fourteenth unit is used for, after acquiring the area map, sequentially performing an opening operation and a closing operation on the area map to filter out noise of the area map and fill holes of the area map;

[0128] Preferably, the system further comprises:

[0129] The classification module 50 is used to perform a difference process between the area map and the packaging reference map to obtain a defective area if there is a defect in the drug package, and determine the defect type based on the defective area.

[0130] The present invention also provides a computer, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for drug packaging defect detection based on artificial intelligence as described in the above technical solution is implemented.

[0131] The present invention also provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the method for detecting drug packaging defects based on artificial intelligence as described in the above technical solution is implemented.

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

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

Claims

1. A drug packaging defect detection method based on artificial intelligence, characterized in that: The following steps are involved: Acquire a medicine plate image of an aluminum-plastic medicine plate packaged with medicines, and perform smoothing processing on the medicine plate image to obtain a first image to be processed; Performing background segmentation on the first image to be processed to obtain a second image to be processed, and performing correction processing on the second image to be processed to make the second image to be processed in a horizontal state; Scaling the second image to be processed to adjust the second image to be processed to a standard size to form a third image to be processed, segmenting the third image to be processed into a peripheral image and a central image, and extracting an identification code corresponding to the aluminum-plastic medicine plate from the peripheral image; The central image is converted into Lab color space to obtain a first channel image, the first channel image is subjected to grayscale transformation processing to obtain a recognition image, and a defect determination is performed on the recognition image based on the identification code to determine whether there is a defect in the drug packaging.

2. The method for drug packaging defect detection based on artificial intelligence according to claim 1, characterized in that: The step of smoothing the medicine plate image comprises: Setting one of the initial pixel points in the medicine plate image as a center point, and obtaining an initial pixel value of the center point; Detecting the initial pixel point adjacent to the center point to obtain a number of neighboring points and a number of neighboring pixel values; A median process is performed on a plurality of the neighboring pixel values ​​and the initial pixel value to obtain an updated pixel value, and the initial pixel value is replaced by the updated pixel value.

3. The drug packaging defect detection method based on artificial intelligence according to claim 1 is characterized in that: The step of performing correction processing on the second image to be processed comprises: Obtaining the corner point coordinates of two adjacent corner points in the second image to be processed; Determine a first distance between the two corner points in the horizontal direction and a second distance between the two corner points in the vertical direction based on the coordinates of the two corner points, and determine one of the corner points as a reference point based on the coordinates of the two corner points; Determining a rotation angle of the second image to be processed according to the first spacing and the second spacing; The position of the second image to be processed is corrected using the reference point and the rotation angle.

4. The method for drug packaging defect detection based on artificial intelligence according to claim 1, characterized in that: The step of performing scaling processing on the second image to be processed comprises: Comparing the length of the long side of the second image to be processed with the first standard length to obtain a long side adjustment coefficient, and comparing the length of the short side of the second image to be processed with the second standard length to obtain a short side adjustment coefficient; Taking the center of the second image to be processed as the origin, scaling processing is performed on the second image to be processed using the long side adjustment coefficient and the short side adjustment coefficient.

5. The method for drug packaging defect detection based on artificial intelligence according to claim 1, characterized in that: The step of dividing the third image to be processed into regions is specifically as follows: The outer contour line of the third image to be processed is obtained, and the center of the third image to be processed is used as the origin, and the outer contour line is shrunk based on a preset scaling ratio to form a segmentation contour line, and the third image to be processed is segmented by the segmentation contour line.

6. The drug packaging defect detection method based on artificial intelligence according to claim 1 is characterized in that: The step of performing defect determination on the recognition image based on the identification code comprises: Retrieving the medicine board type and packaging reference diagram corresponding to the identification code in the database; Determine a segmentation line by the type of the medicine plate, and segment the recognition image based on the segmentation line to obtain a plurality of area maps corresponding to the medicines; The area map is obtained and compared with the packaging reference map to obtain a similarity value between the area map and the packaging reference map, and a defect determination is performed on the recognition image based on the similarity value.

7. The method for drug packaging defect detection based on artificial intelligence according to claim 6, characterized in that: After the step of determining the segmentation line by the type of the medicine plate and segmenting the recognition image based on the segmentation line to obtain a plurality of area maps corresponding to the medicines, the method further includes: The region map is sequentially subjected to an opening operation and a closing operation to filter out noise of the region map and fill holes of the region map.

8. The method for drug packaging defect detection based on artificial intelligence according to claim 6, characterized in that: After the steps of converting the central image into the Lab color space to obtain a first channel image, performing grayscale transformation processing on the first channel image to obtain a recognition image, and performing defect determination on the recognition image based on the identification code to determine whether the drug packaging has defects, the method further includes: If there is a defect in the drug packaging, a difference process is performed between the area map and the packaging reference map to obtain a defective area, and the defect type is determined based on the defective area.

9. A drug packaging defect detection system based on artificial intelligence, applied to the drug packaging defect detection method based on artificial intelligence as claimed in any one of claims 1 to 8, characterized in that: The system comprises: An acquisition module, used for acquiring a medicine plate image of an aluminum-plastic medicine plate packaging medicines, and performing smoothing processing on the medicine plate image to acquire a first image to be processed; A first adjustment module is used to perform background segmentation on the first image to be processed to obtain a second image to be processed, and to perform correction processing on the second image to be processed to make the second image to be processed in a horizontal state; a second adjustment module, configured to perform scaling processing on the second image to be processed so as to adjust the second image to be processed to a standard size to form a third image to be processed, perform region segmentation on the third image to be processed so as to divide the third image to be processed into a peripheral image and a central image, and extract an identification code corresponding to the aluminum-plastic medicine plate from the peripheral image; The analysis module is used to convert the central image into the Lab color space to obtain a first channel image, perform grayscale transformation processing on the first channel image to obtain a recognition image, and perform defect determination on the recognition image based on the identification code to determine whether there is a defect in the drug packaging.

10. A computer comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the artificial intelligence-based drug packaging defect detection method as described in any one of claims 1 to 8 is implemented.

Citation Information

Cited By

  • Surface quality detection method and system for automobile exterior trimming product

    CN119338825A