Medicine logistics management device and method based on machine vision
By using multi-angle cameras to collect image data in drug logistics management, combining image preprocessing and multi-scale feature recognition technology, efficient identification and classification judgment of drug packaging defects is achieved, and correction or reconstruction suggestions are provided, which solves the problems of incomplete defect identification and inaccurate classification judgment in the existing technology, and improves the safety and quality traceability in the drug logistics process.
Patent Information
- Application Number
- CN202411737892.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-03-21
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing machine vision detection technology is difficult to fully cover all parts of drug packaging, it is easy to ignore defects such as small cracks or slight label blur, and lacks a standardized defect classification and judgment mechanism, resulting in misjudgment and misjudgment.
Using machine vision-based drug logistics management devices and methods, image data is collected through cameras from multiple angles, image preprocessing and multi-scale feature recognition, packaging defects are identified and positioned, integrity judgment is made, and correction or reconstruction suggestions are provided.
It has achieved comprehensive inspection of drug packaging, can efficiently identify small defects, accurately classify and judge the type, quantity and severity of defects, provide targeted correction or reconstruction plans, reduce the demand for manual testing, and improve the safety and quality traceability of drug logistics.
Smart Images

Figure CN119671981A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of drug logistics management, and in particular to a drug logistics management device and method based on machine vision. Background Art
[0002] In modern pharmaceutical logistics, the quality of drug packaging is directly related to the safety and effectiveness of drugs. Especially during transportation and storage, packaging must not only protect drugs from contamination and damage, but also keep packaging labels clear and legible to ensure the traceability of drug batch, expiration date and other information. With the improvement of the pharmaceutical industry's requirements for packaging quality, traditional manual inspection can no longer meet the needs of large-scale logistics for efficient and accurate packaging inspection. Machine vision technology has gradually been introduced to automatically detect the integrity and defects of drug packaging and improve the efficiency of quality management.
[0003] However, the existing machine vision inspection technology has some shortcomings. First, the traditional method can usually only collect images based on a single angle, which can easily lead to detection blind spots and make it difficult to fully cover all parts of the packaging. In particular, defects such as small cracks or slight label blur may be ignored. Secondly, there is a lack of a standardized judgment mechanism for defect classification, and it is impossible to accurately distinguish between minor defects and serious defects, resulting in misjudgments and missed judgments. In addition, the existing technology lacks intelligent decision-making capabilities. For packaging judged to be defective, it fails to provide effective correction or reconstruction suggestions, and cannot meet the packaging quality management requirements in the logistics process.
[0004] The purpose of the present invention is to provide a drug logistics management device and method based on machine vision, which can not only efficiently identify small defects on the packaging, such as damage, contamination and blurred labels, but also classify and judge the type, quantity and severity of defects to ensure accurate assessment of the packaging status, and provide correction or reconstruction solutions for defects of different degrees, thereby reducing the demand for manual inspection, optimizing resource utilization, and ultimately improving the safety and quality traceability of drugs in the logistics process. Summary of the invention
[0005] The present invention provides a drug logistics management device and method based on machine vision.
[0006] The drug logistics management method based on machine vision includes the following steps:
[0007] S1, drug packaging image acquisition: using a camera to collect image data of drug packaging from multiple angles;
[0008] S2, image preprocessing: preprocessing the collected image data of drug packaging, including image denoising, image enhancement and size normalization;
[0009] S3, packaging integrity analysis: Defect recognition is performed on the preprocessed image data through the packaging defect recognition model, and the integrity of the packaging is judged based on the defect recognition results, including:
[0010] S31, packaging defect recognition: The pre-processed drug packaging image data is analyzed through the packaging defect recognition model to automatically detect packaging defects in the image data, including damage, wrinkles, dirt, and blurred labels;
[0011] S32, defect area positioning and marking: positioning and marking the identified defect area of the drug packaging, generating location information, and marking defect information, including defect size and shape;
[0012] S33, packaging integrity judgment: Based on the results of defect identification, a comprehensive judgment is made on the integrity of the drug packaging to determine whether the packaging is intact, usable, or needs to be repackaged;
[0013] S4, Defect correction and packaging reconstruction suggestions: Provide corresponding packaging correction or reconstruction suggestions based on the results of the packaging integrity analysis.
[0014] Optionally, the drug packaging image acquisition in S1 includes:
[0015] S11, setting camera position and angle: according to the shape and size of the drug packaging, multiple cameras are set, and the camera shooting angles are planned, including the front, side, back and oblique angles;
[0016] S12, camera synchronous trigger shooting: through the synchronous trigger mechanism, ensure that each camera shoots at the same time at the same time point, so as to obtain image data with consistent timestamp;
[0017] S13, ensure image quality and consistency: calibrate and test the cameras to ensure that the image resolution, color reproduction and lighting adaptability of each camera meet consistent standards.
[0018] Optionally, the image preprocessing in S2 includes:
[0019] S21, image denoising: use Gaussian filtering algorithm to denoise the collected image data to reduce random noise in the image and make the image clearer;
[0020] S22, image enhancement processing: using a histogram equalization algorithm to enhance the image data;
[0021] S23, size normalization processing: normalize the size of the image data to make the sizes of all images consistent. The goal of normalization is to adjust the sizes of all image data to a unified standard size W×H.
[0022] Optionally, the packaging defect recognition model in S31 adopts a convolutional neural network (CNN) model, and the convolutional neural network (CNN) model includes:
[0023] S311, Multi-scale convolution kernel application: Use convolution kernels of different sizes (3×3, 5×5, 7×7) for multi-scale feature extraction to detect packaging defects of various sizes;
[0024] S312, activation function application: Use Leaky ReLU activation function to enhance the recognition of subtle packaging defects;
[0025] S313, Attention Mechanism for Feature Enhancement: Introducing an attention mechanism to automatically highlight defect areas in the output feature map of each convolutional layer and ignore irrelevant background information;
[0026] S314, multi-layer pooling layer: uses multi-layer pooling operations, including a combination of maximum pooling and average pooling, to retain global and local information of image data;
[0027] S315, Adaptive loss function: Use an adaptive weighted loss function.
[0028] Optionally, the defect area positioning and marking in S32 includes:
[0029] S321, defect area positioning: based on the packaging defects in the detected image data, a bounding box containing the defect area is generated through a target detection algorithm, and the location (such as coordinates) and area range of the defect are marked;
[0030] S322, defect information labeling: Analyze the located defect area and extract defect information, including the size (area) and shape characteristics (linear, dot or irregular shape) of the defect.
[0031] Optionally, the defect area positioning in S321 includes:
[0032] S321, generation of bounding box: based on the packaging defects in the identified image data, a candidate box is generated in the area containing the defect, and a bounding box is generated to frame the defect area. The position of the bounding box is determined by the center coordinate (x c ,y c ) and width and height (w,h);
[0033] S322, loss function optimization: Use a target detection algorithm to optimize the accuracy of bounding box positioning. The target detection algorithm adopts the total loss function of YOLO, including coordinate loss, width and height loss, and category loss.
[0034] Optionally, the defect information annotation in S322 includes:
[0035] S3221, defect size calculation: the defect size is estimated by calculating the area of the bounding box to estimate the defect area A;
[0036] S3222, defect shape feature extraction: Use image morphology method to process the defect area and analyze the shape features of the defects, including linear, point or irregular shapes.
[0037] Optionally, the packaging integrity determination in S33 includes:
[0038] S331, Packaging is intact: If there is no damage, contamination or unclear label defects in the test results, the packaging is considered intact;
[0039] S332, packaging is usable: if there are fine scratches or creases on the surface not exceeding 1 mm, if the non-critical information on the label is partially blurred but the drug name, batch number, and expiration date are clear, if there are traces of dust in a local area (not exceeding 1 square centimeter), and if there are slight indentations on the edge not exceeding 0.5 mm, the packaging is considered usable;
[0040] S333, repackaging is required: If surface damage or cracks are detected, label information is severely blurred so that the drug name, batch number, and expiration date information cannot be identified, there is large-scale contamination exceeding 1 square centimeter or contamination spreads to the sealing area, or corner indentations or damage exceeds 1 mm, then it is judged that repackaging is required.
[0041] Optionally, the defect correction and packaging rebuild suggestions in S4 include:
[0042] S41, Packaging Correction Suggestions: For packaging that is determined to be usable, provide corresponding correction solutions based on the type and degree of defects, including cleaning, label reinforcement or edge sealing to improve the packaging appearance and protective performance;
[0043] S42, Packaging reconstruction recommendations: For packaging determined to require repackaging, a repackaging plan is recommended, including replacing damaged packaging materials, relabeling, or replacing contaminated packaging.
[0044] The drug logistics management device based on machine vision is used to implement the above-mentioned drug logistics management method based on machine vision, and includes the following modules:
[0045] Drug packaging image acquisition module: uses a camera to collect image data of drug packaging from multiple angles;
[0046] Image preprocessing module: preprocess the collected image data, including image denoising, image enhancement and size normalization;
[0047] Packaging integrity analysis module: The packaging defect recognition model is used to identify defects in the preprocessed image data, and the integrity of the packaging is determined based on the defect recognition results;
[0048] Defect correction and packaging reconstruction suggestion module: provides corresponding packaging correction or reconstruction suggestions based on the results of packaging integrity analysis.
[0049] Beneficial effects of the present invention:
[0050] The present invention realizes comprehensive inspection of drug packaging through multi-angle image acquisition, image preprocessing and multi-scale feature recognition model of the camera, can efficiently capture and analyze various subtle defects, ensure the accuracy and completeness of the inspection results, and optimize the recognition effect of packaging defects through image coverage and consistency control at different angles, effectively improving the automation level of packaging inspection and reducing the need for manual intervention.
[0051] The present invention, through clear packaging integrity judgment and defect classification standards, the system can classify the packaging status into three categories: intact, usable, and needing repackaging according to detailed indicators such as scratches, blurred labels, and contaminated areas. This classification method not only ensures accurate judgment of the packaging status, but also reduces unnecessary repackaging costs, ensuring that packaging with minor defects can still be used safely, helping to optimize resource utilization, and at the same time improving the efficiency and accuracy of drug logistics management.
[0052] The present invention, through the design of defect correction and packaging reconstruction suggestions, enables the system to provide targeted correction or reconstruction plans based on the results of packaging integrity analysis, extend the service life of the packaging through measures such as cleaning, label reinforcement and edge sealing, and provide timely repackaging suggestions in the case of serious defects to ensure the safety and quality of drugs during circulation. This method further improves the accuracy and flexibility of packaging quality control in the logistics process, and provides solid support for quality assurance in drug transportation and storage. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only for the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0054] Figure 1 A schematic diagram of a management method flow chart of an embodiment of the present invention;
[0055] Figure 2 Schematic diagram of device function modules according to an embodiment of the present invention. DETAILED DESCRIPTION
[0056] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. At the same time, it is explained here that in order to make the embodiments more detailed, the following embodiments are the best and preferred embodiments, and those skilled in the art may also adopt other alternatives to implement some known technologies; and the accompanying drawings are only for more specific description of the embodiments, and are not intended to specifically limit the present invention.
[0057] It should be noted that the references to "one embodiment", "an embodiment", "an exemplary embodiment", "some embodiments" and the like in the specification indicate that the embodiments described may include specific features, structures or characteristics, but not every embodiment may include the specific features, structures or characteristics. In addition, when a specific feature, structure or characteristic is described in conjunction with an embodiment, it should be within the knowledge of a person skilled in the art to implement such feature, structure or characteristic in conjunction with other embodiments (whether or not explicitly described).
[0058] In general, a term can be understood, at least in part, from its use in context. For example, depending, at least in part, on the context, the term "one or more" as used herein can be used to describe any feature, structure, or characteristic in the singular sense, or can be used to describe a combination of features, structures, or characteristics in the plural sense. Additionally, the term "based on" can be understood as not necessarily intended to convey an exclusive set of factors, but can instead, depending, at least in part, on the context, allow for the presence of other factors that are not necessarily explicitly described.
[0059] like Figure 1 As shown, the drug logistics management method based on machine vision includes the following steps:
[0060] S1, drug packaging image acquisition: using a camera to collect image data of drug packaging from multiple angles;
[0061] S2, image preprocessing: preprocessing the collected image data of drug packaging, including image denoising, image enhancement and size normalization;
[0062] S3, packaging integrity analysis: Defect recognition is performed on the preprocessed image data through the packaging defect recognition model, and the integrity of the packaging is judged based on the defect recognition results, including:
[0063] S31, packaging defect recognition: The pre-processed drug packaging image data is analyzed through the packaging defect recognition model to automatically detect packaging defects in the image data, including damage, wrinkles, dirt, and blurred labels;
[0064] S32, defect area positioning and marking: positioning and marking the identified defect area of the drug packaging, generating location information, and marking defect information, including defect size and shape;
[0065] S33, packaging integrity judgment: Based on the results of defect identification, a comprehensive judgment is made on the integrity of the drug packaging to determine whether the packaging is intact, usable, or needs to be repackaged;
[0066] S4, defect correction and packaging reconstruction suggestions: provide corresponding packaging correction or reconstruction suggestions based on the results of packaging integrity analysis;
[0067] Through the above content, comprehensive inspection and monitoring of drug packaging can be carried out efficiently and accurately to ensure the integrity and safety of drugs in the logistics process. By automatically identifying packaging defects, the quality management of drug packaging is optimized, the need for manual intervention is reduced, and the logistics efficiency and accuracy are improved. At the same time, the system can intelligently judge the availability of packaging and provide correction suggestions for defects of different degrees, further improving the traceability and quality control capabilities during drug transportation and storage.
[0068] Pharmaceutical packaging image acquisition in S1 includes:
[0069] S11, setting camera position and angle: according to the shape and size of the drug packaging, set up multiple cameras and plan the camera shooting angles, including the front, side, back and oblique angles, to ensure that every detail of the drug packaging can be fully covered to avoid image distortion and occlusion;
[0070] S12, camera synchronous trigger shooting: through the synchronous trigger mechanism, ensure that each camera shoots at the same time at the same time point, so as to obtain image data with consistent timestamps, ensuring the timeliness and accuracy of the image;
[0071] S13, ensure image quality and consistency: calibrate and test the cameras to ensure that the image resolution, color reproduction and lighting adaptability of each camera meet the same standards;
[0072] Through the above content, every detail of the packaging can be captured comprehensively and accurately to ensure that no possible defects or flaws are missed. Image coverage at different angles can effectively avoid image occlusion or distortion problems caused by a single perspective, thereby improving the integrity and accuracy of image data. At the same time, through precise camera position setting and image quality control, the consistency and high quality of the image are guaranteed, thereby optimizing the packaging quality inspection process and improving the degree of automation and accuracy.
[0073] Image preprocessing in S2 includes:
[0074] S21, image denoising: Use Gaussian filtering algorithm to denoise the collected image data to reduce random noise in the image and make the image clearer, which is expressed as:
[0075]
[0076] Among them, I(xi,yj) represents the pixel value of the original image at the position (xi,yj), I new (x, y) is the pixel value of the denoised image, G(i, j) is the Gaussian filter kernel, k is the radius of the filter window, i and j represent the offset relative to the center pixel, and x and y represent the horizontal and vertical coordinates of the current pixel in the image, respectively;
[0077] S22, image enhancement processing: The image data is enhanced by using the histogram equalization algorithm. By stretching the grayscale distribution of the image, the image details are made clearer, especially in the low-contrast area. It is expressed as:
[0078]
[0079] Among them, H(s) is the pixel value after equalization, p(r) is the probability distribution function of the gray level r of the original image, and s is the gray level value of the image after equalization;
[0080] S23, size normalization processing: normalize the size of the image data to make the size of all images consistent. The goal of normalization is to adjust the size of all image data to a unified standard size W×H, which is expressed as:
[0081]
[0082] Among them, I norm (x, y) is the normalized image pixel value, W orig and H orig is the width and height of the original image, W and H are the target sizes;
[0083] Through the above content, random noise in the image is eliminated, the packaging image is clearer, the contrast and details are improved, the defect features are easier to detect, and the consistency of all image data is ensured.
[0084] The packaging defect recognition model in S31 adopts the convolutional neural network (CNN) model, which includes:
[0085] S311, multi-scale convolution kernel application: Use convolution kernels of different sizes (3×3, 5×5, 7×7) for multi-scale feature extraction to detect packaging defects of various sizes, expressed as:
[0086]
[0087] in, is the value of the l-th layer convolution output feature map at position (u, v), I (x-m)(y-n)is the pixel value of the input image at position (xm,yn), is the weight of the convolution kernel of the lth layer, b l is the bias of the convolution kernel of the lth layer, r is the radius of the convolution kernel, indicating the range of the convolution window, and m and n are the offsets relative to the center pixel;
[0088] S312, activation function application: Use the Leaky ReLU activation function to enhance the ability to identify subtle packaging defects, making the model more sensitive to detecting minor packaging defects, expressed as:
[0089]
[0090] Where f(x) is the output of the Leaky ReLU activation function, x is the input value of a position in the convolution output feature map (i.e., the input of the activation function), and α is a constant that controls the output of the negative region, which is set to a value less than 1 (such as α = 0.01) to avoid the problem of completely zero gradient for negative values;
[0091] S313, Feature Enhanced Attention Mechanism: The attention mechanism is introduced to automatically highlight the defective area in the output feature map of each convolutional layer and ignore irrelevant background information, so that the model can effectively focus on the parts where defects may exist and improve the detection accuracy, which is expressed as:
[0092] Attention(f u,v )=σ(W a ·f u,v +b a )·f u,v ;
[0093] Among them, Attention(f u,v ) is the value of the position (u,v) in the feature map after adding the attention mechanism, f u,v is the value of the feature map output by the convolutional layer at position (u, v), W a is the weight matrix of the attention mechanism, which is used to weight the value of the feature map, b a is the bias term of the attention mechanism, σ is the Sigmoid activation function, expressed as Used to map the output value to the range [0,1];
[0094] S314, multi-layer pooling layer: In order to better preserve detail information, a multi-layer pooling operation is used, including a combination of maximum pooling and average pooling, to preserve the global and local information of the image data, expressed as:
[0095] P max (x,y)=max(I (x-i,y-j) );
[0096]
[0097] Among them, P max (x, y) is the output value of the maximum pooling operation at position (x, y), P avg (x, y) is the output value of the average pooling operation at position (x, y), I (x-i,y-j) is the pixel value relative to the position (x, y) in the pooling window, s is the side length of the pooling window, i and j are the offsets relative to the center position in the pooling window, which are used to traverse all pixels in the pooling window;
[0098] S315, Adaptive loss function: Use an adaptive weighted loss function to assign different weights to different defect types, so that the model pays more attention to defect types that are easy to ignore or difficult to detect, expressed as:
[0099]
[0100]
[0101] Where L is the total loss value, which is the weighted sum of the losses of all defect categories, and w c is the weight of defect category c, which is used to adjust the impact of different defect categories on the total loss. C is the total number of defect categories, y c is the true label value of defect category c, is the model’s predicted probability for defect category c, is the cross entropy loss, which is used to measure the error between the predicted probability and the true label;
[0102] Through the above content, the accuracy and efficiency of pharmaceutical packaging defect detection can be greatly improved. Through the combination of multi-scale convolution kernels, activation functions, attention mechanisms, multi-layer pooling and adaptive loss functions, the model can more accurately identify and locate various packaging defects, including small cracks, wrinkles, contamination and other complex problems, making the model more sensitive to subtle defects while reducing missed detections and false detections, which is especially suitable for the high-standard quality inspection needs of pharmaceutical packaging.
[0103] Defect area positioning and annotation in S32 include:
[0104] S321, defect area positioning: based on the packaging defects in the detected image data, a bounding box containing the defect area is generated through a target detection algorithm, and the location (such as coordinates) and area range of the defect are marked;
[0105] S322, defect information annotation: analyzing the located defect area and extracting defect information, including defect size (area) and shape characteristics (linear, dot or irregular shape);
[0106] Through the above content, the defective areas on the pharmaceutical packaging can be accurately identified and framed, and the specific location, size and shape characteristics of the defects can be marked. It can automatically and quickly capture subtle defects in the packaging and ensure that each problem area is clearly located and marked in detail. With the help of accurate defective area positioning and information marking, it not only reduces the need for manual intervention, but also improves the accuracy and efficiency of packaging quality inspection.
[0107] Defect area positioning in S321 includes:
[0108] S321, generation of bounding box: based on the packaging defects in the identified image data, a candidate box is generated in the area containing the defect, and a bounding box is generated to frame the defect area. The position of the bounding box is determined by the center coordinate (x c ,y c ) and width and height (w,h), expressed as:
[0109]
[0110] w=x max -x min ,h=y max -y min ;
[0111] Among them, x c is the coordinate of the center point of the bounding box on the x-axis, y c is the coordinate of the center point of the bounding box on the y-axis, x min and x max Represents the x-coordinates of the left and right sides of the bounding box, y min and max Represents the top and bottom y coordinates of the bounding box respectively;
[0112] S322, loss function optimization: Use the target detection algorithm to optimize the accuracy of bounding box positioning. The target detection algorithm uses the total loss function of YOLO, including coordinate loss, width and height loss, and category loss, which is expressed as:
[0113]
[0114] Among them, L is the total loss function, which is used to measure the error between the predicted bounding box position, size and classification and the true value, and λ coord is the weight coefficient of the coordinate loss, which controls the influence of the position error on the total loss, λ size is the weight coefficient of the size loss, which controls the influence of the bounding box size error on the total loss. S is the size of the grid division, and B is the number of bounding boxes in each grid. is an indicator variable whose value is 1 when the jth bounding box in grid i contains an object, otherwise it is 0. w and h are the width and height of the predicted bounding box, respectively. and are the width and height of the ground-truth bounding box, respectively, and λ class is the weight coefficient of the category loss, which is used to adjust the impact of the category loss in the total loss and ensure that the category loss accounts for an appropriate proportion in the optimization process. is an indicator variable. Its value is 1 when grid i contains an object, otherwise it is 0. c is a specific category, classes is the set of all categories, and p c is the probability of category c in grid i predicted by the model, is the true category label, which represents the true value of category c in grid i;
[0115] Through the above content, defective areas on drug packaging can be accurately identified and marked, providing precise location information for subsequent defect analysis and repair. By using the target detection algorithm to generate a bounding box, the location, size and shape characteristics of the defect are clearly marked, so that minor cracks, blurred labels or contamination can also be quickly captured. Defects such as can be reduced, the need for manual intervention is reduced, and the accuracy and efficiency of detection are improved. This provides strong technical support for the automated detection of packaging quality and effectively improves the safety and quality management level of drugs in the logistics process.
[0116] Defect information annotation in S322 includes:
[0117] S3221, defect size calculation: The defect size is estimated by calculating the area of the bounding box to estimate the defect area A. Assuming the width of the bounding box of the defect area is w and the height is h, the defect area A is expressed as:
[0118] A = w × h;
[0119] Where w and h are the width and height of the bounding box respectively;
[0120] S3222, defect shape feature extraction: Use image morphology method to process the defect area and analyze the shape features of the defects, including linear, point or irregular shapes;
[0121] Image morphology methods specifically include:
[0122] Aspect ratio: Aspect ratio is a basic feature to measure the shape of the defect area. The aspect ratio R is calculated by the width w and height h of the bounding box to preliminarily determine the shape of the defect, which is expressed as:
[0123]
[0124] Among them, when R≈1, the defect shape is close to a square, and may be point-shaped. When R>>1 or R<<1, the defect shape may be linear. In other cases, it may be an irregular shape.
[0125] Contour perimeter and area ratio: Contour perimeter and area ratio are used to judge the compactness of defects and to identify irregular shapes. Assuming the perimeter of the defect area is P and the area is A, the compactness (compactness coefficient) is expressed as:
[0126]
[0127] Among them, when C is close to 1, the defect area is rounded, and when C is much larger than 1, the defect may have an irregular or elongated shape (such as a linear defect);
[0128] Eccentricity: Eccentricity is used to describe the elliptical shape characteristics of the defect area. Assuming that the major axis length of the minimum circumscribed ellipse of the defect area is a and the minor axis length is b, the eccentricity e is expressed as:
[0129]
[0130] When e is close to 0, the defect shape is close to a circle or a point, and when e is close to 1, the defect shape is more elongated or linear;
[0131] Hu invariant moments: Hu invariant moments are a set of seven shape descriptors that can identify rotation, scale, and mirror invariant properties of shapes, expressed as:
[0132] First invariant moment: I1 = η 20 +η 02 ;
[0133] Second invariant moment:
[0134] The third invariant moment: I3 = (η 30 -3η 12 ) 2 +(3η 21 -η 03 ) 2 ;
[0135] The fourth invariant moment: I4 = (η 30 +η 12 ) 2 +(η 21 +η 03 ) 2 ;
[0136] The fifth invariant moment: I5 = (η 30 -3η 12 )(η 30 +η 12 )[(η30 +η 12 ) 2 -3(η 21 +η 03 ) 2 +(3η 21 -η 03 )(η 21 +η 03 )[3(η 30 +η 12 ) 2 -(η 21 +η 03 ) 2 ;
[0137] Sixth invariant moment: I6 = (η 20 -η 02 )[(η 30 +η 12 ) 2 -(η 21 +η 03 ) 2 +4η 11 (η 30 +η 12 )(η 21 +η 03 );
[0138] Seventh invariant moment: I7 = (3η 21 -η 03 )(η 30 +η 12 )[(η 30 +η 12 ) 2 -3(η 21 +η 03 ) 2 -(η 30 -3η 12 )(η 21 +η 03 )[3(η 30 +η 12 ) 2 -(η 21 +η 03 ) 2 ;
[0139] where η ij represents the normalized central moment, and different combinations of I1, I2, …, I7 can be used to describe different shape features;
[0140] The above content provides rich data support for the classification and processing of pharmaceutical packaging defects. By using methods such as aspect ratio, contour perimeter and area ratio, eccentricity and Hu invariant moment, the geometric characteristics of defects can be comprehensively analyzed, including whether the defects are linear, point-shaped or irregular in shape, ensuring the accuracy of defect identification. Even in the case of complex or subtle defect shapes, key features can be effectively extracted to help achieve higher-precision quality inspection and classification.
[0141] The packaging integrity judgment in S33 includes:
[0142] S331, Packaging is intact: If there is no damage, contamination or unclear label defects in the test results, the packaging is considered intact;
[0143] S332, packaging is usable: if there are fine scratches or creases on the surface not exceeding 1 mm, if the non-critical information on the label is partially blurred but the drug name, batch number, and expiration date are clear, if there are traces of dust in a local area (not exceeding 1 square centimeter), and if there are slight indentations on the edge not exceeding 0.5 mm, the packaging is considered usable;
[0144] S333, need to repackage: if the surface is damaged or cracked, the label information is severely blurred so that the drug name, batch number, and expiration date information cannot be identified, there is large-scale contamination exceeding 1 square centimeter or contamination spreads to the sealing area, and the corners are indented or damaged more than 1 mm, it is judged that repackaging is needed;
[0145] Through the above content, the packaging status is divided into three categories: intact, usable and needing repackaging. The judgment conditions for each status are refined, such as scratches, blurred labels, contaminated area and other specific indicators. This classification method ensures that even if there are minor defects, qualified packaging can continue to be used while ensuring the safety of drugs, thereby reducing unnecessary repackaging costs. At the same time, it supports automated inspection processes, provides a reliable decision-making basis for subsequent packaging corrections and quality control, and improves the efficiency and safety of packaging management in pharmaceutical logistics.
[0146] Bug fixes and packaging rebuild suggestions in S4 include:
[0147] S41, Packaging Correction Suggestions: For packaging that is determined to be usable, provide corresponding correction solutions based on the type and degree of defects, including correction methods such as cleaning, label reinforcement or edge sealing to improve the appearance and protective performance of the packaging and ensure the integrity of the packaging during use;
[0148] S42, Packaging reconstruction recommendations: For packaging that is determined to require repackaging, a repackaging plan is recommended, including replacing damaged packaging materials, relabeling, or replacing contaminated packaging to ensure that the sealing and safety of the packaging fully meet the drug quality standards;
[0149] Through the above content, the accuracy and efficiency of packaging management are improved. For packaging with minor defects, corrective measures such as cleaning and label reinforcement can be taken to extend the service life of the packaging, avoid unnecessary repackaging and reduce costs. For packaging with serious defects, direct reconstruction is recommended to ensure the sealing of the packaging and the safety of the drugs. This method makes the packaging handling process more flexible and efficient, helps to optimize the use of resources while ensuring the quality and safety of drugs, and provides reliable support for quality control in the logistics process.
[0150] like Figure 2 As shown, the drug logistics management device based on machine vision is used to implement the above-mentioned drug logistics management method based on machine vision, and includes the following modules:
[0151] Drug packaging image acquisition module: uses a camera to collect image data of drug packaging from multiple angles;
[0152] Image preprocessing module: preprocess the collected image data, including image denoising, image enhancement and size normalization;
[0153] Packaging integrity analysis module: The packaging defect recognition model is used to identify defects in the preprocessed image data, and the integrity of the packaging is determined based on the defect recognition results;
[0154] Defect correction and packaging reconstruction suggestion module: provides corresponding packaging correction or reconstruction suggestions based on the results of packaging integrity analysis.
[0155] The present invention covers any substitution, modification, equivalent method and scheme made on the essence and scope of the present invention. In order to make the public have a thorough understanding of the present invention, specific details are described in detail in the following preferred embodiments of the present invention, but those skilled in the art can fully understand the present invention without the description of these details. In addition, in order to avoid unnecessary confusion about the essence of the present invention, well-known methods, processes, procedures, components and circuits are not described in detail.
[0156] 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 drug logistics management method based on machine vision, characterized in that: The following steps are involved: S1, drug packaging image acquisition: using a camera to collect image data of drug packaging from multiple angles; S2, image preprocessing: preprocessing the collected image data of drug packaging, including image denoising, image enhancement and size normalization; S3, packaging integrity analysis: Defect recognition is performed on the preprocessed image data through the packaging defect recognition model, and the integrity of the packaging is judged based on the defect recognition results, including: S31, packaging defect recognition: The pre-processed drug packaging image data is analyzed through the packaging defect recognition model to automatically detect packaging defects in the image data, including damage, wrinkles, dirt, and blurred labels; S32, defect area positioning and marking: positioning and marking the identified defect area of the drug packaging, generating location information, and marking defect information, including defect size and shape; S33, packaging integrity judgment: Based on the results of defect identification, a comprehensive judgment is made on the integrity of the drug packaging to determine whether the packaging is intact, usable, or needs to be repackaged; S4, Defect correction and packaging reconstruction suggestions: Provide corresponding packaging correction or reconstruction suggestions based on the results of the packaging integrity analysis.
2. The drug logistics management method based on machine vision according to claim 1, characterized in that: The drug packaging image acquisition in S1 includes: S11, setting camera position and angle: according to the shape and size of the drug packaging, multiple cameras are set, and the camera shooting angles are planned, including the front, side, back and oblique angles; S12, camera synchronous trigger shooting: through the synchronous trigger mechanism, ensure that each camera shoots at the same time at the same time point, so as to obtain image data with consistent timestamp; S13, ensure image quality and consistency: calibrate and test the cameras to ensure that the image resolution, color reproduction and lighting adaptability of each camera meet consistent standards.
3. The drug logistics management method based on machine vision according to claim 1, characterized in that: The image preprocessing in S2 includes: S21, image denoising: use Gaussian filtering algorithm to denoise the collected image data to reduce random noise in the image and make the image clearer; S22, image enhancement processing: using a histogram equalization algorithm to enhance the image data; S23, size normalization processing: normalize the size of the image data to make the sizes of all images consistent. The goal of normalization is to adjust the sizes of all image data to a unified standard size W×H.
4. The drug logistics management method based on machine vision according to claim 1, characterized in that: The packaging defect recognition model in S31 adopts a convolutional neural network model, and the convolutional neural network model includes: S311, Multi-scale convolution kernel application: Use convolution kernels of different sizes for multi-scale feature extraction to detect packaging defects of various sizes; S312, activation function application: Use Leaky ReLU activation function to enhance the recognition of subtle packaging defects; S313, Attention Mechanism for Feature Enhancement: Introducing an attention mechanism to automatically highlight defect areas in the output feature map of each convolutional layer and ignore irrelevant background information; S314, multi-layer pooling layer: uses multi-layer pooling operations, including a combination of maximum pooling and average pooling, to retain global and local information of image data; S315, Adaptive loss function: Use an adaptive weighted loss function.
5. The drug logistics management method based on machine vision according to claim 4 is characterized in that: The defect area positioning and marking in S32 includes: S321, defect area positioning: based on the packaging defects in the detected image data, a bounding box containing the defect area is generated through a target detection algorithm, and the location and area range of the defect are marked; S322, defect information labeling: analyzing the located defect area and extracting defect information, including size and shape characteristics of the defect.
6. The drug logistics management method based on machine vision according to claim 5, characterized in that: The defect area positioning in S321 includes: S321, generation of bounding box: based on the packaging defects in the identified image data, a candidate box is generated in the area containing the defect, and a bounding box is generated to frame the defect area. The position of the bounding box is determined by the center coordinate (x c ,y c ) and width and height (w,h); S322, loss function optimization: Use a target detection algorithm to optimize the accuracy of bounding box positioning. The target detection algorithm adopts the total loss function of YOLO, including coordinate loss, width and height loss, and category loss.
7. The drug logistics management method based on machine vision according to claim 6, characterized in that: The defect information annotation in S322 includes: S3221, defect size calculation: the defect size is estimated by calculating the area of the bounding box to estimate the defect area A; S3222, defect shape feature extraction: Use image morphology method to process the defect area and analyze the shape features of the defects, including linear, point or irregular shapes.
8. The drug logistics management method based on machine vision according to claim 7, characterized in that: The packaging integrity determination in S33 includes: S331, Packaging is intact: If there is no damage, contamination or unclear label defects in the test results, the packaging is considered intact; S332, packaging is usable: if there are fine scratches or creases on the surface not exceeding 1 mm, if the non-critical information on the label is partially blurred but the drug name, batch number, and expiration date are clear, if there are traces of dust in some areas, and if there are slight indentations on the edges not exceeding 0.5 mm, the packaging is considered usable; S333, repackaging is required: If surface damage or cracks are detected, label information is severely blurred so that the drug name, batch number, and expiration date information cannot be identified, there is large-scale contamination exceeding 1 square centimeter or contamination spreads to the sealing area, or corner indentations or damage exceeds 1 mm, then it is judged that repackaging is required.
9. The drug logistics management method based on machine vision according to claim 8, characterized in that: The bug fixes and packaging rebuild suggestions in S4 include: S41, Packaging Correction Suggestions: For packaging that is determined to be usable, provide corresponding correction solutions based on the type and degree of defects, including cleaning, label reinforcement or edge sealing to improve the packaging appearance and protective performance; S42, Packaging reconstruction recommendations: For packaging determined to require repackaging, a repackaging plan is recommended, including replacing damaged packaging materials, relabeling, or replacing contaminated packaging.
10. A drug logistics management device based on machine vision, used to implement the drug logistics management method based on machine vision as claimed in any one of claims 1 to 9, characterized in that: Includes the following modules: Drug packaging image acquisition module: uses a camera to collect image data of drug packaging from multiple angles; Image preprocessing module: preprocess the collected image data, including image denoising, image enhancement and size normalization; Packaging integrity analysis module: The packaging defect recognition model is used to identify defects in the preprocessed image data, and the integrity of the packaging is determined based on the defect recognition results; Defect correction and packaging reconstruction suggestion module: provides corresponding packaging correction or reconstruction suggestions based on the results of packaging integrity analysis.
Citation Information
Patent Citations
Cigarette packet package appearance detection method based on deep self-learning
CN111738963A
Yolov5-based remote sensing directed target detection method
CN113920443A
Quality inspection method and system for soft capsule production, medium and computer equipment
CN117011289A
Power transmission line inspection image detection method based on deep convolutional neural network
CN117541535A
Intelligent detection system and method for medicine packaging defects
CN117952919A