Vision-based solid drug surface defect detection method and device and storage medium

By using a combination method of industrial cameras and RT-DTTC deep learning networks in drug surface defect detection, the trade-off between detection accuracy and comprehensiveness in the prior art is solved, and efficient, accurate detection and quality evaluation of drug surface defects is achieved.

CN119941735AActive Publication Date: 2025-05-06JILIN UNIV FIRST HOSPITAL
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202510431243.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-08
Publication Date
2025-05-06
Estimated Expiration
2045-04-08

AI Technical Summary

Technical Problem

There is a trade-off between accuracy and comprehensiveness of existing drug surface defect detection methods, which is difficult to meet the high standards for quality control in large-scale production.

Method used

Vision-based detection methods are adopted to collect surface images of drugs through industrial cameras and pre-process them, and defect detection is carried out in combination with RT-DTTC deep learning network, and key parameters of drugs are extracted using image processing technology to achieve accurate identification and quality evaluation of surface defects of drugs.

Benefits of technology

It realizes efficient and accurate detection of surface defects of drugs, significantly improves detection speed and accuracy, reduces the possibility of human errors, and provides an intelligent solution for drug quality management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119941735A_ABST
    Figure CN119941735A_ABST
Patent Text Reader

Abstract

The invention discloses a solid medicine surface defect detection method and device based on vision and a storage medium, and belongs to the technical field of image processing. The method comprises the following steps: acquiring a drug surface image by using an industrial camera; the collected images are preprocessed; the preprocessed image is input into the RT-DTTC deep learning network; if the RT-DTTC deep learning network detects that a defect exists on the surface of the drug, directly outputting a defect category; if the RT-DTTC deep learning network does not detect that defects exist on the surface of the medicine, key parameters of the medicine are extracted by using an image processing technology; whether the deviation of the key parameters is within a preset tolerance range or not is judged, and if the deviation of the key parameters is within the preset tolerance range, it is considered that the drug surface quality is qualified; and if the deviation of the key parameters is not within the preset tolerance range, determining that the surface quality of the medicine is unqualified. According to the invention, the speed and efficiency of drug surface quality detection can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of image processing, and in particular relates to a method, device and storage medium for detecting surface defects of solid medicines based on vision. Background Art

[0002] Drug quality testing is an important part of ensuring drug safety, effectiveness and stability. Especially during the production process, the appearance quality of drugs (such as the surface integrity of tablets and capsules) and packaging quality have a direct impact on the performance and user experience of the final product. While optimizing production efficiency, drug testing technology can also effectively control the flow of unqualified products into the market to avoid potential harm to patients' health.

[0003] Drug surface inspection and packaging inspection are the core parts of drug quality management. Their main goals are to detect whether there are defects such as cracks, dents, deformation, stains on the drug surface, and whether there are leaks, damage or printing errors in the packaging. If these defects are not discovered in time, they may not only affect the efficacy of the drug, but also lead to reduced product stability or contamination problems due to packaging failure, thereby affecting the safety of patients' medication.

[0004] At present, the drug quality inspection methods are mainly divided into drug appearance inspection method and package seal inspection method. Among them, the appearance inspection method usually uses traditional manual inspection or statistical machine vision methods to detect defects such as cracks, pits, stains and missing corners on the surface of drugs to evaluate the appearance quality of drugs. However, due to the complexity and subtlety of drug surface defects, traditional manual inspection is easily affected by subjective factors, and the inspection efficiency and accuracy are low. The statistical machine vision method is difficult to comprehensively and accurately judge whether the appearance quality of drugs is qualified.

[0005] In contrast, the package seal detection method mainly evaluates the protection and stability of drugs by testing the sealing and integrity of drug packaging, such as using airtightness testing or image analysis technology to detect leaks, damage, and printing errors in packaging. Although this method is intuitive and reliable in evaluating packaging quality, it is usually a destructive test and cannot fully test all products, so it is only suitable for small batch sampling analysis. Nevertheless, package seal testing can provide more accurate quality assessment and play an important role in the production process of high-risk drugs.

[0006] Overall, there is a certain trade-off between accuracy and comprehensiveness in existing drug testing methods. There is an urgent need to develop an efficient, non-destructive and comprehensive testing technology to meet the high standards for quality control in large-scale drug production. Summary of the invention

[0007] In order to solve the above-mentioned technical problem of low efficiency and accuracy in drug surface defect detection, the present invention provides a vision-based solid drug surface defect detection method, device and storage medium.

[0008] According to one aspect of the present invention, a method for detecting surface defects of solid medicines based on vision is provided, comprising: using an industrial camera to collect images of the surface of medicines, and adding a timestamp to each collected image, wherein the timestamp is used to add a time mark to the medicine on the image according to the image collection time; preprocessing the collected images to enhance the visibility of the surface defects of the medicines; inputting the preprocessed images into an RT-DTTC deep learning network to complete the detection of surface defects of medicines, wherein the RT-DTTC deep learning network is used to identify target medicines according to the input images, detect whether there are defects on the surface of the target medicines, and output the corresponding defect categories; if the RT-DTTC deep learning network detects that there are defects on the surface of the medicines, the defect categories are directly output; if the RT-DTTC deep learning network does not detect that there are defects on the surface of the medicines, the key parameters of the medicines are extracted using image processing technology, wherein the key parameters include tablet diameter and edge contour, which are used for tablet size measurement and edge integrity analysis respectively; judging whether the deviation of the key parameters is within a preset tolerance range, if the deviation of the key parameters is within the preset tolerance range, the surface quality of the medicines is considered to be qualified; if the deviation of the key parameters is not within the preset tolerance range, the surface quality of the medicines is considered to be unqualified.

[0009] Optionally, the preprocessing of the acquired image includes: adjusting the acquired image to the input size required by the deep learning model and standardizing the image pixel values; filtering out noise in the image using a nonlinear bilateral filtering method; performing image enhancement processing based on the spatial domain on the denoised image to improve the contrast between different areas on the surface of the drug, so as to make the distinction between defect features and normal areas more obvious.

[0010] Optionally, the RT-DTTC deep learning network is improved based on the RT-DETR network, and the improvements include: introducing a bidirectional fusion mechanism between high-resolution and low-resolution features to make the information transmission between features more sufficient, further improving the effect of multi-scale feature fusion; adopting an adaptive attention mechanism to adaptively adjust the weights of features according to the different resolutions and contents of feature maps, so as to better capture the multi-scale features of the target; selectively aggregating boundary information and semantic information to depict the contour of the object and recalibrate the position of the object; adding a P2 layer in the network structure to enhance the network's detection ability for small targets.

[0011] Optionally, the preprocessed image is input into the RT-DTTC deep learning network to complete the detection of drug surface defects, including: inputting the preprocessed image into the RT-DTTC deep learning network, the RT-DTTC deep learning network analyzes the input image, and for images in which defects are detected, the location of the drug defect in the image is framed, and the defect category and the corresponding confidence score are displayed, wherein the defect categories include cracks, stains, pits, deformation, edge drop, missing corners, and blur; for images in which no defects are detected, they are used as rftest categories, and the rftest indicates that further testing is required; according to the detected defect category and the rftest category, the image and the detection result are saved in a folder of the corresponding category, and timestamp information is added to the saved image file name.

[0012] Optionally, the method of extracting key parameters of a drug using image processing technology includes: using a Canny edge detection algorithm to extract a boundary contour of the drug in an image, applying morphological operations to the edge detection results to remove noise and repair incomplete edges; for round tablets, fitting a circular boundary contour using the Hough circle transform; for elliptical tablets, fitting an elliptical contour using the least squares method; calculating the diameter of the drug based on the fitted boundary contour, and comparing it with a standard range to determine whether the drug size is qualified; analyzing the fitted boundary contour with the actual edge of the drug to evaluate the integrity of the edge of the drug and detect whether the edge is concave or damaged, wherein the actual edge refers to the boundary contour extracted using the Canny edge detection algorithm.

[0013] Optionally, it is determined whether the deviation of the key parameter is within a preset tolerance range. If the deviation of the key parameter is within the preset tolerance range, the surface quality of the drug is considered to be qualified; if the deviation of the key parameter is not within the preset tolerance range, the surface quality of the drug is considered to be unqualified. The method also includes: sorting the test results based on timestamps and generating a test log, which is used to record the test results of each drug, including the test date, defect category, diameter size, and edge integrity of the drug.

[0014] According to one aspect of the present invention, there is also provided a vision-based solid pharmaceutical surface defect detection device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the vision-based solid pharmaceutical surface defect detection method as described above when executing the computer program.

[0015] According to another aspect of the present invention, a storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the vision-based solid pharmaceutical surface defect detection method as described above are implemented.

[0016] Through high-resolution industrial cameras and deep learning networks, the present invention can accurately identify defects on the surface of medicines (such as cracks, pits, stains, missing corners, etc.) and measure the diameter and edge integrity of medicines, thereby realizing real-time or near real-time detection of drug quality and significantly improving the detection speed. Compared with traditional manual detection methods, the method of the present invention is more efficient and greatly reduces the possibility of human error.

[0017] The present invention combines deep learning network detection and key parameter detection, wherein the deep learning network can identify complex patterns and subtle differences in images, while the key parameters detect the physical properties of the drugs. The surface quality of the drugs is considered qualified only when both tests are qualified. By combining the detection results of the two methods, the possibility of false alarms and missed alarms is reduced, and the accuracy of detection is improved.

[0018] The comprehensive automation characteristics and high-precision detection capabilities of the present invention not only improve the overall efficiency of the production line, but also provide an intelligent solution for drug quality management, which can help the pharmaceutical industry move towards a higher level of standardization and digitalization. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings: Figure 1 is a flow chart of a method for detecting surface defects of solid medicines based on vision in an embodiment of the present invention; Figure 2 is a schematic diagram of the detection layout; Figure 3 This is the RT-DTTC network structure diagram; Figure 4 This is the ablation experiment result diagram of RT-DETR-R18 model and RT-DTTC model; Figure 5 It is a graph of experimental results using different detection methods; Figure 6 This is the edge detection effect diagram. DETAILED DESCRIPTION

[0020] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only embodiments of a part of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work should fall within the scope of protection of the present application. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.

[0021] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.

[0022] The terms "comprises" and "having" and any variations thereof in the specification and claims of this application are intended to cover non-exclusive inclusions. For example, a process, method, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products or apparatuses.

[0023] Example 1: Reference Figure 1 , Figure 1 FIG. 1 is a flow chart of a method for detecting surface defects of solid medicines based on vision in an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps: S1, using an industrial camera to collect images of the drug surface, and adding a timestamp to each collected image, wherein the timestamp is used to add a time mark to the drug on the image according to the image collection time; The camera detection layout diagram is as follows Figure 2As shown in the figure, the high-precision industrial camera is fixedly installed just above the conveyor belt. The drugs are arranged in a single layer on the conveyor belt. A certain interval is maintained between two adjacent drugs for inspection. The layout of the drugs is regular and complete to avoid drug stacking or mutual obstruction. The camera shooting angle has been strictly calibrated, and the field of view covers a specific area of ​​the conveyor belt. Each time the image is acquired, only the complete drug and an appropriate amount of background area are captured to avoid the problem of drug edge cutting or half of the drug entering the field of view. When performing surface defect detection, the drug moves at a constant speed with the conveyor belt, and the industrial camera captures images at a fixed time interval synchronized with the conveyor belt speed and pushes them to the cloud. When each image is transmitted, accurate timestamp information is automatically added according to the image acquisition time (generally, surface defect detection will be performed after the image is acquired, so the image acquisition time in this step can also be understood as the drug detection time), which is used to add time tags to the drugs on the image, facilitating subsequent drug sorting and defect location.

[0024] S2, preprocessing the collected images to enhance the visibility of surface defects of the drugs; Receive the real-time image stream pushed from the cloud and transmit it to the local detection system for preprocessing. Preprocessing usually includes resizing, normalization, denoising, contrast enhancement, sharpening, etc.

[0025] In one embodiment, S2 includes: S21, size adjustment: The acquired image is adjusted to the input size (such as 640×640) required by the deep learning model through image scaling to ensure that the image meets the input requirements of the model.

[0026] S22, pixel value normalization: Perform standard normalization on the image pixel values ​​and scale the pixel values ​​to a specific range (such as 0 to 1) to enhance the model's adaptability to the image and improve detection performance. This can be achieved by dividing the pixel value by 255 or using the maximum and minimum normalization method.

[0027] S23, bilateral filtering: Use nonlinear bilateral filtering to filter out noise in the image. Bilateral filtering combines information in the spatial domain and the intensity domain, and can remove noise while maintaining image edge details such as cracks, pits, or printing boundaries, ensuring that key features are not blurred.

[0028] S24, Image Enhancement: The denoised image is enhanced in the spatial domain through contrast enhancement, sharpening and other operations to improve the contrast between different areas on the surface of the drug, making the distinction between defect features (such as cracks, stains, and edge loss) and normal areas more obvious, which facilitates the subsequent deep learning detection network to perform accurate identification.

[0029] S3, input the preprocessed image into the RT-DTTC deep learning network to complete the detection of drug surface defects; The preprocessed image is input into the RT-DTTC (Real-time Drug Tablet Transformer-based Checking) deep learning network. The RT-DTTC deep learning network identifies the target drug based on the input image, detects whether there are defects on the surface of the target drug, and outputs the corresponding defect category.

[0030] The RT-DTTC deep learning network in the embodiment of the present invention is an improved network based on RT-DETR, and the improvements include: 1. The RT-DTTC deep learning network introduces a bidirectional fusion mechanism between high-resolution and low-resolution features, which makes the information transmission between features more sufficient and further improves the effect of multi-scale feature fusion; 2. The RT-DTTC deep learning network adopts an adaptive attention mechanism to adaptively adjust the weights of features according to the different resolutions and contents of feature maps, so as to better capture the multi-scale features of the target.

[0031] 3. Selectively aggregate boundary information and semantic information to depict finer-grained object contours and recalibrate object positions, improve the ability to detect surface defects of pharmaceuticals, and perform identification and classification; 4. The RT-DTTC deep learning network adds a P2 layer to the network, which significantly improves the detection ability of small targets (such as fine cracks or stains); Figure 3 The improved RT-DTTC deep learning network model can accurately detect defects on the surface of drugs through feature extraction, multi-scale analysis and defect classification, and select the defect location in the image, and output the bounding box coordinates, defect category and confidence score of each defect.

[0032] The original RT-DETR-R18 model and the RT-DTTC model proposed in the embodiment of the present invention were used to conduct ablation experiments for comparison. The experimental results are shown in the figure. Figure 4 As shown, Figure 4mAP@.5 is the average precision calculated when the IoU (intersection over union) threshold is 0.5; mAP@.5:.95 is the average precision calculated under multiple thresholds of IoU thresholds from 0.5 to 0.95 (step size is 0.05); all refers to the "overall" or "all categories" indicator; Parameters(M) is the number of parameters of the model, in million (M, Mega); GFLOPs is the computational amount of the model, which means one billion floating-point operations performed in one inference process; weight_size is the size of the model weight file, usually in MB (megabytes); FPS is the inference speed of the model, which means how many frames can be processed per second; As can be seen from the figure, compared with the RT-DETR-R18 model, the RT-DTTC model proposed in the embodiment of the present invention has advantages in all indicators, verifying that the model improvement is effective.

[0033] In addition, it is understandable that before using the RT-DTTC deep learning network for drug surface defect detection, some necessary preliminary preparations are required, such as building the RT-DTTC deep learning network model, training and verifying the model, etc. Specifically, it includes: S01, collect basic images and create a database: Before real-time detection, surface images of drugs (such as tablets, capsules, etc.) are collected. The images are required to reflect the actual appearance characteristics of the drugs and have high contrast. The collected images must include the types of defects that may appear on the surface of the drugs (such as cracks, pits, stains, missing corners, etc.) for subsequent model training. The collected drug images are organized into a database to provide support for the training and testing of deep learning models.

[0034] S02, make a data set: Perform the following operations on the drug surface image data collected by the industrial camera: Image annotation: Manually or automatically annotate the collected drug images, identify the defect type and location (such as cracks, edge defects, etc.), and generate annotation files; Data enhancement: Use data enhancement techniques (such as rotation, scaling, noise addition, contrast adjustment, etc.) to process images, simulate shooting conditions in complex environments (such as lighting changes, drug rotation), expand the size of the data set, and improve the robustness of the model; Complete dataset creation: Merge original images with enhanced images to form a diverse and comprehensive dataset, providing diverse samples for model training.

[0035] S03, model verification and comparative experiments: The data set is loaded to train the model. After the model training is completed, an experimental comparison is performed to verify the effectiveness of the model in the present invention.

[0036] In the experiment, the model performance (such as detection accuracy, speed, etc.) before and after the improvement is tested and the results are recorded. The experimental results are as follows: Figure 5 As shown, the improved method in the present invention significantly improves the detection accuracy and efficiency (due to the obvious color contrast between the impurities and other defects in the collected images and the drugs, the RGB camera was selected for the experiment).

[0037] Through model training and verification, the verified model will be used for the detection of drug surface defects in the method of the present invention.

[0038] S4, if the RT-DTTC deep learning network detects defects on the surface of the drug, it directly outputs the defect category; Defect categories include cracks, stains, pits, deformation, edge loss, missing corners, blur, etc. The RT-DTTC deep learning network detects defective images and directly outputs the defect category of the drug in the image, and saves the detection results to the corresponding folder according to the defect category.

[0039] S5, if the RT-DTTC deep learning network does not detect defects on the surface of the drug, the key parameters of the drug are extracted using image processing technology; Among them, the key parameters include tablet diameter and edge profile, which are used for tablet size measurement and edge integrity analysis respectively.

[0040] Images where the RT-DTTC deep learning network does not detect defects will be output as rftest (require furthertest) categories and saved in the rftest folder for subsequent dimensional measurement and integrity analysis.

[0041] Among them, for the defect-free drug images saved in the rftest folder, continue to use image processing technology to extract the key parameters of the drugs for size measurement and integrity analysis, including: S51, edge detection: The Canny edge detection algorithm is used to extract the boundary contour of the drug in the image. The Canny algorithm is a classic edge detection algorithm that can accurately detect the edge information in the image. To ensure the continuity and accuracy of the contour, morphological operations (dilation and erosion) are applied to the edge detection results to remove noise and repair incomplete edges. Figure 6 As shown, Figure 6 This is the edge detection effect diagram.

[0042] S52, edge fitting: For round tablets, the Hough circle transform is used to fit the circular boundary contour; for elliptical tablets, the least squares method is used to fit the elliptical contour.

[0043] S53, Diameter and Integrity Assessment: The diameter of the drug is calculated based on the fitted boundary contour. For circular tablets, the diameter can be directly obtained from the fitted circular boundary; for elliptical tablets, the diameter includes the length of the major axis and the minor axis, which can also be directly obtained from the fitted elliptical boundary. The obtained diameter is compared with the standard diameter range to determine whether the drug diameter size is qualified.

[0044] The deviation between the fitted boundary contour and the actual edge of the drug is analyzed to evaluate the integrity of the drug edge. The actual edge can be replaced by the boundary contour extracted by the Canny edge detection algorithm. By comparing the deviation between the fitted contour and the actual edge, it is possible to detect whether there are incomplete edge conditions such as concave or damaged edges.

[0045] S6, judging whether the deviation of the key parameter is within the preset tolerance range. If the deviation of the key parameter is within the preset tolerance range, the surface quality of the drug is considered to be qualified; if the deviation of the key parameter is not within the preset tolerance range, the surface quality of the drug is considered to be unqualified.

[0046] A corresponding tolerance range is preset for each key parameter, and the deviation between the actual value of each key parameter and the preset standard value is calculated to determine whether the deviation is within the preset tolerance range. If the deviation is within the tolerance range, the drug surface quality is considered to be qualified. For example, the deviation between the actual value of the drug diameter and the standard value (or expected value) is calculated. If the diameter deviation is within the preset tolerance range, the drug diameter size is considered to be qualified; if the deviation between the edge line of the drug fitting and the standard edge line (such as the distance difference between the key points of the edge) is also within the preset tolerance range, the drug edge integrity is considered to be qualified. In addition, no defects on the drug surface have been detected by the RT-DTTC deep learning network, so the drug surface quality is considered to be qualified.

[0047] The embodiment of the present invention combines RT-DTTC deep learning network detection and key parameter detection. The surface quality of the drug is considered qualified only when both tests are qualified. Among them, the deep learning network can identify complex patterns and subtle differences in images, while the key parameters detect the physical properties of the drug. By combining the detection results of the two methods, the possibility of false alarms and missed alarms can be reduced, and the overall detection accuracy can be improved.

[0048] In addition, after step S6, the method further includes sorting the inspection results based on timestamps and generating an inspection log, wherein the inspection log is used to record the inspection results of each drug, including the inspection date, defect category, diameter size, and edge integrity of the drug.

[0049] All test results are sorted based on timestamps to generate a test log to ensure that the order of drug testing is consistent with the actual arrangement on the conveyor belt. The log records the test results of each drug, including but not limited to defect category, diameter size, edge integrity and other information. Based on the log information, combined with the timestamp and the motion parameters of the conveyor belt, the corresponding defective drugs on the conveyor belt can be accurately located, making it easier to remove unqualified products from the production line. The defect detection results are fed back to the production control system in real time for dynamic adjustment of production parameters.

[0050] The present invention uses a deep learning model to achieve accurate detection of drug surface defects, including cracks, pits, stains, missing corners and other defect types. The robustness of the model is improved by data enhancement technology to ensure the detection effect in different environments. At the same time, the post-processing step performs dimensional measurement and edge integrity assessment on defect-free drugs to further ensure the quality of the drugs. Finally, the position of defective drugs is accurately located by timestamps and conveyor belt motion parameters to facilitate subsequent processing. This method realizes real-time or near real-time detection of drug quality and significantly improves the detection speed. Compared with traditional manual detection methods, the detection method of the present invention is more efficient and greatly reduces the possibility of human error.

[0051] Embodiment 2: In this embodiment, a vision-based solid drug surface defect detection device is also provided, which is used to implement the above embodiments and preferred implementations, and the descriptions that have been made will not be repeated. The vision-based solid drug surface defect detection device includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of the vision-based solid drug surface defect detection method as described above when executing the computer program. The specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and this embodiment will not be repeated here.

[0052] An embodiment of the present invention further provides a storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.

[0053] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store computer programs.

[0054] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0055] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0056] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A method for detecting surface defects of solid medicines based on vision, characterized in that: include: Using an industrial camera to capture images of the drug surface, and adding a timestamp to each captured image, wherein the timestamp is used to add a time mark to the drug on the image according to the image capture time; Pre-process the acquired images to enhance the visibility of surface defects of drugs; Input the preprocessed image into the RT-DTTC deep learning network to complete the detection of drug surface defects, wherein the RT-DTTC deep learning network is used to identify the target drug based on the input image, detect whether there are defects on the surface of the target drug, and output the corresponding defect category; If the RT-DTTC deep learning network detects defects on the surface of the drug, it directly outputs the defect category; If the RT-DTTC deep learning network does not detect defects on the drug surface, it uses image processing technology to extract key parameters of the drug, where the key parameters include tablet diameter and edge contour, which are used for tablet size measurement and edge integrity analysis respectively; Determine whether the deviation of the key parameter is within the preset tolerance range. If the deviation of the key parameter is within the preset tolerance range, the surface quality of the drug is considered to be qualified; if the deviation of the key parameter is not within the preset tolerance range, the surface quality of the drug is considered to be unqualified.

2. The method for detecting surface defects of solid pharmaceutical products based on vision according to claim 1, characterized in that: The preprocessing of the collected images comprises: Resize the acquired images to the input size required by the deep learning model and normalize the image pixel values; Use nonlinear bilateral filtering method to filter out noise in the image; The denoised image is subjected to image enhancement processing based on the spatial domain to improve the contrast between different areas on the drug surface, so as to make the distinction between defect features and normal areas more obvious.

3. The method for detecting surface defects of solid pharmaceutical products based on vision according to claim 1, characterized in that: The RT-DTTC deep learning network is improved based on the RT-DETR network. The improvements include: The introduction of a bidirectional fusion mechanism between high-resolution and low-resolution features makes the information transfer between features more complete, further improving the effect of multi-scale feature fusion; Adopting an adaptive attention mechanism, the weight of features is adaptively adjusted according to the different resolutions and contents of feature maps, so as to better capture the multi-scale features of the target; Selectively aggregate boundary information and semantic information to depict object contours and recalibrate object positions; A P2 layer is added to the network structure to improve the network's ability to detect small targets.

4. The method for detecting surface defects of solid pharmaceutical products based on vision according to claim 1, characterized in that: The pre-processed image is input into the RT-DTTC deep learning network to complete the detection of drug surface defects, including: The preprocessed image is input into the RT-DTTC deep learning network, and the RT-DTTC deep learning network analyzes the input image. For images in which defects are detected, the location of the drug defect in the image is selected, and the defect category and the corresponding confidence score are displayed, wherein the defect category includes cracks, stains, pits, deformation, edge loss, missing corners, and blur; For images in which no defects are detected, they are classified as rftest categories, which indicates that further testing is required; According to the detected defect category and rftest category, the image and the test results are saved in the folder of the corresponding category, and the timestamp information is added to the saved image file name.

5. The method for detecting surface defects of solid pharmaceutical products based on vision according to claim 1, characterized in that: The key parameters of the drug extracted by using image processing technology include: Use the Canny edge detection algorithm to extract the boundary contour of the drug in the image, and apply morphological operations to the edge detection results to remove noise and repair incomplete edges; For round tablets, the Hough circle transform is used to fit the circular boundary contour; For elliptical tablets, the least square method was used to fit the elliptical contour; Calculate the diameter of the drug based on the fitted boundary contour and compare it with the standard range to determine whether the drug size is qualified; The fitted boundary contour and the actual edge of the drug are analyzed to evaluate the integrity of the drug edge and detect whether there are defects or damages on the edge, wherein the actual edge refers to the boundary contour extracted using the Canny edge detection algorithm.

6. The method for detecting surface defects of solid pharmaceutical products based on vision according to claim 1, characterized in that: Determine whether the deviation of the key parameter is within the preset tolerance range. If the deviation of the key parameter is within the preset tolerance range, the surface quality of the drug is considered to be qualified; If the deviation of the key parameter is not within the preset tolerance range, the surface quality of the drug is considered unqualified, and the method further includes: The test results are sorted based on timestamps to generate a test log, which is used to record the test results of each drug, including the test date, defect category, diameter size, and edge integrity of the drug.

7. A visual-based solid medicine surface defect detection device, comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the vision-based solid pharmaceutical surface defect detection method described in any one of claims 1 to 6 are implemented.

8. A storage medium, characterized in that: The storage medium stores a computer program, which, when executed by a processor, implements the steps of the vision-based solid pharmaceutical surface defect detection method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Medicine blister packaging defect detection system and method based on machine vision

    CN113560219A

  • Quality inspection method and system for soft capsule production, medium and computer equipment

    CN117011289A

  • Improved chip multi-defect detection method and system based on fusion of SwinIR and RT-DETR

    CN117934420A

  • Ceramic packaging substrate detection method and system based on visual detection and meta learning

    CN119091236A

  • Precise copper material surface defect identification method and system based on optical online detection

    CN119354971A