An automatic production monitoring method and system for pills
By collecting images in automatic production of pills and using Gaussian models for sub-pixel edge detection, calculating contour coded values and performing outlier detection, the problem of inaccurate pill quality judgment in the prior art is solved, and accurate monitoring and early warning of the quality of pills finished product is achieved.
Patent Information
- Application Number
- CN202411277953.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2044-09-12
AI Technical Summary
It is difficult to accurately judge the quality of the pill during the automatic production process of pills, especially when a large number of pills are present, it is difficult to collect image sequences, and it is impossible to accurately judge the quality of the pills.
An automatic production monitoring method of pills is adopted. By collecting the pill images after production, using a preset Gaussian model to perform sub-pixel edge detection, obtaining the pill profile, drawing extension lines along the gradient direction, calculating the contour code value, and conducting outlier detection, issuing an early warning to judge the quality of the pills.
Accurate judgment of the quality of the finished pills is achieved, and the production quality can be monitored during the automatic production process of the pills and the product pass rate can be improved.
Smart Images

Figure CN119228752B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of intelligent production technology, and in particular to a method and system for automatically monitoring the production of pills. Background Art
[0002] Pills refer to spherical or quasi-spherical tablet preparations made from fine powder of medicinal materials or medicinal material extracts with appropriate adhesive excipients. The automatic production of pills includes steps such as raw material preparation, material mixing, processing into pills, drying and packaging. During the production process, pills will be affected by the physical properties of the processed raw materials, the production environment and the production process, resulting in abnormal shapes of pills and affecting the quality of pills.
[0003] In the field of image processing, edge refers to the part of the local area in the image where the brightness changes significantly. Traditional edge detection methods, such as the Canny edge detection algorithm, can only achieve pixel-level detection accuracy, which cannot meet the needs of actual measurement. Sub-pixel edge detection came into being. Sub-pixel is a subdivision of pixels, which is a unit smaller than pixels. Sub-pixel edge points exist in areas where the image gradually changes excessively. Usually, the grayscale value or the derivative of the grayscale value of the pixel point is interpolated according to the preset edge model to increase information, accurately locate the position of the sub-pixel edge point, and realize sub-pixel edge detection. Among them, the preset edge model is a hyperbolic tangent function or a Gaussian edge function.
[0004] At present, a patent application document with application publication number CN118096734A discloses a product quality monitoring method and system based on big data, wherein the method includes: collecting an image sequence of pills during rolling, the image sequence including multiple frames of grayscale images; obtaining a pill area in any frame of grayscale image, and constructing an area sequence of the image sequence according to the number of pixels in the pill area; taking the change amplitude of the gradient direction of the pill area between any two adjacent frames of grayscale images as the direction amplitude of the latter frame of grayscale image in the two adjacent frames of grayscale images, and constructing a direction amplitude sequence of the image sequence; for a frame of grayscale image, extracting the grayscale run matrix of the pill area in the grayscale image, and obtaining the pill texture feature value of the grayscale image according to the grayscale run matrix, retaining the minimum value of the pill texture feature value in the image sequence as the pill crack value; inputting the area sequence, the direction amplitude sequence and the pill crack value into the trained pill quality judgment model, and outputting the pill quality judgment result.
[0005] The above method collects the area information, directional amplitude information and pill crack value information of the image sequence of the pill during the rolling process, and obtains the quality judgment result of the pill with the help of the trained pill quality judgment model. However, in the process of automatic production of pills, there are a large number of pills at the same time. The above method needs to collect the image sequence of each pill during the rolling process. The image sequence collection is difficult and the quality of the pill cannot be accurately judged. Summary of the Invention
[0006] To solve the technical problem of being unable to accurately judge the quality of pills, the present application provides an automatic production monitoring method and system for pills, which can accurately judge the quality of pill products.
[0007] In the first aspect of the present application, an automatic production monitoring method for pills is provided. The monitoring method includes: collecting a pill image after production is completed, performing sub-pixel edge detection on the pill image using a preset Gaussian model to obtain a pill contour map, where the pill contour map includes a plurality of contour points; drawing extension lines of each contour point along the gradient direction, and in response to the plurality of extension lines intersecting at any position point, taking the contour points corresponding to the plurality of extension lines as the target contour points of the position point; calculating the contour coding value of each position point, including: in response to the number of target contour points being less than a preset value, the contour coding value of the position point is 0, and in response to the number of target contour points being greater than or equal to the preset value, the contour coding value of the position point is equal to the sum of the variance of the Euclidean distances between each target contour point and the position point, and the variance of the gradient values of the target contour points; performing outlier detection on the contour coding values of each position point to obtain the outlier value of each position point; and in response to the outlier value of any position point being greater than a preset outlier value, issuing a warning.
[0008] Performing sub-pixel edge detection on the pill image after production to obtain a plurality of contour points of the pill, drawing extension lines of each contour point along the gradient direction, and the plurality of extension lines will intersect at any position point in the pill image. If the plurality of extension lines intersect at a position point, taking the contour points corresponding to the plurality of extension lines as the target contour points of the position point; ideally, all the target contour points of a position point can form a circular contour. Therefore, taking the sum of the variance of the Euclidean distances between each target contour point and the position point and the variance of the gradient values of the target contour points as the contour coding value of each position point; performing outlier detection on the contour coding values of each position point, and in response to the outlier value of any position point being greater than a preset outlier value, issuing a warning, accurately judging the quality of pill products, and monitoring the production quality of pills during the automatic production process of pills.
[0009] Preferably, before performing sub-pixel edge detection on the pill image, the monitoring method further includes: performing threshold segmentation on the pill image according to a preset color threshold.
[0010] Segmenting the pill image using the color difference between the pill and the background, avoiding the influence of the contour points in the background area of the pill image on the quality detection of the pill, and ensuring that the quality of pill products can be accurately judged.
[0011] Preferably, performing sub-pixel edge detection on the pill image using a preset Gaussian model includes: performing Canny edge detection on the pill image to obtain each edge point; obtaining the previous adjacent position point and the next adjacent position point along the gradient direction of each edge point, and correcting the edge point according to the preset Gaussian model to obtain sub-pixel edge points. The sub-pixel edge point of the edge point is: where is the preset Gaussian model, , and are the previous adjacent position point, the edge point, and the next adjacent position point respectively, is the edge point 's sub-pixel edge point; all sub-pixel edge points correspond to the contour points in the pill contour map.
[0012] Preferably, the contour encoding value of the position point further includes the absolute value of the difference between the number of each target contour point and the average perimeter, and the average perimeter is equal to the perimeter of the circular contour with the average Euclidean distance between each target contour point and the position point as the radius.
[0013] The number of target contour points corresponding to a position point can reflect all the contour points covered by the circular contour with this position point as the center in the pill contour map. Ideally, the target contour points corresponding to a position point can form a complete circular contour. Therefore, calculating the absolute value of the difference between the number of target contour points and the average perimeter as part of the contour encoding value can reflect the integrity of the circular contour with this position point as the center, and further reflect the quality of the pill.
[0014] Preferably, an outlier detection algorithm is used to perform outlier detection on the contour encoding values of each position point, and the outlier detection algorithm is the CBLOF algorithm, the LOF algorithm, or the isolation forest algorithm.
[0015] Preferably, in response to the outlier value of any position point being greater than the preset outlier value, the monitoring method further includes: marking the target contour points corresponding to the any position point as a defect area to obtain the position information of the abnormal pill.
[0016] By realizing the positioning of the abnormal pill, the abnormal pill can be screened out to ensure the product qualification rate of the automatic production of the pill.
[0017] Preferably, obtaining the outlier value of each position point includes: calculating the absolute value of the difference between the contour encoding value of each position point and the theoretical value as the contour loss, adjusting the model parameters of the preset Gaussian model multiple times to update the contour encoding value of each position point, and in response to the contour loss reaching the minimum value, performing outlier detection on the contour encoding value of each position point to obtain the outlier value of each position point, and the theoretical value is taken as 0.
[0018] The outliers at each position point can be divided into two parts. The first is the outliers caused by insufficient accuracy of sub-pixel edge detection, and the second is the outliers caused by the quality of the pills themselves. The model parameters of the preset Gaussian model are adjusted multiple times. When the contour loss reaches the minimum value, it indicates that the accuracy of sub-pixel edge detection at this time reaches the optimal. By excluding the influence of insufficient accuracy of sub-pixel edge detection on the outliers, the accuracy of the outliers at each position point is ensured.
[0019] In the second aspect of the present application, an automatic pill production monitoring system is further provided, including a processor and a memory. The memory stores computer program instructions, and when the computer program instructions are executed by the processor, an automatic pill production monitoring method according to the first aspect of the present application is implemented.
[0020] The technical solution of the present application has the following beneficial technical effects:
[0021] Perform sub-pixel edge detection on the pill images after production, accurately locate multiple contour points on the pills in the pill images, draw extension lines of each contour point along the gradient direction, and the multiple extension lines will intersect at any position point in the pill image. If the multiple extension lines intersect at a position point, the contour points corresponding to the multiple extension lines are used as the target contour points of this position point. Ideally, all the target contour points at a position point can form a circular contour. Therefore, the sum of the variance of the Euclidean distance between each target contour point and the position point, the variance of the gradient value of the target contour point, and the absolute value of the difference between the number of target contour points and the circumference of the circular contour is used as the contour coding value of each position point. Perform outlier detection on the contour coding values of each position point. In response to the outlier value of any position point being greater than the preset outlier value, an alarm is issued to accurately judge the quality of the pill products and monitor the production quality of the pills during the automatic pill production process.
[0022] Furthermore, by adjusting the model parameters of the preset Gaussian model multiple times to update the pill contour map, when the contour loss reaches the minimum value, it indicates that the accuracy of sub-pixel edge detection at this time reaches the optimal. By excluding the influence of insufficient accuracy of sub-pixel edge detection on the outliers, the accuracy of the outliers at each position point is ensured. Description of the Drawings
[0023] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features, and advantages of the exemplary embodiments of the present application will become easily understandable. In the drawings, several embodiments of the present application are shown in an exemplary rather than restrictive manner, and the same or corresponding reference numerals represent the same or corresponding parts, where:
[0024] Figure 1 is a flowchart of an automatic pill production monitoring method according to an embodiment of the present application;
[0025] Figure 2 It is a schematic diagram of sub-pixel edge points according to an embodiment of the present application;
[0026] Figure 3 It is a flowchart of an automatic pill production monitoring method according to another embodiment of the present application;
[0027] Figure 4 It is a structural block diagram of an automatic pill production monitoring system according to an embodiment of the present application. Detailed implementation manners
[0028] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present application.
[0029] It should be understood that when terms such as "first" and "second" are used in the claims, the description, and the drawings of the present application, they are only used to distinguish different objects, rather than to describe a specific order. The terms "including" and "comprising" used in the description and claims of the present application indicate the presence of the described features, wholes, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their combinations.
[0030] According to the first aspect of the present application, the present application provides an automatic pill production monitoring method. Figure 1 It is a flowchart of an automatic pill production monitoring method according to an embodiment of the present application. As Figure 1 shown, the automatic pill production monitoring method includes steps S101 to S105, which are described in detail below.
[0031] S101, collect the pill image after production ends, perform sub-pixel edge detection on the pill image using a preset Gaussian model, and obtain a pill contour map, where the pill contour map includes a plurality of contour points.
[0032] In one embodiment, the pill image after production ends is collected from a top-down perspective. The pill image includes a plurality of produced pills, and the pill image is a grayscale image.
[0033] To avoid the influence of background information on the pill contour, before performing sub-pixel edge detection on the pill image, the monitoring method further includes: performing threshold segmentation on the pill image according to a preset color threshold. Among them, the background information not included in the pill image after threshold segmentation ensures the accuracy of the pill contour map.
[0034] In one embodiment, using a preset Gaussian model to perform sub-pixel edge detection on the pill image includes: performing Canny edge detection on the pill image to obtain each edge point; obtaining the previous adjacent position point and the next adjacent position point along the gradient direction of each edge point, and correcting the edge point according to the preset Gaussian model to obtain sub-pixel edge points. The edge point of the sub-pixel edge point is: , is the preset Gaussian model, , and are the previous adjacent position point, the edge point, and the next adjacent position point respectively, is the edge point of the sub-pixel edge point; all sub-pixel edge points correspond to the contour points in the pill contour map. Among them, the preset Gaussian model includes a preset mean and a preset variance.
[0035] Specifically, please refer to Figure 2 , which is a schematic diagram of sub-pixel edge points according to an embodiment of the present application. Taking the edge point as an example, the previous adjacent position point and the next adjacent position point are obtained along the gradient direction of the edge point. Using the preset Gaussian model to perform interpolation between , and , the gradient value curve between the three position points , and can be obtained. The coordinates corresponding to the maximum value of the gradient value curve are defined as the sub-pixel edge point . The gradient direction of the sub-pixel edge point is the gradient direction of the edge point . Inputting the position information of the sub-pixel edge point into the preset Gaussian model, the gradient value of the sub-pixel edge point is obtained.
[0036] In this way, using the preset Gaussian model to perform interpolation on the edge point and realizing sub-pixel level edge detection according to the interpolation result, accurately locating all the contour points of the pills in the pill image, and ensuring the accuracy of subsequent pill anomaly detection.
[0037] S102, draw extension lines of each contour point along the gradient direction. In response to the intersection of multiple extension lines at any position point, use the contour points corresponding to the multiple extension lines as the target contour points of the position point.
[0038] In one embodiment, the pill contour map includes contour points and non - contour points. Both the contour points and non - contour points are position points, and one contour point corresponds to one gradient direction and one gradient value. By drawing extension lines along the gradient direction of each contour point, multiple extension lines can be obtained in the pill contour map, and each extension line may intersect or not intersect with each other.
[0039] For any position point, two situations may occur: Situation 1, no extension line passes through this position point, in which case there is no target contour point at this position point; Situation 2, at least one extension line passes through this position point, that is to say, at least one extension line intersects at this position point. At this time, the number of target contour points corresponding to this position point is the number of extension lines passing through this position point.
[0040] Therefore, in response to multiple extension lines intersecting at any position point, the contour points corresponding to the multiple extension lines are used as the target contour points of the position point.
[0041] It can be understood that for any two contour points, if they are located on the same circular contour, their extension lines will intersect at the center of the circular contour, and the distances from these two contour points to the center are equal to the radius of the circular contour. Therefore, the target contour points of a position point can be understood as: the contour points on all circular contours with this position point as the center in the pill contour map.
[0042] S103. Calculate the contour coding value of each position point, including: in response to the number of target contour points being less than the preset value, the contour coding value of the position point is 0; in response to the number of target contour points being greater than or equal to the preset value, the contour coding value of the position point is equal to the sum of the variance of the Euclidean distances between each target contour point and the position point, and the variance of the gradient values of the target contour points.
[0043] In one embodiment, the contour coding value of each position point is calculated based on the target contour points corresponding to the position point. Specifically, in response to the number of target contour points being less than the preset value, the contour coding value of the position point is 0; in response to the number of target contour points being greater than or equal to the preset value, the contour coding value of the position point is equal to the sum of the variance of the Euclidean distances between each target contour point and the position point, and the variance of the gradient values of the target contour points.
[0044] Among them, the value of the preset value is 10. If the number of target contour points corresponding to a position point is less than the preset value, it means that the target contour points corresponding to the position point are not sufficient to form the circular contour of the pill, that is, the position point does not belong to the center point of the pill, and the contour encoding value is directly set to 0; if the number of target contour points corresponding to a position point is greater than or equal to the preset value, it means that the target contour points corresponding to the position point are sufficient to form the circular contour of the pill, that is, the position point is the center point of the pill. Further, calculate the variance of the Euclidean distances between all target contour points and this position point. If the variance of the Euclidean distances approaches 0, it means that the Euclidean distances from each target contour point to the position point are the same, and all target contour points are on the same circular contour. Therefore, the variance of the Euclidean distances can reflect the roundness of the pill; similarly, if the variance of the gradient values of each target contour point approaches 0, it means that the gradient characteristics of the pill edge are consistent. Therefore, the variance of the gradient values can reflect the consistency of the pill edge texture; take the sum of the variance of the Euclidean distances and the variance of the gradient values as the contour encoding value of this position point.
[0045] In another embodiment, when a complete circular contour can be detected at a position point in the pill contour map, the number of target contour points corresponding to this position point should be equal to the theoretical circumference of the circular contour (i.e., , is the radius of the circular contour). Therefore, for a position point, the difference between the number of target contour points and the theoretical circumference of the circular contour can reflect the contour integrity of the pill. The contour encoding value also includes the absolute value of the difference between the number of target contour points and the average circumference, and the average circumference is the circumference of the circular contour with the average Euclidean distance between each target contour point and the position point as the radius.
[0046] Specifically, the contour encoding value of the position point satisfies the relational expression:
[0047] , is the number of target contour points of the position point , is the average Euclidean distance between each target contour point and the position point , is the variance of the Euclidean distances between each target contour point and the position point , is the variance of the gradient values of each target contour point of the position point .
[0048] In this way, the contour encoding value of each position point in the pill contour map is obtained. The contour encoding value can reflect the roundness of the pill, the consistency of the edge texture, and the contour integrity; the closer the contour encoding value is to 0, the better the roundness of the pill, the more consistent the edge texture, and the more complete the pill contour.
[0049] S104. Detect outliers for the contour encoding values of each position point to obtain the outliers of each position point.
[0050] In one embodiment, one position point corresponds to one contour encoding value. Use an outlier detection algorithm to detect outliers for the contour encoding values of each position point. The outlier detection algorithm is the CBLOF algorithm, the LOF algorithm, or the Isolation Forest algorithm. In response to the outlier value of any position point being greater than a preset outlier value, issue a warning. The preset outlier value is 0.5.
[0051] Among them, the LOF algorithm (Local Outlier Factor algorithm) is a density-based outlier detection. The CBLOF algorithm is based on the Local Outlier Factor algorithm and uses a clustering method to implement outlier detection. The Isolation Forest algorithm is an outlier detection algorithm based on a random binary tree, and uses the number of splits of a sample to measure the outlier degree of the sample. The CBLOF algorithm, the LOF algorithm, or the Isolation Forest algorithm can all assign an outlier value to each position point. The larger the outlier value, the more abnormal the position point.
[0052] S105. In response to the outlier value of any position point being greater than a preset outlier value, issue a warning.
[0053] In one embodiment, in response to the outlier value of any position point being greater than a preset outlier value, the monitoring method further includes: marking the target contour point corresponding to the any position point as a defective area to obtain the position information of the abnormal pill.
[0054] In this way, the positioning of the abnormal pill is realized. According to the position information of the abnormal pill, the pills with abnormal shapes can be removed to ensure the quality of the pills.
[0055] Figure 3 is a flowchart of a method for automatically monitoring the production of pills according to another embodiment of the present application. As Figure 3 shown, the method for automatically monitoring the production of pills includes steps S201 to S205. Among them, the implementation methods of steps S201 to S203 are the same as those of steps S101 to S103, and the implementation method of step S205 is the same as that of step S105, which will not be elaborated here. Only step S204 will be described in detail below.
[0056] S204. Calculate the absolute value of the difference between the contour encoding value of each position point and the theoretical value as the contour loss. Adjust the model parameters of the preset Gaussian model multiple times to update the contour encoding values of each position point. In response to the contour loss reaching the minimum value, detect outliers for the contour encoding values of each position point to obtain the outliers of each position point.
[0057] In one embodiment, during the automatic production process of pills, the situation of abnormal pills is a low-probability event, that is, the shapes of most pills in the pill images are circular contours under normal circumstances. Therefore, ideally, the contour coding values of most position points are equal and equal to the theoretical value, and the value of the theoretical value is 0.
[0058] Calculate the absolute value of the difference between the contour coding value of each position point and the theoretical value as the contour loss. The contour loss is: , where is the contour coding value of the position point in the pill contour map , is the theoretical value, and the value of the theoretical value is 0; the preset Gaussian model directly affects the accuracy of sub-pixel edge detection. Different preset Gaussian models correspond to different pill contour maps. By adjusting the model parameters, the pill contour map can be updated, and then the contour coding values of each position point can be updated. Therefore, the abnormal values of each position point can be divided into two parts. The first is the abnormality caused by insufficient accuracy of sub-pixel edge detection, and the second is the abnormality caused by the quality of the pills themselves. Adjust the model parameters of the preset Gaussian model multiple times. The model parameters include the mean and variance. When the contour loss reaches the minimum value, it means that the accuracy of sub-pixel edge detection at this time reaches the optimal, excluding the influence of insufficient accuracy of sub-pixel edge detection on the abnormal values, and then ensuring the accuracy of the abnormal values of each position point.
[0059] Among them, optimization algorithms such as the hill climbing algorithm or the simulated annealing algorithm can be used to adjust the model parameters of the preset Gaussian model multiple times to obtain the abnormal values of each position point when the accuracy of sub-pixel edge detection reaches the optimal. When adjusting the model parameters of the preset Gaussian model multiple times, the maximum number of adjustments can be set to avoid falling into an infinite loop. Specifically, the maximum number of adjustments is set to 100.
[0060] In this way, since the accuracy of sub-pixel edge detection directly affects the accuracy of the abnormal values of each position point, this application aims to minimize the absolute value of the difference between the contour coding value of each position point and the theoretical value, obtain the abnormal values of each position point when the accuracy of sub-pixel edge detection reaches the optimal, and then accurately judge the quality of the pill products.
[0061] The technical principle and implementation details of the automatic production monitoring method for pills of the present application are introduced through specific embodiments above. Sub-pixel edge detection is performed on the pill images after production to accurately locate multiple contour points on the pills in the pill images. Extension lines of each contour point are drawn along the gradient direction, and multiple extension lines will intersect at an arbitrary position point in the pill image. If multiple extension lines intersect at one position point, the contour points corresponding to the multiple extension lines are used as the target contour points of this position point; ideally, all the target contour points of one position point can form a circular contour. Therefore, the sum of the variance of the Euclidean distances between each target contour point and the position point, the variance of the gradient values of the target contour points, and the absolute value of the difference between the number of target contour points and the circumference of the circular contour is used as the contour coding value of each position point; outlier detection is performed on the contour coding values of each position point. In response to the abnormal value of any position point being greater than the preset abnormal value, a warning is issued to accurately judge the quality of the finished pills and monitor the production quality of the pills during the automatic production process of the pills.
[0062] According to the second aspect of the present application, the present application also provides an automatic production monitoring system for pills. Figure 4 It is a structural block diagram of the automatic production monitoring system for pills according to an embodiment of the present application. As Figure 4 shown, the system 50 includes a processor and a memory. The memory stores computer program instructions, and when the computer program instructions are executed by the processor, it implements an automatic production monitoring method for pills according to the first aspect of the present application. The system also includes other components well-known to those skilled in the art such as a communication bus and a communication interface, and their settings and functions are known in the art, so they will not be elaborated here.
[0063] In the present application, the foregoing memory may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, system, or device. For example, a computer-readable storage medium may be any suitable magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory (RRAM), a dynamic random access memory (DRAM), a static random access memory (SRAM), an enhanced dynamic random access memory (EDRAM), a high-bandwidth memory (HBM), a hybrid memory cube (HMC), etc., or any other medium that can be used to store the required information and can be accessed by an application, a module, or both. Any such computer storage medium may be part of the device or accessible or connectable to the device. Any application or module described in the present application may be implemented using computer-readable / executable instructions that can be stored or otherwise maintained by such a computer-readable medium.
[0064] The technical features of the above-described embodiments may be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0065] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the scope of the patent application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the appended claims.
Claims
1. A method for automatically monitoring the production of pills, characterized in that: The monitoring method comprises: Collecting a pill image after production, performing sub-pixel edge detection on the pill image using a preset Gaussian model to obtain a pill contour map, wherein the pill contour map includes a plurality of contour points; Draw extension lines of each contour point along the gradient direction, and in response to a plurality of extension lines intersecting at an arbitrary position point, use the contour points corresponding to the plurality of extension lines as target contour points of the position point; Calculating the contour coding value of each position point, including: in response to the number of target contour points being less than a preset value, the contour coding value of the position point is 0; in response to the number of target contour points being greater than or equal to the preset value, the contour coding value of the position point is equal to the sum of the variance of the Euclidean distance between each target contour point and the position point, and the variance of the gradient value of the target contour point; Outlier detection is performed on the contour coding value of each position point to obtain the abnormal value of each position point; in response to the abnormal value of any position point being greater than the preset abnormal value, an early warning is issued.
2. The method for automatic pill production monitoring according to claim 1, characterized in that: Before performing sub-pixel edge detection on the pill image, the monitoring method further includes: performing threshold segmentation on the pill image according to a preset color threshold.
3. The method for automatic pill production monitoring according to claim 1, characterized in that: Performing sub-pixel edge detection on the pill image using a preset Gaussian model includes: Performing Canny edge detection on the pill image to obtain edge points; The previous adjacent position point and the next adjacent position point are obtained along the gradient direction of each edge point, and the edge point is corrected according to the preset Gaussian model to obtain the sub-pixel edge point. Sub-pixel edge points for: , To preset the Gaussian model, , and are the previous adjacent position point, edge point and next adjacent position point respectively. For edge points sub-pixel edge points; all sub-pixel edge points correspond to contour points in the pill contour map.
4. The method for automatic pill production monitoring according to claim 1, characterized in that: The contour encoding value of the position point also includes the absolute value of the difference between the number of each target contour point and the average perimeter, and the average perimeter is equal to the perimeter of a circular contour with the average Euclidean distance between each target contour point and the position point as the radius.
5. The method for automatic pill production monitoring according to claim 1, characterized in that: An outlier detection algorithm is used to detect outliers on the contour coding value of each position point. The anomaly detection algorithm is a CBLOF algorithm, a LOF algorithm or an isolation forest algorithm.
6. The method for automatic pill production monitoring according to claim 1, characterized in that: In response to the abnormal value of any position point being greater than a preset abnormal value, the monitoring method further includes: The target contour point corresponding to the arbitrary position point is marked as a defect area to obtain the position information of the abnormal pill.
7. A method for automatically monitoring pill production according to any one of claims 1 to 6, characterized in that: The outliers at each location point include: The absolute value of the difference between the contour coding value of each position point and the theoretical value is calculated as the contour loss, and the model parameters of the preset Gaussian model are adjusted multiple times to update the contour coding value of each position point. In response to the contour loss reaching the minimum value, outlier detection is performed on the contour coding value of each position point to obtain the abnormal value of each position point, and the theoretical value is 0.
8. A pill automatic production monitoring system, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, a method for automatically monitoring the production of pills according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Product quality monitoring method and system based on big data
CN118096734A
Production abnormity monitoring method for municipal clothing cleaning device
CN114742826A
Image recognition-based illegal building identification method and device
WO2021003824A1