Tablet edge detection method and system based on cross-sectional information
By obtaining the two-dimensional image of the tablet and its depth information, the annular area to be detected at the edge of the tablet is extracted and expanded into one-dimensional cross-sectional information, the problem of difficult detection of the edge defect of the tablet is solved, and the rapid and accurate detection of the edge defect of the tablet is achieved, and the product quality is improved.
Patent Information
- Application Number
- CN202410748800.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-06-12
AI Technical Summary
The prior art is difficult to accurately detect the edge-bumping defects of the tablet, resulting in the product quality of the tablet production process being unable to be guaranteed.
By acquiring the two-dimensional image of the tablet and its depth information, the annular area to be detected at the edge of the tablet is extracted, and its depth information is expanded into one-dimensional cross-sectional information, and defect detection is performed based on the one-dimensional cross-sectional information.
It realizes rapid detection of the position, size and depth of the edge defects of the tablet, effectively solves the defect problem that is difficult to detect in the transition area of the surface to the side, and improves the product quality of the tablet production process.
Smart Images

Figure CN118608484B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of machine vision, and in particular to a method and system for detecting tablet edge cracks based on cross-sectional information. Background Art
[0002] Tablets are the most common drug dosage form. The Pharmacopoeia of the People's Republic of China (2020 Edition) stipulates that tablets should not have obvious scratches, cracks, or visible damage on their appearance. Tablet appearance defect detection is a critical link in the tablet production process, and the accuracy of the test results directly affects the quality of drug production.
[0003] When the defect is located at the edge of the tablet surface, due to its special location, it becomes a difficult point in the detection of tablet appearance defects. The existing visual inspection method usually uses a high-resolution camera to photograph the tablet surface, and then uses image processing algorithms or software to perform image segmentation, feature extraction and other methods for defect detection. However, since the tablet edge defect is located at the transition position of the front and side of the tablet, the traditional method has a series of problems such as difficulty in imaging and inability to extract defect feature information, which often leads to the inability to accurately detect this type of defect, thereby failing to guarantee the product quality of the tablet production process. Summary of the invention
[0004] In view of this, an object of the present invention is to provide a method and system for detecting tablet edge chipping based on cross-sectional information, so as to solve the problem that it is difficult to detect tablet edge chipping in the prior art.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions:
[0006] A tablet edge detection method based on cross-sectional information of the present invention comprises:
[0007] Obtaining a two-dimensional image of the tablet and depth information of each region of the two-dimensional image;
[0008] Extracting the to-be-detected annular region of the edge of the tablet in the two-dimensional image based on the depth information, and expanding the depth information of the to-be-detected annular region into one-dimensional cross-sectional information;
[0009] Defect detection of the tablet is performed based on the one-dimensional cross-sectional information.
[0010] In one embodiment of the present application, extracting the annular area to be detected of the edge of the tablet in the two-dimensional image based on the depth information includes:
[0011] Extracting the edge contour of the tablet based on the depth information of each area of the two-dimensional image;
[0012] Fitting the edge contour to obtain a standard circle that fits the outer edge of the tablet;
[0013] Interpolating multiple coordinate points in the edge contour to obtain the coordinates of each coordinate point in the standard circle;
[0014] The annular area to be detected is determined based on the coordinates of each pixel point in the standard circle, the center of the standard circle and pre-configured geometric parameters of the annular area to be detected.
[0015] In one embodiment of the present application, extracting the edge contour of the tablet based on the depth information of each area of the two-dimensional image includes:
[0016] The depth information of each area of the two-dimensional image is binarized based on a preset height threshold to obtain the edge contour of the tablet.
[0017] In one embodiment of the present application, interpolating multiple coordinate points in the edge contour to obtain the coordinates of each coordinate point in the standard circle includes:
[0018] Copy each pixel point and the coordinate value of each pixel point in the edge contour to the contour point set, and copy the starting pixel point and the coordinate value of the starting pixel point to the end pixel point in the contour point set to form a closed contour;
[0019] Interpolate any two adjacent pixel points in the contour point set to obtain the coordinates of each pixel point in the standard circle.
[0020] In one embodiment of the present application, the geometric parameters of the annular area to be detected include the shortest distance Dis between the edge of the standard circle and the outer ring of the annular area to be detected. start , the shortest distance Dis between the edge of the standard circle and the inner ring of the annular area to be detected end ;
[0021] Wherein, determining the annular area to be detected based on the coordinates of each pixel point in the standard circle, the center of the standard circle and the pre-configured geometric parameters of the annular area to be detected includes:
[0022] The outer ring coordinates Pt of the annular area to be detected are calculated based on the coordinates of each pixel point in the standard circle, the center of the standard circle and the pre-configured geometric parameters of the annular area to be detected. start And the inner ring coordinates Pt end , where the outer ring coordinates Pt start The mathematical expression is:
[0023] Pt start =mc+unitVec*Radius*Ratio start
[0024]
[0025] unitVec=(Pt i -mc) / norm(Pt i -mc)
[0026] The inner ring coordinate Pt start The mathematical expression is:
[0027] Pt end =mc+unitVec*Radius*Ratio end
[0028]
[0029] Where mc is the center of the standard circle, unitVec is the unit vector, and Pt of the standard circle is i is the i-th contour point, Radius is the radius of the standard circle, Ratio start is the first ratio, Reso_x is the resolution of the sensor in the x direction, and norm() is the vector modulus;
[0030] Based on the outer ring coordinates Pt of the annular area to be detected start And the inner ring coordinates Pt end The annular area to be detected is constructed.
[0031] In one embodiment of the present application, the depth information of the annular area to be detected is expanded into one-dimensional cross-sectional information, including:
[0032] Determine the lengths of multiple detection line segments of the annular area to be detected, wherein the detection line segments are line segments formed by the intersection of the radius line of the standard circle and the inner ring of the annular area to be detected and the outer ring of the annular area to be detected;
[0033] Setting a plurality of uniformly distributed sampling points on the plurality of detection line segments based on the lengths of the plurality of detection line segments, and acquiring height values of the plurality of sampling points;
[0034] Perform height interpolation on each sampling point of each detection line segment to obtain height interpolation of multiple sampling points;
[0035] Calculate the average of the height values of multiple sampling points and the height interpolation, and use the average as the height value of the corresponding detection line segment; construct one-dimensional section information based on the height values of multiple detection cables, wherein the one-dimensional section information includes multiple section points and the height values corresponding to the multiple section points.
[0036] In one embodiment of the present application, defect detection of a tablet is performed based on the one-dimensional cross-sectional information, including:
[0037] Traversing the one-dimensional cross-section information to obtain a maximum height value and a minimum height value;
[0038] When the difference between the maximum height and the minimum height is less than a preset first difference threshold, it is determined that the tablet does not have an edge defect; otherwise, the one-dimensional cross-sectional information is divided into a front half and a rear half, and a symmetry check is performed on the front half and the rear half;
[0039] When the front half and the rear half meet the symmetry verification rule, it is determined that the tablet does not have a knocked edge defect; otherwise, it is determined that the tablet has a knocked edge defect;
[0040] When the tablet has a chipped edge defect, the chipped edge position of the tablet is detected based on the one-dimensional cross-sectional information.
[0041] In one embodiment of the present application, the symmetry check of the first half and the second half includes:
[0042] Calculating the average height of the plurality of cross-sectional points in the front half and the average height of the plurality of cross-sectional points in the rear half;
[0043] Based on the pre-built detection window, slide along the one-dimensional cross-sectional information, each sliding unit step length, calculate the sum of the height values in the detection window during each sliding, and obtain multiple area height values A n , where n is the number of detection window sliding times;
[0044] In any three adjacent regions, the height value A n-1 , A n and A n+1 Satisfaction: A n-1 <A n >A n+1 , or satisfy: A n-1 >A n <A n+1 When the area height value A n The middle position of is taken as the regional extreme point;
[0045] When the following conditions are met at the same time: the difference between the number of regional extreme points in the front half and the number of regional extreme points in the back half is less than a preset second difference threshold, the window corresponding to any regional extreme point contains the center position of the one-dimensional cross-sectional information, and the difference between the average height value of the front half and the average height value of the back half is less than a preset third difference threshold, the front half and the back half are determined to comply with the symmetry verification rules; otherwise, the front half and the back half are determined to not comply with the symmetry verification rules.
[0046] In one embodiment of the present application, the edge position of the tablet is detected based on the one-dimensional cross-sectional information, including:
[0047] Calculate the first-order gradient value gradient(i) of the one-dimensional cross-sectional information. The mathematical expression of the first-order gradient value gradient(i) is:
[0048] gradient(i)=f(i+1)-f(i)
[0049] Where, f(i) is the height value of the i-th section point, and f(i+1) is the height value of the i+1-th section point;
[0050] When any two adjacent cross-sectional points satisfy: gradient(i) is within the preset gradient range, f(i) and f(i+1) are one positive and one negative, and the distance between cross-sectional points i and i+1 in the x-axis direction is less than the preset distance threshold, the positions of cross-sectional points i and i+1 are taken as defect positions;
[0051] The defect length is calculated based on the section point i and the section point i+1, and the defect depth is determined based on the edge height of the defect position and the center height of the defect position.
[0052] The present application also provides a tablet edge detection system based on cross-sectional information, which is characterized by comprising:
[0053] An acquisition module, used for acquiring a two-dimensional image of the tablet and depth information of each area of the two-dimensional image;
[0054] An extraction and conversion module, used for extracting the annular region to be detected of the edge of the tablet in the two-dimensional image based on the depth information, and expanding the depth information of the annular region to be detected into one-dimensional cross-sectional information;
[0055] A defect detection module is used to perform defect detection on the tablet based on the one-dimensional cross-sectional information.
[0056] The beneficial effects of the present invention are as follows: a tablet edge detection method and system based on cross-sectional information of the present invention obtains a two-dimensional image of the tablet and the depth information of each area of the two-dimensional image; extracts the annular area to be detected at the edge of the tablet in the two-dimensional image, and expands the depth information of the annular area to be detected into one-dimensional cross-sectional information; and performs defect detection on the tablet based on the one-dimensional cross-sectional information. The present application extracts the annular area to be detected at the edge of the tablet, and then expands the depth information of the annular area to be detected into one-dimensional cross-sectional information, which can quickly detect the location, size and depth of edge defects. The present application can effectively detect defects that are difficult to detect in the transition zone from the surface to the side, thereby improving the product quality of the tablet production process. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] The present invention will be further described below in conjunction with the accompanying drawings and embodiments:
[0058] Figure 1 A 2D image of a tablet with a chipped edge defect in one embodiment of the present application;
[0059] Figure 2 It is a flow chart of a tablet edge detection method based on cross-sectional information in one embodiment of the present invention;
[0060] Figure 3 Schematic diagram of the annular area to be detected in an embodiment of the present application Figure 1 ;
[0061] Figure 4 This is a schematic diagram of the outline of a tablet in an embodiment of the present application;
[0062] Figure 5 Schematic diagram of the annular area to be detected in one embodiment of the present application Figure 2 ;
[0063] Figure 6 is a schematic diagram of a detection line segment in an embodiment of the present application;
[0064] Figure 7 A schematic diagram of a one-dimensional cross-sectional information fitting curve in one embodiment of the present application;
[0065] Figure 8 This is a schematic diagram of a first-order gradient value in an embodiment of the present application;
[0066] Fig. 9 The structure diagram of a tablet edge detection system based on cross-sectional information in one embodiment of the present invention. DETAILED DESCRIPTION
[0067] The following describes the embodiments of the present invention by specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0068] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show the layers related to the present invention rather than being drawn according to the number, shape and size of the layers in actual implementation. In actual implementation, the type, quantity and proportion of each layer may be changed arbitrarily, and the layer layout may also be more complicated.
[0069] In the following description, numerous details are discussed to provide a more thorough explanation of embodiments of the present invention; however, it is apparent to one skilled in the art that embodiments of the present invention may be practiced without these specific details.
[0070] Figure 1 This is a 2D image of a tablet with a chipped edge defect in an embodiment of the present application, such as Figure 1 As shown, it can be seen that the defect features are not obvious in the 2D image and detection is difficult.
[0071] Figure 2 FIG. 1 is a flow chart of a method for detecting tablet edge cracks based on cross-sectional information in one embodiment of the present application. Figure 1 As shown, this application includes:
[0072] S210, obtaining a two-dimensional image of the tablet and depth information of each area of the two-dimensional image; in the present application, a 3D sensor is used to collect depth information of each area of the tablet.
[0073] S220, extracting a to-be-detected annular region of the edge of the tablet in the two-dimensional image based on the depth information, and expanding the depth information of the to-be-detected annular region into one-dimensional cross-sectional information;
[0074] Figure 3 Schematic diagram of the annular area to be detected in an embodiment of the present application Figure 1 , the annular area to be detected extracted by this application is as follows Figure 3 As shown, after obtaining the annular area to be detected, the present application expands the 3D height information of the annular edge area to be detected into 1D cross-sectional information, thereby intuitively obtaining the height values of various positions on the edge of the tablet.
[0075] S230, performing defect detection on the tablet based on the one-dimensional cross-sectional information.
[0076] After obtaining the height values of each position on the edge of the tablet, it is possible to confirm whether there is an abnormality in the cross section and confirm the defect location based on the abnormal value and the position of the abnormal point. Combined with the sensor parameters, the location and size physical information of the edge knock defect can be determined.
[0077] In one embodiment of the present application, extracting the annular area to be detected of the edge of the tablet in the two-dimensional image based on the depth information includes:
[0078] S2201, extracting the edge contour of the tablet based on the depth information of each area of the two-dimensional image;
[0079] In the present application, the depth information of each area of the two-dimensional image is binarized based on a preset height threshold to obtain the edge contour of the tablet.
[0080] Since the 3D sensor transmits the height information of the front view of the tablet to this process, the height difference between the tablet area and the background area should be large. An arbitrary effective height threshold can be set. If it is higher than this height, it is set to 255, and if it is lower than this height, it is set to 0.
[0081] Figure 4 Schematic diagram of the outline of a tablet in an embodiment of the present application, such as Figure 4 As shown, the contour of the above binary image is extracted, and the extraction result is as follows Figure 4 It can be seen that since the contour extraction is based on pixel-level accuracy, the jagged shape of the contour is obvious. In order to obtain 1D cross-sectional information with higher accuracy and smoother transition, it is necessary to use contour points to perform a tablet shape fitting.
[0082] S2202, fitting the edge contour to obtain a standard circle that fits the outer edge of the tablet;
[0083] In order to eliminate interference such as noise and deformation, this application fits all the extracted contour points. The RANSAC algorithm can be used for fitting, or the Hough circle search algorithm can be used directly to search for the tablet shape, or other methods can be used to locate the tablet shape. Regardless of the method used, this step ultimately determines a standard circle that fits the outer edge of the tablet.
[0084] S2203, interpolating multiple coordinate points in the edge contour to obtain the coordinates of each coordinate point in the standard circle;
[0085] Specifically include:
[0086] Step1. Copy each pixel point of the edge contour and the coordinate value of each pixel point to the contour point set contourPointsTemp, and copy the coordinates of the starting pixel point and the starting pixel point to the end pixel point in the contour point set contourPointsTemp to form a closed contour;
[0087] Step 2. Traverse each pair of adjacent points in contourPointsTemp, denoted as p1 and p2.
[0088] Step 3. Calculate the horizontal and vertical distances between p1 and p2, denoted as dx and dy respectively.
[0089] Step 4. Determine the number of interpolation steps, take the larger value of dx and dy as the number of steps, recorded as fSteps.
[0090] Step 5. Calculate the increments in the x and y directions for each step, recorded as xIncrement and yIncrement respectively.
[0091] Step 6. Initialize the starting point of the interpolation to the coordinates of p1, denoted as x and y.
[0092] Step 7. Use a loop to interpolate for a total of fSteps iterations. In each step, add the current interpolation point (x, y) to polygonPoints and update the values of x and y to increase by xIncrement and yIncrement respectively.
[0093] Step8. Return the interpolated polygon point set ploygonPoints.
[0094] S2204: Determine the annular area to be detected based on the coordinates of each pixel point in the standard circle, the center of the standard circle, and pre-configured geometric parameters of the annular area to be detected.
[0095] The geometric parameters of the annular area to be detected include the shortest distance Dis between the edge of the standard circle and the outer ring of the annular area to be detected star t, the shortest distance Dis between the edge of the standard circle and the inner ring of the annular area to be detected end ;
[0096] Wherein, determining the annular area to be detected based on the coordinates of each pixel point in the standard circle, the center of the standard circle and the pre-configured geometric parameters of the annular area to be detected includes:
[0097] S22041, calculating the outer ring coordinates Pt of the annular area to be detected based on the coordinates of each pixel point in the standard circle, the center of the standard circle and the pre-configured geometric parameters of the annular area to be detected start And the inner ring coordinates Pt end , where the outer ring coordinates Pt start The mathematical expression is:
[0098] Pt start =mc+unitVec*Radius*Ratio start
[0099]
[0100] unitVec=(Pt i -mc) / norm(Pt i -mc)
[0101] The inner ring coordinate Pt start The mathematical expression is:
[0102] Pt end =mc+unitVec*Radius*Ratioend
[0103]
[0104] Where mc is the center of the standard circle, unitVec is the unit vector, and Pt of the standard circle is i is the i-th contour point, Radius is the radius of the standard circle, Ratio start is the first ratio, Reso_x is the resolution of the sensor in the x direction, and norm() is the vector modulus;
[0105] S22042, based on the outer ring coordinates Pt of the annular area to be detected start And the inner ring coordinates Pt end The annular area to be detected is constructed.
[0106] Figure 5 Schematic diagram of the annular area to be detected in one embodiment of the present application Figure 2 , the annular area to be detected obtained after the above steps is as follows Figure 5 shown.
[0107] In one embodiment of the present application, the depth information of the annular area to be detected is expanded into one-dimensional cross-sectional information, including:
[0108] S2211, determining the lengths of multiple detection line segments of the annular area to be detected, wherein the detection line segments are line segments formed by the intersection of the radius line of the standard circle and the inner ring of the annular area to be detected and the outer ring of the annular area to be detected;
[0109] Figure 6 is a schematic diagram of a detection line segment in an embodiment of the present application, such as Figure 6 As shown, the starting point of the detection line segment is Pt start , the end point is Pt end .
[0110] S2212, setting a plurality of uniformly distributed sampling points on the plurality of detection line segments based on the lengths of the plurality of detection line segments, and obtaining height values of the plurality of sampling points;
[0111] S2213, performing height interpolation on each sampling point of each detection line segment to obtain height interpolation of multiple sampling points;
[0112] S2214, calculate the average value of the height values of multiple sampling points and the height interpolation, and use the average value as the height value of the corresponding detection line segment; construct one-dimensional cross-sectional information based on the height values of multiple detection cables, wherein the one-dimensional cross-sectional information includes multiple cross-sectional points and the height values corresponding to the multiple cross-sectional points.
[0113] In this embodiment, sampling points are generated based on the pixel length of the detection line segment. For example, if the length of the detection line segment is 5, 5 sampling points are evenly generated on the detection line segment. The depth value of each point is calculated using bilinear interpolation, and the depth values calculated after interpolation of the five points are averaged as the height value of the section at the current point. Therefore, the generated one-dimensional section information includes multiple section points and the height values corresponding to the multiple section points. Each section point corresponds to a position (angle).
[0114] In order to intuitively display the one-dimensional cross-sectional information, the present application fits the one-dimensional cross-sectional information and then filters it to obtain the one-dimensional cross-sectional information in the form of a curve. Figure 7 is a schematic diagram of a one-dimensional cross-sectional information fitting curve in an embodiment of the present application. The one-dimensional cross-sectional information in the form of a curve is as follows: Figure 7 shown.
[0115] In the previous article, the three-dimensional depth information is mapped to one-dimensional cross-sectional information. After a series of processing, including filtering and noise reduction, sampling, derivation, threshold filtering and other operations, the defect points are screened out. If there are no defect points, it is considered that there is no edge defect in the current detected tablet.
[0116] You can filter according to the preset window size, and you can choose any method such as 1D median filtering, 1D mean filtering, 1D Gaussian filtering, etc. to perform noise reduction. Figure 7 ,The cross-sectional image of the detection area after noise reduction is a relatively gentle curve, according to the characteristics of the curve such as the maximum and minimum values, including the absolute value of the extreme value, the steepness of the extreme value, the position of the extreme value, and other information.
[0117] Among them, the present application first determines the defects of the tablets based on the one-dimensional cross-sectional information, and then performs defect detection after determining the existence of defects. The defect determination methods include: 1. Determination of cross-sectional height difference; 2. Cross-sectional shape inspection (symmetry), and the specific process includes:
[0118] S311, traversing the one-dimensional cross-section information to obtain a maximum height and a minimum height;
[0119] S312, when the difference between the maximum height and the minimum height is less than a preset first difference threshold, it is determined that the tablet does not have an edge defect; otherwise, the one-dimensional cross-sectional information is divided into a front half and a rear half, and a symmetry check is performed on the front half and the rear half;
[0120] Steps S311 and S312 are to determine the cross-sectional height difference of the tablets. By calculating the global maximum and minimum values, traversing all cross-sectional points, obtaining the maximum and minimum values of all point heights, and calculating the difference between the maximum and minimum values, if it is less than the preset threshold, it means that the tablet does not have edge defects. If it is greater than the preset threshold, there may be defects for subsequent determination. Due to the interference of horizontal jumping and other interferences when acquiring 3D data of tablets, those less than the cross-sectional height difference threshold can only be determined as ok products, and those greater than the cross-sectional height difference threshold cannot be used as the determination condition for defective products.
[0121] S313, when the front half and the rear half meet the symmetry verification rule, it is determined that the tablet does not have a chipped edge defect; otherwise, it is determined that the tablet has a chipped edge defect;
[0122] Step S313 is to perform a cross-sectional shape test (symmetry) on the tablet. The cross-sectional symmetry includes shape (evaluated based on the regional extreme point characteristics) and height (average height, relative height, etc.). The cross section is divided into two parts, and the similarity between the front and back parts is determined, specifically including:
[0123] S3131, calculating the average height of the plurality of cross-section points in the first half and the average height of the plurality of cross-section points in the second half, that is, the average y coordinate of each point;
[0124] S3132, based on the pre-constructed detection window, slide along the one-dimensional cross-sectional information, each sliding unit step length, calculate the sum of the height values in the detection window during each sliding, and obtain multiple area height values A n , where n is the number of detection window sliding times;
[0125] S3133, in any three adjacent areas, the height value A n-1 , A n and A n+1 Satisfaction: A n-1 <A n >A n+1 , or satisfy: A n-1 >A n <A n+1 When the area height value A n The middle position of is taken as the regional extreme point;
[0126] Among them, the points whose height values are less than or greater than the left and right neighbors are defined as regional extreme points. First, set the detection window width wid, slide from left to right, and calculate the height sum in the area window. If the sum of the height in the current window is greater than the sum of the heights of the front and back windows or the sum of the height in the front window is less than the heights of the front and back windows, the middle position of this window is determined as the regional extreme point.
[0127] S3134: When the following conditions are met at the same time, it is determined that the first half and the second half meet the symmetry check rule; otherwise, it is determined that the first half and the second half do not meet the symmetry check rule:
[0128] (1) The difference between the number of regional extreme value points in the front half and the number of regional extreme value points in the rear half is less than a preset second difference threshold value; indicating that the number of regional extreme value points in the front and rear sections of the cross section is close: the total number of extreme values, the number of regional maximum values, and the number of regional minimum values allowed to differ can be selected based on the strictness of the judgment.
[0129] (2) The window corresponding to any regional extreme point contains the center position of the one-dimensional cross-section information; indicating that there is an extreme point at the center, and the window where one of all the extreme points is located contains the center position point of the entire cross-section.
[0130] (3) The difference between the average height value of the front half and the average height value of the rear half is less than a preset third difference threshold, indicating that the difference in height between the two sections (maximum value minus minimum value) meets the preset threshold.
[0131] If both the regional extreme point and the height symmetry meet the conditions, the cross section is considered to be symmetrical and there is no edge knock defect. Otherwise, it is considered that there is a defect and the subsequent defect detection process is carried out.
[0132] S314: When the tablet has a chipped edge defect, the chipped edge position of the tablet is detected based on the one-dimensional cross-sectional information.
[0133] The defect detection process includes:
[0134] S3141, calculating the first-order gradient value gradient(i) of the one-dimensional cross-section information, the mathematical expression of the first-order gradient value gradient(i) is:
[0135] gradient(i)=f(i+1)-f(i)
[0136] Where, f(i) is the height value of the i-th section point, and f(i+1) is the height value of the i+1-th section point;
[0137] S3142: When any two adjacent cross-sectional points satisfy the following conditions, the positions of cross-sectional points i and i+1 are taken as defect positions; the conditions include:
[0138] (1) gradient(i) is within the preset gradient range;
[0139] (2) f(i) and f(i+1) are one positive and one negative;
[0140] (3) When the distance between the section point i and the section point i+1 in the x-axis direction is less than the preset distance threshold.
[0141] Figure 8 is a schematic diagram of a first-order gradient value in an embodiment of the present application, such as Figure 8 As shown, the gradient value is between -0.005 and 0.005. The present application first selects the adjacent points whose absolute gradient values satisfy the preset threshold, and then performs the screening of (2) and (3).
[0142] S3143, calculating the defect length based on the section point i and the section point i+1, and determining the defect depth based on the edge height of the defect position and the center height of the defect position.
[0143] The two selected points are the locations (angles) of the defect edges, and the defect length is calculated based on their angles and angle difference. The defect depth is determined based on the height difference between the defect edge and the defect center.
[0144] The present invention provides a tablet edge detection method based on cross-sectional information, which obtains a two-dimensional image of the tablet and the depth information of each area of the two-dimensional image; extracts the annular area to be detected at the edge of the tablet in the two-dimensional image, and expands the depth information of the annular area to be detected into one-dimensional cross-sectional information; and performs defect detection on the tablet based on the one-dimensional cross-sectional information. The present application extracts the annular area to be detected at the edge of the tablet, and then expands the depth information of the annular area to be detected into one-dimensional cross-sectional information, which can quickly detect the location, size and depth of edge defects. The present application can effectively detect defects that are difficult to detect in the transition zone from the surface to the side, thereby improving the product quality of the tablet production process.
[0145] The present application also provides a tablet edge detection system based on cross-sectional information, which is characterized by comprising:
[0146] An acquisition module, used for acquiring a two-dimensional image of the tablet and depth information of each region of the two-dimensional image;
[0147] An extraction and conversion module, used for extracting the annular region to be detected of the edge of the tablet in the two-dimensional image based on the depth information, and expanding the depth information of the annular region to be detected into one-dimensional cross-sectional information;
[0148] A defect detection module is used to perform defect detection on the tablet based on the one-dimensional cross-sectional information.
[0149] The tablet edge detection system based on cross-sectional information of the present invention obtains a two-dimensional image of the tablet and the depth information of each area of the two-dimensional image; extracts the annular area to be detected at the edge of the tablet in the two-dimensional image, and expands the depth information of the annular area to be detected into one-dimensional cross-sectional information; and performs defect detection on the tablet based on the one-dimensional cross-sectional information. The present application extracts the annular area to be detected at the edge of the tablet, and then expands the depth information of the annular area to be detected into one-dimensional cross-sectional information, which can quickly detect the location, size and depth of edge defects. The present application can effectively detect defects that are difficult to detect in the transition zone from the surface to the side, thereby improving the product quality of the tablet production process.
[0150] This embodiment further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, any one of the methods in this embodiment is implemented, wherein the method is the execution logic of this system.
[0151] This embodiment also provides an electronic terminal, including: a processor and a memory;
[0152] The memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the terminal executes any one of the methods in this embodiment.
[0153] The computer-readable storage medium in this embodiment can be understood by ordinary technicians in this field: all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to the computer program. The aforementioned computer program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes.
[0154] The electronic terminal provided in this embodiment includes a processor, a memory, a transceiver and a communication interface. The memory and the communication interface are connected to the processor and the transceiver and complete communication with each other. The memory is used to store computer programs, the communication interface is used to communicate, and the processor and the transceiver are used to run computer programs so that the electronic terminal executes each step of the above method.
[0155] In this embodiment, the memory may include a random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0156] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0157] In the above-mentioned embodiments, although the present invention has been described in conjunction with the specific embodiments of the present invention, many replacements, modifications and variations of these embodiments will be apparent to those of ordinary skill in the art based on the foregoing description. The embodiments of the present invention are intended to cover all such replacements, modifications and variations falling within the broad scope of the appended claims.
[0158] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.
Claims
1. A tablet edge detection method based on cross-sectional information, characterized in that: Includes steps: Obtaining a two-dimensional image of the tablet and depth information of each region of the two-dimensional image; Extracting the to-be-detected annular region of the edge of the tablet in the two-dimensional image based on the depth information, and expanding the depth information of the to-be-detected annular region into one-dimensional cross-sectional information; Extracting the annular area to be detected at the edge of the tablet in the two-dimensional image based on the depth information, including: extracting the edge contour of the tablet based on the depth information of each area of the two-dimensional image; fitting the edge contour to obtain a standard circle that fits the outer edge of the tablet; interpolating multiple coordinate points in the edge contour to obtain the coordinates of each coordinate point in the standard circle; determining the annular area to be detected based on the coordinates of each pixel point in the standard circle, the center of the standard circle and the pre-configured geometric parameters of the annular area to be detected; the geometric parameters of the annular area to be detected include the shortest distance between the edge of the standard circle and the outer ring of the annular area to be detected , the shortest distance between the edge of the standard circle and the inner ring of the annular area to be detected ; wherein, determining the annular area to be detected based on the coordinates of each pixel point in the standard circle, the center of the standard circle and the pre-configured geometric parameters of the annular area to be detected comprises: calculating the outer ring coordinates of the annular area to be detected based on the coordinates of each pixel point in the standard circle, the center of the standard circle and the pre-configured geometric parameters of the annular area to be detected And the inner ring coordinates , where the outer ring coordinates The mathematical expression is: The inner ring coordinates The mathematical expression is: In the formula, is the center of the standard circle, is a unit vector, the standard circle For the contour points, is the radius of the standard circle, is the first ratio, For the sensor Directional resolution, The vector modulus is based on the outer ring coordinates of the annular area to be detected. And the inner ring coordinates Constructing the annular area to be detected; Defect detection of the tablet is performed based on the one-dimensional cross-sectional information.
2. According to the method for detecting tablet edge cracks based on cross-sectional information of claim 1, it is characterized in that: Extracting the edge contour of the tablet based on the depth information of each area of the two-dimensional image includes: The depth information of each area of the two-dimensional image is binarized based on a preset height threshold to obtain the edge contour of the tablet.
3. According to the method for detecting tablet edge cracks based on cross-sectional information of claim 1, it is characterized in that: Interpolating multiple coordinate points in the edge contour to obtain the coordinates of each coordinate point in the standard circle includes: Copy each pixel point and the coordinate value of each pixel point of the edge contour to the contour point set, and copy the starting pixel point and the coordinate value of the starting pixel point to the end pixel point in the contour point set to form a closed contour; Interpolate any two adjacent pixel points in the contour point set to obtain the coordinates of each pixel point in the standard circle.
4. According to claim 1, a tablet edge detection method based on cross-sectional information is characterized in that: Expanding the depth information of the annular area to be detected into one-dimensional cross-sectional information includes: Determine the lengths of multiple detection line segments of the annular area to be detected, wherein the detection line segments are line segments formed by the intersection of the radius line of the standard circle and the inner ring of the annular area to be detected and the outer ring of the annular area to be detected; Setting a plurality of uniformly distributed sampling points on the plurality of detection line segments based on the lengths of the plurality of detection line segments, and acquiring height values of the plurality of sampling points; Perform height interpolation on each sampling point of each detection line segment to obtain height interpolation of multiple sampling points; Calculate the average of the height values of multiple sampling points and the height interpolation, and use the average as the height value of the corresponding detection line segment; construct one-dimensional section information based on the height values of multiple detection cables, wherein the one-dimensional section information includes multiple section points and the height values corresponding to the multiple section points.
5. The tablet edge detection method based on cross-sectional information according to claim 4, characterized in that: Performing defect detection on the tablet based on the one-dimensional cross-sectional information includes: Traversing the one-dimensional cross-section information to obtain a maximum height value and a minimum height value; When the difference between the maximum height and the minimum height is less than a preset first difference threshold, it is determined that the tablet does not have an edge defect; otherwise, the one-dimensional cross-sectional information is divided into a front half and a rear half, and a symmetry check is performed on the front half and the rear half; When the front half and the rear half meet the symmetry verification rule, it is determined that the tablet does not have a knocked edge defect; otherwise, it is determined that the tablet has a knocked edge defect; When the tablet has a chipped edge defect, the chipped edge position of the tablet is detected based on the one-dimensional cross-sectional information.
6. The tablet edge detection method based on cross-sectional information according to claim 5, characterized in that: The first half and the second half are checked for symmetry, including: Calculating the average height of the plurality of cross-sectional points in the front half and the average height of the plurality of cross-sectional points in the rear half; Based on the pre-built detection window, slide along the one-dimensional cross-sectional information, each sliding unit step length, calculate the sum of the height values in the detection window during each sliding, and obtain multiple area height values ,in, The number of times the detection window slides; In any three adjacent regions, the height , and satisfy: and , or satisfy: and When the height value of the area The middle position of is taken as the regional extreme point; When the following conditions are met at the same time: the difference between the number of regional extreme points in the front half and the number of regional extreme points in the back half is less than a preset second difference threshold, the window corresponding to any regional extreme point contains the center position of the one-dimensional cross-sectional information, and the difference between the average height value of the front half and the average height value of the back half is less than a preset third difference threshold, the front half and the back half are determined to comply with the symmetry verification rules; otherwise, the front half and the back half are determined to not comply with the symmetry verification rules.
7. The tablet edge detection method based on cross-sectional information according to claim 6, characterized in that: Detecting the edge position of the tablet based on the one-dimensional cross-sectional information includes: Calculate the first-order gradient value of the one-dimensional cross-sectional information , the first-order gradient value The mathematical expression is: In the formula, For the The height value of each section point, For the The height value of each section point; At any two adjacent section points: Within the preset gradient range, and One is positive and the other is negative, the cross-sectional point and section points of When the axial distance is less than the preset distance threshold, the section point and section points The location is taken as the defect location; Based on section points and section points The defect length is calculated, and the defect depth is determined based on the edge height of the defect location and the center height of the defect location.
8. A tablet edge detection system based on cross-sectional information, characterized in that: include: An acquisition module, used for acquiring a two-dimensional image of the tablet and depth information of each region of the two-dimensional image; An extraction and conversion module, used for extracting the annular region to be detected of the edge of the tablet in the two-dimensional image based on the depth information, and expanding the depth information of the annular region to be detected into one-dimensional cross-sectional information; Extracting the annular area to be detected at the edge of the tablet in the two-dimensional image based on the depth information, including: extracting the edge contour of the tablet based on the depth information of each area of the two-dimensional image; fitting the edge contour to obtain a standard circle that fits the outer edge of the tablet; interpolating multiple coordinate points in the edge contour to obtain the coordinates of each coordinate point in the standard circle; determining the annular area to be detected based on the coordinates of each pixel point in the standard circle, the center of the standard circle and the pre-configured geometric parameters of the annular area to be detected; the geometric parameters of the annular area to be detected include the shortest distance between the edge of the standard circle and the outer ring of the annular area to be detected , the shortest distance between the edge of the standard circle and the inner ring of the annular area to be detected ; wherein, determining the annular area to be detected based on the coordinates of each pixel point in the standard circle, the center of the standard circle and the pre-configured geometric parameters of the annular area to be detected comprises: calculating the outer ring coordinates of the annular area to be detected based on the coordinates of each pixel point in the standard circle, the center of the standard circle and the pre-configured geometric parameters of the annular area to be detected And the inner ring coordinates , where the outer ring coordinates The mathematical expression is: The inner ring coordinates The mathematical expression is: In the formula, is the center of the standard circle, is a unit vector, the standard circle For the contour points, is the radius of the standard circle, is the first ratio, For the sensor Directional resolution, The vector modulus is based on the outer ring coordinates of the annular area to be detected. And the inner ring coordinates Constructing the annular area to be detected; A defect detection module is used to perform defect detection on the tablet based on the one-dimensional cross-sectional information.
Citation Information
Patent Citations
Vision-based method of detecting defects on end surface of bearing finished product
CN109187581A
Quadratic surface defect detection method, detection device, detection system and storage medium
CN117934369A