Vision-based Solid Drug Surface Defect Detection Method, Device and Storage Medium
Through the combination of high-resolution industrial cameras and RT-DTTC deep learning networks, the accuracy and comprehensiveness of drug surface defect detection are solved, real-time detection and efficient management of drug quality are achieved.
Patent Information
- Application Number
- CN202510431243.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-08
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2045-04-08
AI Technical Summary
There is a trade-off between accuracy and comprehensiveness of existing drug surface defect detection methods. Traditional manual detection is susceptible to subjective factors and is inefficient. Machine vision methods are difficult to comprehensively and accurately judge the appearance quality of drugs. Packaging seal detection is a destructive detection and is not suitable for mass production.
High-resolution industrial cameras are used to combine RT-DTTC deep learning network for drug surface defect detection, image preprocessing enhances defect visibility, use RT-DTTC network to identify defects and output categories, and combine image processing technology to extract key parameters such as tablet diameter and edge profile to determine whether they are within the tolerance range.
It realizes accurate identification and quality evaluation of surface defects of drugs, improves detection speed and accuracy, reduces false alarms and missed reports, supports real-time or near-real-time detection of drug quality, and improves production line efficiency and intelligent level of drug management.
Smart Images

Figure CN119941735B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image processing, and particularly relates to a vision-based method, device and storage medium for detecting surface defects of solid drugs. Background Art
[0002] Drug quality inspection is an important link to ensure the safety, effectiveness and stability of drugs. 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. Drug detection technology can not only optimize production efficiency, but also effectively control the flow of unqualified products into the market, avoiding potential harm to patients' health.
[0003] Drug surface inspection and packaging inspection are the core parts of drug quality management. Its main goal is to detect whether there are defects such as cracks, depressions, deformations, stains, etc. on the drug surface, and whether there are problems such as unsealing, damage or printing errors in the packaging. If these defects are not detected in time, it may not only affect the efficacy of the drug, but also lead to a decrease in product stability or pollution problems due to packaging failure, thereby affecting the safety of patients' medication.
[0004] Currently, the detection methods for drug quality are mainly divided into drug appearance detection methods and packaging sealing detection methods. Among them, the appearance detection method usually detects defects such as cracks, pits, stains and missing corners on the drug surface through traditional manual inspection or statistical machine vision means to evaluate the appearance quality of drugs. However, due to the complexity and subtlety of drug surface defects, traditional manual detection is easily affected by subjective factors, with low detection efficiency and accuracy, while statistical machine vision methods are difficult to comprehensively and accurately judge whether the drug appearance quality is qualified.
[0005] In contrast, the packaging sealing detection method mainly evaluates the protection and stability of drugs by detecting the sealing and integrity of drug packaging. For example, airtightness testing or image analysis technology is used to detect problems such as unsealing, damage and printing errors of packaging. Although this method is intuitive and reliable in evaluating packaging quality, it is usually a destructive test and cannot comprehensively detect all products, so it is only applicable to small batch sampling analysis. Nevertheless, packaging sealing detection can provide more accurate quality assessment and play an important role in the production process of high-risk drugs.
[0006] Generally speaking, there is a certain trade-off between the accuracy and comprehensiveness of existing drug detection methods. There is an urgent need to develop an efficient, non-destructive and comprehensively applicable detection technology to meet the high standards of quality control in large-scale drug production. Summary of the Invention
[0007] To solve the above technical problems of low efficiency and accuracy in the detection of drug surface defects, the present invention provides a vision-based method, device, and storage medium for detecting solid drug surface defects.
[0008] According to one aspect of the present invention, there is provided a vision-based method for detecting solid drug surface defects, including: using an industrial camera to collect drug surface images and adding a timestamp to each collected image, where the timestamp is used to add a time mark to the drug in the image according to the image acquisition time; preprocessing the collected images to enhance the visibility of drug surface defects; inputting the preprocessed images into the RT-DTTC deep learning network to complete the detection of drug surface defects, where the RT-DTTC deep learning network is used to identify the target drug according to the input image, detect whether there are defects on the surface of the target drug, and output the corresponding defect categories; if the RT-DTTC deep learning network detects that there are defects on the drug surface, directly output the defect categories; if the RT-DTTC deep learning network does not detect that there are defects on the drug surface, use image processing technology to extract the key parameters of the drug, where the key parameters include the tablet diameter and the edge contour, which are used for tablet size measurement and edge integrity analysis respectively; determine whether the deviation of the key parameters is within the preset tolerance range, if the deviation of the key parameters is within the preset tolerance range, it is considered that the drug surface quality is qualified; if the deviation of the key parameters is not within the preset tolerance range, it is considered that the drug surface quality is unqualified.
[0009] Optionally, the preprocessing of the collected images includes: adjusting the collected images to the input size required by the deep learning model and normalizing the image pixel values; using a non-linear bilateral filtering method to filter out the noise in the images; performing image enhancement processing based on the spatial domain on the denoised images to improve the contrast between different regions on the drug surface, so that the distinction between defect features and normal regions is more obvious.
[0010] Optionally, the RT-DTTC deep learning network is improved based on the RT-DETR network, and the improvement points include: introducing a two-way fusion mechanism between high-resolution and low-resolution features to make the information transfer between features more sufficient and further improve 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 the feature maps, so as to better capture the multi-scale features of the target; selectively aggregating boundary information and semantic information to depict the object contour and recalibrate the position of the object; adding a P2 layer to the network structure to improve the network's detection ability for small targets.
[0011] Optionally, inputting the preprocessed image into the RT-DTTC deep learning network to complete the detection of drug surface defects includes: inputting the preprocessed image into the RT-DTTC deep learning network, and the RT-DTTC deep learning network analyzes the input image. For the image in which defects are detected, the positions of drug defects in the image are framed, and the defect categories and corresponding confidence scores are displayed, where the defect categories include cracks, stains, pits, deformations, edge breaks, corner chips, and blurs; for the image in which no defects are detected, it is classified as the rftest category, and the rftest indicates that further testing is required; according to the detected defect categories and the rftest category, the image and the detection results are saved to the folders corresponding to the categories, and timestamp information is added to the saved image file names.
[0012] Optionally, using image processing technology to extract the key parameters of the drug includes: using the Canny edge detection algorithm to extract the boundary contour of the drug in the image, and applying morphological operations to the edge detection results to remove noise and repair incomplete edges; for circular tablets, using the Hough circle transform to fit the circular boundary contour; for oval tablets, using the least squares method to fit the oval contour; calculating the diameter of the drug according to the fitted boundary contour and comparing it with the standard range to determine whether the drug size is qualified; analyzing the fitted boundary contour and the actual edge of the drug to evaluate the integrity of the drug edge and detect whether there are concave defects or breakages at the edge, where the actual edge refers to the boundary contour extracted using the Canny edge detection algorithm.
[0013] Optionally, determine whether the deviation of the key parameters is within the preset tolerance range. If the deviation of the key parameters is within the preset tolerance range, it is considered that the surface quality of the drug is qualified; if the deviation of the key parameters is not within the preset tolerance range, it is considered that the surface quality of the drug is unqualified. After that, the method further includes: sorting the detection results based on the timestamp to generate a detection log, and the detection log is used to record the detection results of each drug, including the detection 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 drug surface defect detection device, including a memory and a processor, where the memory stores a computer program, and when the processor executes the computer program, the steps of the above-mentioned vision-based solid drug surface defect detection method are implemented.
[0015] According to another aspect of the present invention, there is also provided a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned vision-based solid drug surface defect detection method are implemented.
[0016] Through a high-resolution industrial camera and a deep learning network, the present invention can accurately identify defects on the surface of drugs (such as cracks, pits, stains, missing corners, etc.), and measure the diameter and edge integrity of drugs, realizing real-time or near-real-time detection of drug quality, 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 errors.
[0017] The present invention combines deep learning network detection and key parameter detection. Among them, the deep learning network can identify complex patterns and subtle differences in images, while the key parameters detect the physical properties of drugs. The surface quality of drugs is considered qualified only when both detections are qualified. By integrating the detection results of the two methods, the possibility of false alarms and missed detections is reduced, and the detection accuracy is improved.
[0018] The fully automated features 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 higher standardization and digitalization levels. 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 schematic 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:
[0020] Figure 1 is a flowchart of a vision-based method for detecting surface defects of solid drugs in an embodiment of the present invention;
[0021] Figure 2 is a schematic diagram of the detection layout;
[0022] Figure 3 is a network structure diagram of RT-DTTC;
[0023] Figure 4 is a graph of ablation experiment results of RT-DETR-R18 model and RT-DTTC model;
[0024] Figure 5 is a graph of experimental results using different detection methods;
[0025] Figure 6 is an edge detection effect diagram. DETAILED DESCRIPTION OF THE INVENTION
[0026] To enable those skilled in the art to better understand the solution of this application, the following will clearly and completely describe the technical solutions in the embodiments of this application with reference to the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of this application. It should be noted that, without conflict, the embodiments in this application and the features in the embodiments may be combined with each other.
[0027] Secondly, the so-called "one embodiment" or "embodiment" herein refers to a specific feature, structure or characteristic that may be included in at least one implementation manner of the present invention. The "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that excludes other embodiments.
[0028] The terms "comprising" and "having" and any variations thereof in the specification and claims of this application are intended to cover non-exclusive inclusion. For example, a process, method, product or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0029] Example 1: Refer to Figure 1 , Figure 1 is a flowchart of a vision-based surface defect detection method for solid drugs in the embodiments of the present invention. As Figure 1 shown, the method includes the following steps:
[0030] S1, Use an industrial camera to collect the surface image of the drug and add a timestamp to each collected image. The timestamp is used to add a time mark to the drug on the image according to the image acquisition time;
[0031] The schematic diagram of the camera detection layout is as Figure 2As shown, the high-precision industrial camera is fixedly installed directly above the conveyor belt. The drugs are arranged in a single layer on the conveyor belt, with a certain interval maintained between adjacent drugs being inspected. The layout of the drugs is regular and complete, avoiding drug stacking or mutual occlusion. The camera shooting angle is strictly calibrated, and the field of view covers a specific area of the conveyor belt. Each time an image is collected, only the complete drugs and an appropriate amount of background area are captured, avoiding problems such as drug edge cutting or half a drug entering the field of view. When performing surface defect detection, the drugs move at a constant speed along with the conveyor belt, and the industrial camera collects images at fixed time intervals synchronized with the conveyor belt speed and pushes them to the cloud. Each image is automatically appended with accurate timestamp information according to the image collection time (generally, surface defect detection is performed immediately after image collection, so the image collection time in this step can also be understood as the drug detection time) when being transmitted, which is used to add a time mark to the drugs in the image, facilitating subsequent drug sorting and defect positioning.
[0032] S2. Preprocess the collected images to enhance the visibility of surface defects of the drugs;
[0033] Receive the real-time image stream pushed from the cloud and transmit it to the local detection system for preprocessing. The preprocessing usually includes operations such as size adjustment, normalization, denoising, contrast enhancement, and sharpening.
[0034] In one implementation, S2 includes:
[0035] S21. Size adjustment:
[0036] Adjust the collected images to the input size required by the deep learning model (such as 640×640) through image scaling operations to ensure that the images meet the input requirements of the model.
[0037] S22. Pixel value normalization:
[0038] Perform standard normalization processing on the image pixel values, scaling the pixel values to a specific range (such as 0 to 1) to enhance the model's adaptability to the images and improve the detection performance. This can be achieved by dividing the pixel values by 255 or using the maximum-minimum normalization method.
[0039] S23. Bilateral filtering:
[0040] Use a non-linear bilateral filtering method to filter out the noise in the images. Bilateral filtering combines the information in the spatial domain and the intensity domain, and can keep the edge details of the images, such as cracks, pits, or printing boundaries, while removing the noise, ensuring that the key features are not blurred.
[0041] S24. Image enhancement:
[0042] Perform spatial domain-based image enhancement processing on the denoised image through operations such as contrast enhancement and sharpening to improve the contrast between different regions on the drug surface, making the distinction between defect features (such as cracks, stains, edge chips, etc.) and normal regions more obvious, facilitating accurate identification by the subsequent deep learning detection network.
[0043] S3, Input the preprocessed image into the RT-DTTC deep learning network to complete the detection of drug surface defects;
[0044] 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 categories.
[0045] The RT-DTTC deep learning network in the embodiments of the present invention is a network improved based on RT-DETR. The improvement points include:
[0046] 1. The RT-DTTC deep learning network introduces a two-way fusion mechanism between high-resolution and low-resolution features, making the information transfer between features more sufficient and further improving the effect of multi-scale feature fusion;
[0047] 2. The RT-DTTC deep learning network adopts an adaptive attention mechanism, adaptively adjusts the weights of features according to the different resolutions and contents of the feature maps, so as to better capture the multi-scale features of the target.
[0048] 3. Selectively aggregate boundary information and semantic information to depict finer-grained object contours and recalibrate the positions of objects, improving the detection ability of drug surface defects for identification and classification;
[0049] 4. The RT-DTTC deep learning network adds a P2 layer in the network, significantly improving the detection ability for small targets (such as fine cracks or stains);
[0050] Figure 3 This is the structure diagram of the RT-DTTC network. The improved RT-DTTC deep learning network model can accurately detect the defects existing on the drug surface through feature extraction, multi-scale analysis and defect classification, frame the defect positions in the image, and output the bounding box coordinates, defect categories and confidence scores of each defect.
[0051] Conduct ablation experiments and comparisons using the original RT-DETR-R18 model and the RT-DTTC model proposed in the embodiments of the present invention. The experimental results are asFigure 4 As shown Figure 4 Among them, mAP@.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 where the IoU threshold ranges from 0.5 to 0.95 (with a step size of 0.05); all refers to the metric of "overall" or "all classes"; Parameters(M) is the number of parameters of the model, with the unit of million (M, Mega); GFLOPs is the computational volume of the model, indicating the number of billions of 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, indicating how many frames can be processed per second; It can be seen from the figure that compared with the RT-DETR-R18 model, the RT-DTTC model proposed in the embodiment of the present invention has advantages in various indicators, verifying that the model improvement is effective.
[0052] In addition, it can be understood that before using the RT-DTTC deep learning network for drug surface defect detection, some necessary preliminary preparations are also included, such as constructing the RT-DTTC deep learning network model, training and validating the model, etc. Specifically, it includes:
[0053] S01, Collect basic images and create a database:
[0054] Before real-time detection, collect surface images of drugs (such as tablets, capsules, etc.), requiring the images to reflect the actual appearance characteristics of the drugs and have high contrast. The collected images should include the types of defects that may appear on the drug surface (such as cracks, pits, stains, missing corners, etc.) for subsequent model training. Organize the collected drug images into a database to support the training and testing of the deep learning model.
[0055] S02, Create a dataset:
[0056] Perform the following operations on the drug surface image data collected by the industrial camera:
[0057] Image annotation: Manually or automatically annotate the collected drug images to identify the types and locations of defects (such as cracks, edge defects, etc.) and generate annotation files;
[0058] Data augmentation: Use data augmentation techniques (such as rotation, scaling, noise addition, contrast adjustment, etc.) to process the images, simulate the shooting situations under complex environments (such as light changes, drug rotation), expand the scale of the dataset, and improve the robustness of the model;
[0059] Complete dataset creation: Combine the original images and the augmented images to form a diverse and comprehensive dataset to provide diverse samples for model training.
[0060] S03, Model Verification and Comparative Experiments:
[0061] Load the dataset to train the model. After the model training is completed, conduct experimental comparisons to verify the effectiveness of the model in the present invention.
[0062] In the experiment, test the performance of the model before and after improvement (such as detection accuracy, speed, etc.) and record the results. The experimental results are as Figure 5 shown. The improved method in the present invention significantly improves the detection accuracy and efficiency (since there is an obvious color contrast between impurities and other defects and the medicine in the collected images, an RGB camera is selected for the experiment).
[0063] 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.
[0064] S4, If the RT-DTTC deep learning network detects defects on the drug surface, directly output the defect category;
[0065] The defect categories include cracks, stains, pits, deformations, edge breakage, corner breakage, blurring, etc. For the images with defects detected by the RT-DTTC deep learning network, directly output the defect category of the drug in the image and save the detection results to the corresponding folder according to the defect category.
[0066] S5, If the RT-DTTC deep learning network does not detect defects on the drug surface, use image processing technology to extract the key parameters of the drug;
[0067] Among them, the key parameters include the tablet diameter and the edge contour, which are used for tablet size measurement and edge integrity analysis respectively.
[0068] The images without defects detected by the RT-DTTC deep learning network will be output as the rftest (require further test) category and saved to the rftest folder for subsequent size measurement and integrity analysis.
[0069] 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 drug for size measurement and integrity analysis, including:
[0070] S51, Edge Detection:
[0071] Use the Canny edge detection algorithm to extract the boundary contour of the medicine 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. As Figure 6 shown, Figure 6 Figure 4 shows the effect diagram of edge detection.
[0072] S52, Edge fitting:
[0073] For circular tablets, use the Hough circle transform to fit the circular boundary contour; for oval tablets, use the least squares method to fit the oval contour.
[0074] S53, Diameter and integrity evaluation:
[0075] Calculate the diameter of the medicine according to the fitted boundary contour. Among them, for circular tablets, the diameter can be directly obtained from the fitted circular boundary; for oval tablets, the diameter includes the major axis and minor axis lengths, which can also be directly obtained from the fitted oval boundary. Compare the obtained diameter with the standard diameter range to judge whether the diameter size of the medicine is qualified.
[0076] Analyze the deviation between the fitted boundary contour and the actual edge of the medicine to evaluate the integrity of the medicine 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 can be detected whether there are incomplete edges such as concavities or damages.
[0077] S6, 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, it is considered that the surface quality of the medicine is qualified; if the deviation of the key parameter is not within the preset tolerance range, it is considered that the surface quality of the medicine is unqualified.
[0078] Preset the corresponding tolerance range for each key parameter, calculate the deviation between the actual value and the preset standard value of each key parameter, and judge whether the deviation is within the preset tolerance range. If the deviation is within the tolerance range, it is considered that the surface quality of the medicine is qualified. For example, calculate the deviation between the actual value and the standard value (or expected value) of the medicine diameter. If the diameter deviation is within the preset tolerance range, it is considered that the diameter size of the medicine is qualified; if the deviation between the fitted edge line of the medicine and the standard edge line (such as the distance difference of each key point on the edge) is also within the preset tolerance range, it is considered that the edge integrity of the medicine is qualified. Coupled with the fact that no defects have been detected on the medicine surface through the RT-DTTC deep learning network before, it is considered that the surface quality of the medicine is qualified.
[0079] In the embodiments of the present invention, the detection is combined with an RT-DTTC deep learning network and key parameter detection. The surface quality of the drug is considered qualified only when both detections are qualified. Among them, the deep learning network can identify complex patterns and subtle differences in the image, while the key parameters detect the physical characteristics of the drug. By integrating the detection results of the two methods, the possibility of false positives and false negatives can be reduced, and the accuracy of the overall detection can be improved.
[0080] In addition, after step S6, the method further includes sorting the detection results based on timestamps to generate a detection log, which is used to record the detection results of each drug, including the detection date, defect category, diameter size, and edge integrity of the drug.
[0081] All detection results are sorted based on timestamps to generate a detection log, ensuring that the detection order of the drugs is consistent with the actual arrangement on the conveyor belt. The log records the detection results of each drug, including but not limited to information such as defect category, diameter size, and edge integrity. According to the log information, combined with the timestamp and the motion parameters of the conveyor belt, the defective drug corresponding to the conveyor belt can be accurately located, facilitating the rejection of unqualified products in the production line. The defect detection results are fed back to the production control system in real time for dynamically adjusting production parameters.
[0082] The present invention realizes the accurate detection of drug surface defects through a deep learning model, including defect types such as cracks, pits, stains, and missing corners. The robustness of the model is improved through data augmentation technology, ensuring the detection effect in different environments. At the same time, the post-processing step measures the size and evaluates the edge integrity of the drug without defects, further ensuring the quality of the drug. Finally, the position of the defective drug is accurately located through the timestamp and the motion parameters of the conveyor belt, facilitating subsequent processing. This method realizes the real-time or near-real-time detection of drug quality, significantly improves the detection speed, and is more efficient than the traditional manual detection method. The detection method of the present invention greatly reduces the possibility of human errors.
[0083] Embodiment 2: In this embodiment, a vision-based solid drug surface defect detection device is further provided to implement the above embodiments and preferred embodiments. Those that have been described 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 when the processor executes the computer program, the steps of the vision-based solid drug surface defect detection method described above are implemented. Specific examples in this embodiment can refer to the examples described in the above embodiments and optional embodiments, and will not be repeated here.
[0084] 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 in any one of the above method embodiments when running.
[0085] Optionally, in this embodiment, the above storage medium may include but is not limited to: various media such as USB flash drives, read-only memories (ROM for short), random access memories (RAM for short), mobile hard disks, magnetic disks, or optical discs that can store computer programs.
[0086] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages and disadvantages of the embodiments.
[0087] In the above embodiments of the present invention, the descriptions of each embodiment have their own focuses. For the parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
[0088] The above is only the preferred embodiment of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.
Claims
1. A vision-based method for detecting surface defects of solid drugs, characterized in that, Including: Using an industrial camera to collect images of the drug surface and adding a timestamp to each collected image, where the timestamp is used to add a time mark to the drug on the image according to the image acquisition time; Preprocessing the collected images to enhance the visibility of drug surface defects; Inputting the preprocessed images into the RT-DTTC deep learning network to complete the detection of drug surface defects. Among them, the RT-DTTC deep learning network is used to identify the target drug according to the input image, detect whether there are defects on the surface of the target drug, and output the corresponding defect categories; If the RT-DTTC deep learning network detects that there are defects on the drug surface, directly output the defect category; If the RT-DTTC deep learning network does not detect that there are defects on the drug surface, use image processing technology to extract the key parameters of the drug. Among them, the key parameters include the tablet diameter and the edge contour, which are used for tablet size measurement and edge integrity analysis respectively; Judge whether the deviation of the key parameters is within the preset tolerance range. If the deviation of the key parameters is within the preset tolerance range, it is considered that the drug surface quality is qualified; if the deviation of the key parameters is not within the preset tolerance range, it is considered that the drug surface quality is unqualified; The RT-DTTC deep learning network is improved based on the RT-DETR network. The improvement points include: Introducing a two-way fusion mechanism between high-resolution and low-resolution features, making the information transfer between features more sufficient and 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 the feature maps, so as to better capture the multi-scale features of the target; Selectively aggregating boundary information and semantic information to depict the object contour and recalibrate the object position; Adding a P2 layer to the network structure to improve the network's detection ability for small targets; The step of inputting the preprocessed images into the RT-DTTC deep learning network to complete the detection of drug surface defects includes: Inputting the preprocessed images into the RT-DTTC deep learning network. The RT-DTTC deep learning network analyzes the input images. For the images in which defects are detected, the positions of the drug defects in the images are framed, and the defect category and the corresponding confidence score are displayed. Among them, the defect categories include cracks, stains, pits, deformations, chipping, corner missing, and blurring; For the images in which no defects are detected, they are classified as the rftest category, where rftest means further testing is required; According to the detected defect categories and the rftest category, save the images and the detection results into folders corresponding to the categories, and add timestamp information to the saved image file names.
2. The method for detecting surface defects of solid drugs based on vision according to claim 1, wherein The preprocessing of the collected images includes: Adjusting the collected images to the input size required by the deep learning model and normalizing the image pixel values; Using a non-linear bilateral filtering method to filter out the noise in the images; Perform image enhancement processing based on the spatial domain on the denoised image to improve the contrast between different regions on the drug surface, making the distinction between defect features and normal regions more obvious.
3. The visual-based surface defect detection method for solid drugs according to claim 1, wherein The key parameters of the drug extracted by using the 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 result to remove noise and repair incomplete edges; For round tablets, use the Hough circle transform to fit the circular boundary contour; For oval tablets, use the least squares method to fit the oval contour; Calculate the diameter of the drug according to the fitted boundary contour, and compare it with the standard range to determine whether the drug size is qualified; Analyze the fitted boundary contour and the actual edge of the drug to evaluate the integrity of the drug edge and detect whether there are concave defects or breakages on the edge. Among them, the actual edge refers to the boundary contour extracted by using the Canny edge detection algorithm.
4. The method for detecting surface defects of solid drugs based on vision according to claim 1, wherein, Judge whether the deviation of the key parameters is within the preset tolerance range. If the deviation of the key parameters is within the preset tolerance range, it is considered that the surface quality of the drug is qualified; If the deviation of the key parameters is not within the preset tolerance range, it is considered that the surface quality of the drug is unqualified. After that, the method further includes: Sort the detection results based on the time stamp to generate a detection log, which is used to record the detection results of each drug, including the detection date, defect category, diameter size, and edge integrity of the drug.
5. A vision-based surface defect detection device for solid drugs, including a memory and a processor, where the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the vision-based solid drug surface defect detection method according to any one of claims 1 to 4.
6. A storage medium, characterized in that, The computer program is stored on the storage medium, and when the computer program is executed by the processor, it implements the steps of the vision-based solid drug surface defect detection method according to any one of claims 1 to 4.
Citation Information
Patent Citations
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