Automatic pill production monitoring method and system
By using sub-pixel edge detection technology in automatic production of pills, using Gaussian model and outlier detection, the accuracy of pill quality judgment in the prior art is solved, and accurate monitoring of the finished pill product quality and identification of abnormal pills are achieved. , ensuring the product's pass rate.
Patent Information
- Application Number
- CN202411277953.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2044-09-12
AI Technical Summary
The existing automatic production methods of pills are difficult to accurately judge the quality of pills, especially in the automatic production process of pills, image sequence acquisition is difficult, and it is impossible to accurately judge the abnormal shape and quality of pills.
Subpixel edge detection technology is used to detect the pill image edge using a preset Gaussian model, calculate the contour coded value, and identify outliers through outlier detection to achieve accurate judgment of the finished pill product quality. The method includes performing subpixel edge detection on the pill image after production, drawing an extension line of the contour point, calculating the contour coded value, and issuing an early warning through outlier point detection to judge the quality of the pill.
It realizes an accurate judgment of the quality of the finished pill, and can monitor the production quality during the automatic production process of the pill, screen out abnormal pills, and ensure product pass rate.
Smart Images

Figure CN119228752A_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] In order to solve the technical problem of being unable to accurately judge the quality of pills, the present application provides a method and system for automatically monitoring the production of pills, which can accurately judge the quality of finished pills.
[0007] In a first aspect of the present application, a method for automatic production monitoring of pills is provided, the monitoring method comprising: collecting a pill image after the production is completed, performing sub-pixel edge detection on the pill image using a preset Gaussian model to obtain a pill contour map, the pill contour map comprising a plurality of contour points; drawing extension lines of each contour point along a gradient direction, and in response to a plurality of extension lines intersecting at an arbitrary position point, taking the contour points corresponding to the plurality of extension lines as target contour points of the position point; calculating contour coding values of each position point, comprising: in response to the number of target contour points being less than a preset value, the contour coding value of the position point being 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 being equal to the variance of the Euclidean distance between each target contour point and the sum of the variances of the gradient values of the target contour points; performing outlier detection on the contour coding values of each position point to obtain an abnormal value of each position point; and issuing an early warning in response to the abnormal value of any position point being greater than the preset abnormal value.
[0008] Sub-pixel edge detection is performed on the pill image after production to obtain multiple contour points of the pill, and extension lines of each contour point are drawn along the gradient direction. Multiple extension lines will intersect at any 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 the position point; ideally, all target contour points of a position point can form a circular contour, so 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 is used as the contour encoding value of each position point; outlier detection is performed on the contour encoding value of each position point, and in response to the abnormal value of any position point being greater than the preset abnormal value, an early warning is issued to accurately judge the quality of the finished pill product and monitor the production quality of the pills during the automatic production process of the pills.
[0009] Preferably, before performing sub-pixel edge detection on the pill image, the monitoring method further comprises: performing threshold segmentation on the pill image according to a preset color threshold.
[0010] The pill image is segmented using the color difference between the pill and the background to avoid the contour points of the background area in the pill image affecting the quality detection of the pill, ensuring that the quality of the finished pill 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; acquiring a previous adjacent position point and a 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 a sub-pixel edge point, the 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.
[0012] Preferably, the contour encoding value of the location 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 location point as the radius.
[0013] The number of target contour points corresponding to a position point can reflect all contour points covered by the circular contour with the 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, the absolute value of the difference between the number of target contour points and the average circumference is calculated as part of the contour coding value, which can reflect the integrity of the circular contour with the position point as the center, and thus reflect the quality of the pill.
[0014] Preferably, an outlier detection is performed on the contour coding value of each position point using an anomaly detection algorithm, and the anomaly detection algorithm is a CBLOF algorithm, a LOF algorithm or an isolation forest algorithm.
[0015] Preferably, in response to the abnormal value of any position point being greater than a preset abnormal value, the monitoring method further comprises: marking the target contour point corresponding to the arbitrary position point as a defective area to obtain the position information of the abnormal pill.
[0016] By locating abnormal pills, abnormal pills can be screened out to ensure the qualified rate of automatic pill production.
[0017] Preferably, obtaining the abnormal value of each position point includes: calculating the absolute value of the difference between the contour coding 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 coding value of each position point, and in response to the contour loss reaching the minimum value, performing outlier detection on the contour coding value of each position point to obtain the abnormal value of each position point, and the theoretical value is 0.
[0018] The outliers at each position point can be divided into two parts. The first is the anomaly caused by insufficient precision of sub-pixel edge detection, and the second is the anomaly 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 means that the accuracy of sub-pixel edge detection is optimal at this time, eliminating the influence of insufficient precision of sub-pixel edge detection on the outliers, thereby ensuring the accuracy of the outliers at each position point.
[0019] In a second aspect of the present application, there is also provided an automatic pill production monitoring system, comprising a processor and a memory, wherein 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 this application has the following beneficial technical effects: Sub-pixel edge detection is performed on the pill image after production, and multiple contour points on the pill in the pill image are accurately located. Extension lines of each contour point are drawn along the gradient direction. Multiple extension lines will intersect at any 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 the position point; ideally, all target contour points of 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; outlier detection is performed on the contour coding value of each position point, and in response to the abnormal value of any position point being greater than the preset abnormal value, an early warning is issued to accurately judge the quality of the finished pill product and monitor the production quality of the pills during the automatic production process of pills.
[0021] 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 means that the accuracy of sub-pixel edge detection at this time has reached the optimal level, eliminating the influence of insufficient accuracy of sub-pixel edge detection on outliers, thereby ensuring the accuracy of outliers at each position point. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] By reading the detailed description below with reference to the accompanying drawings, the above and other purposes, features and advantages of the exemplary embodiments of the present application will become easy to understand. In the accompanying drawings, several embodiments of the present application are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein: Figure 1 is a flow chart of a method for automatic pill production monitoring according to an embodiment of the present application; Figure 2is a schematic diagram of a sub-pixel edge point according to an embodiment of the present application; Figure 3 is a flow chart of a method for automatic pill production monitoring according to another embodiment of the present application; Figure 4 It is a structural block diagram of the automatic pill production monitoring system according to an embodiment of the present application. DETAILED DESCRIPTION
[0023] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0024] It should be understood that when the terms "first", "second", etc. are used in the claims, specification and drawings of the present application, they are only used to distinguish different objects, rather than to describe a specific order. The terms "include" and "comprise" used in the specification 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 collections.
[0025] According to a first aspect of the present application, the present application provides a method for automatically monitoring the production of pills. Figure 1 FIG. 1 is a flow chart of a method for automatically monitoring pill production according to an embodiment of the present application. Figure 1 As shown, the automatic pill production monitoring method includes steps S101 to S105, which are described in detail below.
[0026] S101, collecting pill images after production, performing sub-pixel edge detection on the pill images using a preset Gaussian model, and obtaining a pill contour map, wherein the pill contour map includes a plurality of contour points.
[0027] In one embodiment, a pill image after production is collected from a top-down perspective, the pill image includes a plurality of produced pills, and the pill image is a grayscale image.
[0028] In order 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. The pill image after threshold segmentation does not contain background information, thereby ensuring the accuracy of the pill contour map.
[0029] In one embodiment, 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 a previous adjacent position point and a 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 a sub-pixel edge point, and the 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 All sub-pixel edge points correspond to contour points in the pill contour map. The preset Gaussian model includes a preset mean and a preset variance.
[0030] Specifically, see Figure 2 , is a schematic diagram of a sub-pixel edge point according to an embodiment of the present application. Take the gradient direction of the edge point as an example to obtain the previous adjacent position point and the next adjacent point , using the preset Gaussian model in , and By interpolating between , and The gradient value curve between the three position points defines the coordinates corresponding to the maximum value of the gradient value curve as the sub-pixel edge point . Sub-pixel edge points The gradient direction is the edge point The gradient direction of the sub-pixel edge point The position information of the sub-pixel edge point is input into the preset Gaussian model to obtain the sub-pixel edge point The gradient value of .
[0031] In this way, the edge points are interpolated using the preset Gaussian model, and sub-pixel level edge detection is achieved based on the interpolation results to accurately locate the contour points of all pills in the pill image, ensuring the accuracy of subsequent pill anomaly detection.
[0032] S102, drawing 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, taking the contour points corresponding to the plurality of extension lines as target contour points of the position point.
[0033] In one embodiment, the pill contour map includes contour points and non-contour points, both of which are position points, and one contour point corresponds to one gradient direction and one gradient value; an extension line is drawn along the gradient direction of each contour point, and multiple extension lines can be obtained in the pill contour map, and each extension line may intersect or not intersect with each other.
[0034] For any position point, there are two situations: In the first situation, no extension line passes through the position point, and at this time there is no target contour point at this position point; in the second situation, at least one extension line passes through the position point, that is, at least one extension line intersects with the position point. At this time, the number of target contour points corresponding to the position point is the number of extension lines passing through the position point.
[0035] Therefore, in response to the intersection of multiple extended lines at an arbitrary position point, the contour points corresponding to the multiple extended lines are used as target contour points of the position point.
[0036] It can be understood that for any two contour points, if they are located in the same circular contour, their extension lines will intersect at the center of the circular contour, and the distance between the two contour points and the center is equal to the radius of the circular contour; therefore, the target contour point of a position point can be understood as: in the pill contour diagram, the contour points on all circular contours with the position point as the center.
[0037] S103, 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 variance of the Euclidean distance between each target contour point and the position point, and the sum of the variances of the gradient values of the target contour points.
[0038] In one embodiment, the contour encoding value of each position point is calculated based on the target contour point corresponding to the position point. Specifically, in response to the number of target contour points being less than a preset value, the contour encoding 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 encoding 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.
[0039] 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 enough 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 enough to form the circular contour of the pill, that is, the position point is the center point of the pill, and further, the variance of the Euclidean distance between all target contour points and the position point is calculated. If the variance of the Euclidean distance approaches 0, it means that the Euclidean distance from each target contour point to the position point is the same, and all target contour points are in the same circular contour. Therefore, the variance of the Euclidean distance can reflect the roundness of the pill; similarly, if the variance of the gradient value of each target contour point approaches 0, it means that the gradient feature of the edge of the pill is consistent, so the variance of the gradient value can reflect the consistency of the texture of the edge of the pill; the variance of the Euclidean distance and the sum of the variance of the gradient value are used as the contour encoding value of the position point.
[0040] In another embodiment, when a position point in the pill contour map can detect a complete circular contour, the number of target contour points corresponding to the 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 perimeter 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 perimeter, and the average perimeter is the perimeter of the circular contour with the average Euclidean distance between each target contour point and the position point as the radius.
[0041] Specifically, the location point The contour encoding value Satisfies the relationship: , For location point The number of target contour points, For each target contour point and position point The average Euclidean distance of For each target contour point and position point The variance of the Euclidean distance between For location point The variance of the gradient values of each target contour point.
[0042] In this way, the contour coding value of each position point in the pill contour map is obtained, and the contour coding value can reflect the roundness of the pill, the consistency of the edge texture and the contour integrity; the closer the contour coding value is to 0, the better the roundness of the pill, the more consistent the edge texture, and the more complete the pill contour.
[0043] S104, performing outlier detection on the contour coding value of each position point to obtain an abnormal value of each position point.
[0044] In one embodiment, one location point corresponds to one contour coding value, and an outlier detection is performed on the contour coding value of each location point using an anomaly detection algorithm, wherein the anomaly detection algorithm is a CBLOF algorithm, a LOF algorithm, or an isolation forest algorithm; in response to an outlier value of any location point being greater than a preset outlier value, an early warning is issued, and the preset outlier value is 0.5.
[0045] Among them, the LOF algorithm (Local Outlier Factor algorithm) is a density-based outlier detection algorithm; the CBLOF algorithm uses a clustering method to detect outliers based on the local outlier factor algorithm; the isolation forest algorithm is an anomaly detection algorithm based on a random binary tree, which uses the number of sample segmentation times to measure the degree of sample outliers; the CBLOF algorithm, LOF algorithm or isolation forest algorithm can assign an outlier value to each location point, and the larger the outlier value, the more abnormal the location point is.
[0046] S105, in response to an abnormal value at any position point being greater than a preset abnormal value, issuing an early warning.
[0047] In one embodiment, in response to an abnormal value of an arbitrary position point being greater than a preset abnormal value, the monitoring method further includes: marking a target contour point corresponding to the arbitrary position point as a defective area to obtain position information of the abnormal pill.
[0048] In this way, the positioning of abnormal pills is achieved, and pills with abnormal shapes can be removed based on their position information to ensure the quality of the pills.
[0049] Figure 3 FIG. 1 is a flow chart of a method for automatically monitoring pill production according to another embodiment of the present application. Figure 3 As shown, the automatic pill production monitoring method includes steps S201 to S205, wherein the implementation method of steps S201 to S203 is the same as the implementation method of steps S101 to S103, and the implementation method of step S205 is the same as the implementation method of step S105, which will not be repeated here, and only step S204 will be described in detail below.
[0050] S204, calculating the absolute value of the difference between the contour coding 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 coding value of each position point, and in response to the contour loss reaching the minimum value, performing outlier detection on the contour coding value of each position point to obtain the abnormal value of each position point.
[0051] In one embodiment, during the automatic production of pills, the occurrence of pill abnormalities is a low-probability event, that is, the shapes of most pills in the pill image are circular contours under normal circumstances. Therefore, under ideal conditions, the contour encoding values of most position points are equal and equal to the theoretical value, and the theoretical value is 0.
[0052] Calculate the absolute value of the difference between the contour encoding value and the theoretical value of each position point as the contour loss. for: ,in Pill outline drawing Middle point The contour encoding value of is a 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. The pill contour map can be updated by adjusting the model parameters, and then the contour encoding value of each position point can be updated; therefore, the abnormal value of each position point can be divided into two parts, the first is the abnormality caused by the insufficient accuracy of sub-pixel edge detection, and the second is the abnormality caused by the quality of the pill itself. The model parameters of the preset Gaussian model are adjusted multiple times. The model parameters include mean and variance. When the contour loss When the minimum value is reached, it means that the accuracy of sub-pixel edge detection is optimal, eliminating the influence of insufficient accuracy of sub-pixel edge detection on outliers, thereby ensuring the accuracy of outliers at each location point.
[0053] Among them, the model parameters of the preset Gaussian model can be adjusted multiple times using an optimization algorithm such as a hill climbing algorithm or an annealing simulation algorithm to obtain the outlier values of each position point when the accuracy of sub-pixel edge detection is optimal. When the model parameters of the preset Gaussian model are adjusted 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.
[0054] In this way, since the accuracy of sub-pixel edge detection directly affects the accuracy of the outliers at each position point, the present 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 outliers at each position point when the accuracy of sub-pixel edge detection reaches the optimal level, and then accurately judge the quality of the finished pills.
[0055] The technical principle and implementation details of the automatic production monitoring method of pills of the present application are introduced above through specific embodiments. Sub-pixel edge detection is performed on the pill image after production, and multiple contour points on the pill in the pill image are accurately located. The extension lines of each contour point are drawn along the gradient direction. Multiple extension lines will intersect at any 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 the position point; ideally, all target contour points of a position point can form a circular contour, so 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 are used as the contour coding value of each position point; outlier detection is performed on the contour coding value of each position point, and in response to the abnormal value of any position point being greater than the preset abnormal value, an early warning is issued to accurately judge the quality of the finished pill product, and monitor the production quality of the pills during the automatic production process of pills.
[0056] According to the second aspect of the present application, the present application also provides an automatic pill production monitoring system. Figure 4 is a structural block diagram of the automatic pill production monitoring system according to an embodiment of the present application. Figure 4 As 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, a method for automatically monitoring the production of pills according to the first aspect of the present application is implemented. The system also includes other components well known to those skilled in the art, such as a communication bus and a communication interface, whose settings and functions are known in the art, so they are not described here.
[0057] In the present application, the aforementioned memory may be any tangible medium containing or storing a program that can be used by or in combination 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 (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), 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 a device or accessible or connectable to a device. Any application or module described in this application may be implemented using computer-readable / executable instructions that may be stored or otherwise maintained by such a computer-readable medium.
[0058] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, 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, they should be considered to be within the scope of this specification.
[0059] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be construed as limiting the scope of the patent application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent application shall be subject to the attached 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