Capsule appearance defect intelligent detection method and system based on multi-angle visual acquisition
Patent Information
- Application Number
- CN202610720297.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-25
- Publication Date
- 2026-08-18
AI Technical Summary
[0005]本发明的目的在于提供基于多角度视觉采集的胶囊外观缺陷智能检测方法及系统,以解决现有检测方法对胶囊套合区的偏斜类缺陷漏检率高的问题
[0040] 1. The fitting defect features are extracted from the geometric relationships scattered among the acquired azimuth images and converted into a fitting deviation defect index that can quantitatively characterize the degree of fitting deviation, thus solving the problem that the existing image processing framework cannot effectively detect such defects.
Smart Images

Figure CN122597312A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of intelligent detection of appearance defects, and particularly relates to an intelligent detection method and system for the appearance defects of capsules based on multi-angle vision acquisition. Background Art
[0002] In the field of pharmaceutical production, the quality inspection of capsule dosage forms is a key link to ensure the safety of drug use. Capsules are usually composed of two parts, a cap and a body, which are sleeved together. During the high-speed filling production process, the cap-body sleeving process may cause the axis of the cap and the body to deviate due to mechanical alignment errors, component wear, or fluctuations in the size of the capsules themselves. Such skew defects not only affect the appearance qualification rate of the products, but more seriously, they will lead to a decrease in the sealing performance of the capsules, resulting in quality accidents such as moisture absorption, leakage, or microbial contamination of the contents, directly threatening the safety of patients' drug use. Therefore, accurate detection of appearance defects in the cap-body sleeving area of capsules has important significance for quality control.
[0003] Due to its particularity, the miss detection rate of the axis skew defect of the cap and body has always been high in the existing technical solutions, becoming the main bottleneck restricting the detection accuracy. The deep reason for this problem is that the sleeving skew is essentially a three-dimensional spatial structure deviation, and its projection performance on a two-dimensional image highly depends on the shooting angle. When the optical axis of the camera is exactly parallel or nearly parallel to the skew direction of the cap and body, the skew feature is almost invisible in the image, and the sleeving area presents as a normal annular band, resulting in defective samples being misjudged as qualified products. In addition, the capsules are in a high-speed moving state on the production line, and their own axes have random spatial attitude changes relative to the camera. Even if the capsules have a fixed skew, due to the superposition of attitude uncertainties, it is difficult for a single view or a limited number of views to stably capture and accurately calculate the true direction and degree of the skew. The existing detection algorithms lack effective means to reconstruct and quantify the skew spatial features from multi-view information, and are unable to form a reliable judgment on the sleeving skew defect in the face of information loss caused by unfavorable viewing angles and attitude interference. Summary of the Invention
[0004] (1) Technical Problems to be Solved
[0005] The purpose of the present invention is to provide an intelligent detection method and system for the appearance defects of capsules based on multi-angle vision acquisition, so as to solve the problem of high miss detection rate of skew defects in the sleeving area of capsules by the existing detection methods.
[0006] (2) Technical Solutions
[0007] To achieve the above purpose, on the one hand, the present invention provides an intelligent detection method for the appearance defects of capsules based on multi-angle vision acquisition, and the method includes:
[0008] Multiple lateral cameras were used to acquire images of the capsule cap and body fitting area, resulting in images of the fitting area corresponding to each acquisition azimuth angle.
[0009] Spatial pose correction is performed on the fitting area image to obtain a fitted area corrected image; contrast enhancement and noise reduction are performed on the fitting transition zone region in the fitted area corrected image to obtain a fitted area enhanced image.
[0010] The interlocking transition zone region in the enhanced image of the interlocking area is projected in grayscale along the capsule axis to identify the axial position value of the interlocking line; the positioning signal-to-noise ratio of the acquired azimuth angle is calculated.
[0011] The axial position values of the mating line corresponding to the acquired azimuth angles are arranged in the order of the acquired azimuth angles to construct a spatial angle domain sequence; the waveform feature analysis of the spatial angle domain sequence is performed based on the positioning signal-to-noise ratio to obtain the mating skew defect index.
[0012] The fitting misalignment defect is identified based on the fitting misalignment defect index and the preset fitting misalignment defect threshold.
[0013] Furthermore, the method for obtaining a corrected fitting area image by performing spatial pose correction on the fitting area image includes:
[0014] Obtain the contour edges of the capsule on the left and right sides of the fitting area image; perform straight line fitting on the contour edges of the capsule on the left and right sides to determine the direction of the capsule axis; calculate the angle between the direction of the capsule axis and the vertical direction of the fitting area image as the image plane rotation angle; perform rotation transformation on the fitting area image according to the image plane rotation angle to obtain the fitting area corrected image.
[0015] Obtain the top edge of the capsule cap in the corrected image of the fitting area; calculate the difference in axial pixel coordinates between the left and right sides of the top edge of the cap; using the nominal outer diameter in the capsule specifications as a reference, and combining the intrinsic parameters of the corresponding side camera, convert the difference in axial pixel coordinates into the spatial attitude deflection angle of the capsule axis relative to the optical axis of the corresponding side camera.
[0016] Based on the spatial attitude deflection angle, and taking the horizontal center column in the corrected image of the fitting area as a reference, the axial projection displacement of each column of pixels in the fitting transition zone is calculated; taking the axial coordinates of each column of pixels in the corrected image of the fitting area as a reference, the corrected axial coordinates are calculated based on the axial projection displacement; and the fitting transition zone is resampled based on the corrected axial coordinates to obtain the corrected image of the fitting area.
[0017] Furthermore, the method for identifying the axial position value of the fitting line by performing grayscale projection on the fitting transition zone region in the enhanced image of the fitting area along the capsule axis includes:
[0018] The average grayscale value of each row of pixels in the overlay transition zone region of the enhanced image of the overlay area is extracted along the direction perpendicular to the capsule axis, and the overlay transition zone region is compressed to obtain the axial grayscale distribution curve.
[0019] The cap-side baseline grayscale and body-side baseline grayscale are extracted from the axial grayscale distribution curve. Based on the mean grayscale values of the cap-side and body-side baselines, the axial grayscale distribution curve is normalized to obtain a normalized grayscale profile. A point-by-point first-order difference is calculated along the capsule axis of the normalized grayscale profile to obtain a normalized axial gradient sequence. The gradient extremum point with the largest absolute value in the normalized axial gradient sequence is selected. The axial pixel coordinates corresponding to the gradient extremum point are used as the gradient extremum coordinates. The gradient extremum coordinates are converted using the calibration parameters of the corresponding lateral camera to obtain the axial position value of the overlay line.
[0020] Furthermore, the method for calculating the positioning signal-to-noise ratio of the acquired azimuth angle includes:
[0021] The average grayscale value of each row of pixels in the overlay transition zone region of the enhanced image of the overlay area is extracted along the direction perpendicular to the capsule axis, and the overlay transition zone region is compressed to obtain the axial grayscale distribution curve.
[0022] The axial coordinate range corresponding to the overlay transition zone is determined based on the axial gray-level distribution curve; a gray-level monotonically abrupt change segment is extracted based on the axial coordinate range; the difference between the maximum and minimum gray-level values within the monotonically abrupt change segment is calculated as the overlay linear abrupt change variable; the standard deviation of all pixel gray-level values in the overlay transition zone region of the enhanced image of the overlay area is calculated as the region gray-level fluctuation; and the ratio of the overlay linear abrupt change variable to the region gray-level fluctuation is used as the localization signal-to-noise ratio.
[0023] Furthermore, the method for obtaining the fitting skew defect index by performing waveform feature analysis on the spatial angle domain sequence based on the positioning signal-to-noise ratio includes:
[0024] Using the positioning signal-to-noise ratio of each acquisition azimuth angle, a sine fit is performed on the spatial angle domain sequence to obtain the fitting amplitude and the fitting residual of each acquisition azimuth angle; the weighted root mean square of the residual is obtained by calculating the fitting residual of each acquisition azimuth angle.
[0025] The fitting skewness defect index is obtained by dividing the fitted amplitude by the sum of the residual weighted root mean square and the regularization constant. The regularization constant is determined by statistical analysis of the test results of known normal capsules.
[0026] Furthermore, the method for obtaining the fitting amplitude and the fitting residuals of each acquired azimuth angle by performing sinusoidal fitting on the spatial angle domain sequence includes:
[0027] A design matrix is constructed using the sine, cosine, and constant values of each acquired azimuth angle as columns. The positioning signal-to-noise ratio is used as the initial composite weight. The weighted least squares equations constructed by the design matrix and the axial position values of each fitting line in the spatial angle domain sequence are solved to obtain the sine component coefficients, cosine component coefficients, axial mean coefficients, and initial fitting residuals.
[0028] The residual amplitude threshold is determined based on the fitting band width in the capsule specifications. For acquisition azimuth angles where the absolute value of the initial fitted residual does not exceed the residual amplitude threshold, the initial composite weight remains unchanged. For acquisition azimuth angles where the absolute value of the initial fitted residual exceeds the residual amplitude threshold, the initial composite weight is multiplied by the ratio of the residual amplitude threshold to the absolute value of the initial fitted residual to obtain the updated composite weight. The weighted least squares equations are re-solved based on the updated composite weight to obtain the updated sine component coefficients, cosine component coefficients, axial mean coefficients, and fitted residual. The process of updating the composite weight and solving the weighted least squares equations is repeated until the sine component coefficients, cosine component coefficients, and axial mean coefficients converge.
[0029] The arithmetic square root of the sum of the squares of the converged sine and cosine component coefficients is used to obtain the fitting amplitude. The fitting residual is obtained by subtracting the sum of the product of the converged sine component coefficient and the corresponding sine value of the azimuth angle, the product of the cosine component coefficient and the corresponding cosine value of the azimuth angle, and the axial mean coefficient from the axial position value of the fitting line corresponding to each acquisition azimuth angle.
[0030] Furthermore, the method for determining the residual amplitude threshold includes:
[0031] Select the acquisition azimuth angle where the absolute value of the fitted residual is lower than the residual amplitude threshold used in the current update; construct a normal residual set from the fitted residuals corresponding to the selected acquisition azimuth angle; calculate the standard deviation of each fitted residual in the normal residual set as the measurement noise estimate for the current update; and take the square root of the product of the measurement noise estimate and the width of the fitting band in the capsule specification parameters as the residual amplitude threshold used in the next update.
[0032] Based on the same inventive concept, this invention also provides an intelligent detection system for capsule appearance defects based on multi-angle visual acquisition, the system comprising:
[0033] The image acquisition module is used to acquire images of the capsule cap and body fitting area using multiple lateral cameras, and obtain images of the fitting area corresponding to each acquisition azimuth angle.
[0034] The image preprocessing module is used to perform spatial pose correction on the fitting area image to obtain a fitted area corrected image; and to perform contrast enhancement and noise reduction on the fitting transition zone region in the fitted area corrected image to obtain a fitted area enhanced image.
[0035] The fitting position calculation module is used to perform grayscale projection on the fitting transition zone region in the enhanced image of the fitting area along the capsule axis, identify the axial position value of the fitting line, and calculate the positioning signal-to-noise ratio of the acquired azimuth angle.
[0036] The fitting defect analysis module is used to construct a spatial angle domain sequence by arranging the axial position values of the fitting line corresponding to the acquired azimuth angles in the order of the acquired azimuth angles; and to obtain the fitting skew defect index by performing waveform feature analysis on the spatial angle domain sequence based on the positioning signal-to-noise ratio.
[0037] The fitting defect identification module is used to identify fitting misalignment defects based on the fitting misalignment defect index and the preset fitting misalignment defect threshold.
[0038] (3) Beneficial effects
[0039] Compared with the prior art, the beneficial effects of the present invention are:
[0040] 1. The fitting defect features are extracted from the geometric relationships scattered among the acquired azimuth images and converted into a fitting deviation defect index that can quantitatively characterize the degree of fitting deviation, thus solving the problem that the existing image processing framework cannot effectively detect such defects.
[0041] 2. The quality of each acquired azimuth image is measured by the positioning signal-to-noise ratio and included in the analysis weight. Combined with the iterative weight update mechanism driven by the fitting tape width constraint, the interference of local abnormal acquisition azimuth angles is suppressed, so that the fitting misalignment defect index can still accurately reflect the degree of fitting misalignment under the condition of multi-source error on the production line. Attached Figure Description
[0042] Figure 1 This is a flowchart of the intelligent detection method for capsule appearance defects based on multi-angle visual acquisition according to Embodiment 1 of the present invention;
[0043] Figure 2 This is a schematic diagram of the module composition of the intelligent capsule appearance defect detection system based on multi-angle visual acquisition according to Embodiment 2 of the present invention. Detailed Implementation
[0044] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0045] Before providing examples, it is necessary to describe the application scenarios of this invention. This invention is applicable to online inspection of the two-stage hard capsules used in this invention. As each capsule passes through the acquisition station, multiple lateral cameras evenly arranged circumferentially acquire images of the mating area from different acquisition angles.
[0046] Example 1: As Figure 1 As shown, this embodiment provides an intelligent detection method for capsule appearance defects based on multi-angle visual acquisition. The method includes:
[0047] S1. Multiple lateral cameras are used to acquire images of the capsule cap and body fitting area, and images of the fitting area corresponding to each acquisition azimuth angle are obtained.
[0048] S2. Perform spatial pose correction on the fitting area image to obtain a fitted area corrected image; perform contrast enhancement and noise reduction processing on the fitting transition zone region in the fitted area corrected image to obtain a fitted area enhanced image.
[0049] S3. Project grayscale onto the interlocking transition zone region in the enhanced image of the interlocking area along the capsule axis to identify the axial position value of the interlocking line; calculate the positioning signal-to-noise ratio of the acquired azimuth angle.
[0050] S4. Arrange the axial position values of the mating line corresponding to the acquired azimuth angles in the order of the acquired azimuth angles to construct a spatial angle domain sequence; perform waveform feature analysis on the spatial angle domain sequence based on the positioning signal-to-noise ratio to obtain the mating deviation defect index.
[0051] S5. Identify the fitting misalignment defect based on the fitting misalignment defect index and the preset fitting misalignment defect threshold.
[0052] For example, eight lateral cameras are evenly arranged along the circumference of the capsule, with a 45° azimuth interval between adjacent cameras. The optical axes of each camera point towards the capsule's axis, and the focal plane covers the axial range of the fitting area. As the capsule passes the acquisition station, a synchronous trigger signal output by the encoder simultaneously drives the eight lateral cameras to complete exposure, resulting in eight images of the fitting area, corresponding to eight acquisition azimuth angles: 0°, 45°, 90°, 135°, 180°, 225°, 270°, and 315°. The pose parameters of each lateral camera and the capsule's specifications are pre-calibrated using a calibration plate and a standard capsule of known dimensions after installation. The calibration results are stored in the form of intrinsic parameter matrices, extrinsic parameter matrices, and distortion coefficients for future use.
[0053] Synchronous triggering is used instead of time-division triggering because the capsule is in motion within the transmission mechanism. Time-division triggering would cause inconsistencies in the axial position of the capsule during the acquisition of each image, making the axial position values of the overlay line corresponding to each acquisition azimuth angle incomparable and unable to form an effective spatial angle domain sequence.
[0054] The overlay area image was sequentially rotated and corrected using perspective projection to obtain a corrected overlay area image. The overlay transition zone region in the corrected overlay area image was then subjected to contrast enhancement and denoising to obtain an enhanced overlay area image. The ratio of the overlay linear jump variable to the regional grayscale fluctuation was extracted from the enhanced overlay area image and used as the positioning signal-to-noise ratio (SNR) for each acquisition azimuth angle. The positioning SNRs for the eight acquisition azimuth angles were 7.25, 6.83, 7.41, 1.28, 6.92, 7.15, 6.78, and 7.03, respectively. In the enhanced image of the overlay area, the first-order difference is calculated point by point on the normalized grayscale profile. The axial pixel coordinates corresponding to the gradient extremum points are taken as the gradient extremum coordinates. After conversion by calibration parameters, the axial position values of the overlay line corresponding to each acquisition azimuth angle are obtained. The axial position values of the overlay line corresponding to the eight acquisition azimuth angles are 3.50mm, 3.80mm, 3.80mm, 3.70mm, 3.27mm, 3.03mm, 3.00mm, and 3.15mm, respectively.
[0055] The axial position values of the mating lines corresponding to the eight acquired azimuth angles were arranged in order of the acquired azimuth angles to form a spatial angle domain sequence. A sine fit was performed on the spatial angle domain sequence based on the positioning signal-to-noise ratio to obtain the fitting amplitude and the fitting residual for each acquired azimuth angle. The fitting amplitude was 0.44 mm, the weighted root mean square residual was 0.024 mm, and the regularization constant was 0.03 mm. The calculated mating misalignment defect index was 8.1, exceeding the preset mating misalignment defect threshold of 2.0, thus indicating the presence of a mating misalignment defect. The axial position values of the eight mating lines corresponding to a normal capsule were between 3.38 mm and 3.42 mm, with a fitting amplitude of 0.02 mm and a mating misalignment defect index of 0.33, which was lower than the preset mating misalignment defect threshold of 2.0, thus indicating a normal capsule. The preset misalignment defect threshold is determined by statistically analyzing the misalignment defect index distribution of known normal capsule batches and known misaligned defect capsule batches, and taking the midpoint between the mean index of normal capsules plus three standard deviations and the mean index of misaligned defect capsules minus three standard deviations. In this embodiment, the mean misalignment defect index of normal capsule batches is 0.38 and the standard deviation is 0.15, while the mean index of misaligned defect batches is 11.2 and the standard deviation is 2.1. Taking the midpoint, the preset misalignment defect threshold is 2.0.
[0056] The method for obtaining a corrected image of the fitting area by performing spatial pose correction on the fitting area image includes:
[0057] Obtain the contour edges of the capsule on the left and right sides of the fitting area image; perform straight line fitting on the contour edges of the capsule on the left and right sides to determine the direction of the capsule axis; calculate the angle between the direction of the capsule axis and the vertical direction of the fitting area image as the image plane rotation angle; perform rotation transformation on the fitting area image according to the image plane rotation angle to obtain the fitting area corrected image.
[0058] Obtain the top edge of the capsule cap in the corrected image of the fitting area; calculate the difference in axial pixel coordinates between the left and right sides of the top edge of the cap; using the nominal outer diameter in the capsule specifications as a reference, and combining the intrinsic parameters of the corresponding side camera, convert the difference in axial pixel coordinates into the spatial attitude deflection angle of the capsule axis relative to the optical axis of the corresponding side camera.
[0059] Based on the spatial attitude deflection angle, and taking the horizontal center column in the corrected image of the fitting area as a reference, the axial projection displacement of each column of pixels in the fitting transition zone is calculated; taking the axial coordinates of each column of pixels in the corrected image of the fitting area as a reference, the corrected axial coordinates are calculated based on the axial projection displacement; and the fitting transition zone is resampled based on the corrected axial coordinates to obtain the corrected image of the fitting area.
[0060] For example, for eight lateral cameras evenly arranged along the circumference of the capsule, the image plane rotation angle of each camera is measured and stored in the configuration file during the calibration phase. During runtime, the corresponding rotation angle parameter is read according to the camera acquisition azimuth angle of the currently acquired image, and rotation transformation is performed independently on each overlay area image to obtain the overlay area corrected image corresponding to each acquisition azimuth angle.
[0061] Taking the image of the overlay area acquired by a lateral camera at a 0° azimuth angle as an example, the Canny operator is used to extract the edge point sets of the capsule's left and right contours. Straight lines are fitted to the edge point sets on both sides, and the average slope of the two straight lines is used to calculate the direction of the capsule's axis, resulting in an image plane rotation angle of 1.2°. Using the image center as the rotation center, the overlay area image is rotated by 1.2° to obtain the corrected image of the overlay area. The image plane rotation angles for the other seven acquisition azimuth angles are -0.8°, 1.5°, -1.1°, 0.9°, -1.3°, 1.0°, and -0.7°, respectively, and each undergoes an independent rotation transformation.
[0062] The capsule specifications are a nominal outer diameter of 7.64 mm and a cap length of 19.40 mm. In the aligned image of the fitting area, if the capsule axis is strictly perpendicular to the optical axis, the top edge of the cap should be a horizontal straight line, and the ratio of the pixel distance from the cap tip to the fitting transition zone to the nominal cap length should be equal to the pixel equivalent of the side camera. In the actual image, the difference in pixel row coordinates between the left and right sides of the top edge of the cap tip is 3 pixels.
[0063] The spatial attitude deflection angle is directly calculated from the geometric relationship of the top edge of the cap in the corrected image of the fitting area. The nominal outer diameter is located in the horizontal direction of the capsule diameter in the corrected image of the fitting area. =7.64mm, the difference in axial coordinates between the left and right sides of the top edge of the cap. =3 pixels corresponds to axial displacement =3×0.080=0.240mm, from which the spatial attitude deflection angle is obtained; spatial attitude deflection angle ;in, This represents the difference in axial pixel coordinates between the left and right sides of the top edge of the cap. In pixel equivalents, The nominal outer diameter of the capsule is given. The spatial attitude deflection angle is obtained. It is 1.8°. The cap length in the capsule specifications... To verify calibration consistency, the axial pixel distance from the top edge of the cap to the center of the overlay transition zone in the overlay zone calibration image should be consistent with... Consistent (in this embodiment) =19.40mm, =19.40 / 0.080=242 pixels, the actual measured axial pixel distance is 244 pixels, the error is within the calibration accuracy range). If the deviation is too large, it indicates that the calibration parameters or specification parameters are abnormal.
[0064] The axial projection displacement of each column of pixels in the overlay transition zone is calculated based on a 1.8° spatial attitude deflection angle and the intrinsic parameters of the lateral camera. Using the horizontal center column of the image as a reference, the displacements on the left and right sides are anti-symmetrical about the center column. The maximum axial projection displacement occurs in the leftmost and rightmost columns of the image, which is 2.3 pixels in this embodiment. For each column of pixels in the overlay transition zone region of the corrected image, the corrected axial coordinates are obtained by adding the corresponding axial projection displacement to the current axial coordinates of that column. For example, the 160th pixel on the left side of the horizontal center column has an axial projection displacement of -2.3 pixels, the original axial coordinate is row 242, and the corrected axial coordinate is row 239.7. Similarly, the 160th pixel on the right side of the horizontal center column has an axial projection displacement of +2.3 pixels, and the corrected axial coordinate is row 244.3. Since the corrected axial coordinates are usually not integer pixel row positions, bilinear interpolation is used to resample the corrected image of the overlay area along the axial direction. The gray value at the corrected coordinate position is calculated by interpolation and assigned to the corresponding pixel position in the corrected image. After resampling all 320 columns of pixels in the overlay transition zone region, the corrected image of the overlay area is obtained. The size of the corrected image of the overlay area is the same as that of the overlay transition zone region in the corrected image of the overlay area, which is 320 columns × 18 rows. The gray values of each column of pixels have been corrected by the axial coordinates, eliminating the projection distortion of the axial position of the overlay line caused by the 1.8° spatial attitude deflection of the capsule axis relative to the optical axis of the side camera. The corrected images of the overlay area at the other 7 acquisition azimuth angles are independently processed with the same correction according to their respective spatial attitude deflection angles. The spatial attitude deflection angle of each acquisition azimuth angle is calculated by the intrinsic parameters of the corresponding side camera and the difference in axial pixel coordinates of the top edge of the cap.
[0065] The method for identifying the axial position value of the fitting line by performing grayscale projection of the fitting transition zone region in the enhanced image of the fitting area along the capsule axis includes:
[0066] The average gray value of each row of pixels in the interlocking transition zone region of the enhanced image of the interlocking area is extracted along the direction perpendicular to the capsule axis, and the interlocking transition zone region is compressed to obtain the axial gray value distribution curve.
[0067] The cap-side baseline grayscale and body-side baseline grayscale are extracted from the axial grayscale distribution curve. Based on the mean grayscale values of the cap-side and body-side baselines, the axial grayscale distribution curve is normalized to obtain a normalized grayscale profile. A point-by-point first-order difference is calculated along the capsule axis of the normalized grayscale profile to obtain a normalized axial gradient sequence. The gradient extremum point with the largest absolute value in the normalized axial gradient sequence is selected. The axial pixel coordinates corresponding to the gradient extremum point are used as the gradient extremum coordinates. The gradient extremum coordinates are converted using the calibration parameters of the corresponding lateral camera to obtain the axial position value of the overlay line.
[0068] For example, for multiple enhanced images of the same capsule's overlapping area, the grayscale values of the cap-side baseline and the body-side baseline differ due to varying illumination conditions at each acquisition azimuth. In this embodiment, the mean grayscale values of the cap-side baseline and the body-side baseline are extracted independently for each acquisition azimuth and normalized separately to ensure consistency in the extraction of the axial position values of the overlapping line at each acquisition azimuth. For instance, in the 0° acquisition azimuth image, the mean grayscale value of the cap-side baseline is 163, and the mean grayscale value of the body-side baseline is 76; while in the 90° acquisition azimuth image, due to different illumination directions, the mean grayscale value of the cap-side baseline is 158, and the mean grayscale value of the body-side baseline is 72. After independent normalization, the extraction of the gradient extremum coordinates is unaffected by illumination differences.
[0069] After row-mean compression of the overlay transition zone region in the enhanced image of the overlay area, an axial gray-level distribution curve of length 18 is obtained. Subscripts 1 to 6 correspond to the cap wall region, subscripts 7 to 14 correspond to the overlay transition zone, and subscripts 15 to 18 correspond to the body wall region. The gray-level average values of three pixels (subscripts 4 to 6) in the neighborhood of the cap side are taken, and the gray-level values at these three locations are 164, 163, and 162, respectively. The gray-level average value of the cap side baseline is 163. The gray-level average values of three pixels (subscripts 15 to 17) in the neighborhood of the body side are taken, and the gray-level values at these three locations are 76, 75, and 76, respectively. The gray-level average value of the body side baseline is 76.
[0070] The baselines on both sides of the cap differ by 87 gray levels. This difference stems from slight variations in the injection molding process parameters between the cap and the body, resulting in different reflectivities on the two side walls. If the gray-weighted centroid is calculated directly from the original gray-scale profile, it will be biased towards the darker gray side, producing a positioning deviation of the same magnitude as the fitting misalignment defect signal. Normalization involves subtracting the average gray value of the cap side baseline (163) from the gray values at each axial coordinate of the axial gray-scale distribution curve, and then dividing by the absolute value of the difference between the average gray values of the body side baseline (76) and the average gray value of the cap side baseline (163) (87). This normalizes the corresponding values of the cap side baseline to zero and the corresponding values of the body side baseline to one. The gray values within the fitting transition zone then monotonically change between 0 and 1, independent of batch differences in reflectivity of the two side walls and variations in illumination. The purpose of taking three pixel positions for each of the hat-side and body-side neighborhoods instead of a single pixel position is to average out the impact of random noise from individual pixels on the baseline estimation. The neighborhood positions are selected outside the axial coordinate range of the overlay transition zone to ensure that the baseline grayscale mean reflects the grayscale of the flat areas of the hat wall and body wall, and to avoid the abrupt grayscale changes in the overlay transition zone from being mixed into the baseline estimation.
[0071] Point-by-point first-order difference was calculated for a normalized grayscale profile of length 18, resulting in a normalized axial gradient sequence of length 17. The difference value at index 9 is -0.31, which has the largest absolute value in the entire gradient sequence. Index 9 is taken as the gradient extremum point, and the corresponding axial pixel coordinate 9 is the gradient extremum coordinate of the overlay transition zone. After conversion using the calibration parameters of the 0° acquisition azimuth angle lateral camera, the corresponding axial position value of the overlay line in the physical coordinate system is 3.82mm. Each acquisition azimuth angle was independently converted using the calibration parameters of its respective camera, and the end face of the capsule cap was used as a unified reference zero point to obtain the axial position value of the overlay line.
[0072] It should be noted that if the weighted centroid is directly calculated from the original gray values of subscripts 7 to 14, the weighted centroid coordinates are 8.6, which differs from the gradient extreme point coordinates 9 by 0.4 pixels, corresponding to a physical distance of about 0.06 mm. This is on the same order of magnitude as the difference in the axial position value of the fitting line caused by the fitting misalignment defect, which is sufficient to interfere with the sinusoidal fitting result of the spatial angle domain sequence.
[0073] The method for calculating the positioning signal-to-noise ratio of the acquired azimuth angle includes:
[0074] The average grayscale value of each row of pixels in the overlay transition zone region of the enhanced image of the overlay area is extracted along the direction perpendicular to the capsule axis, and the overlay transition zone region is compressed to obtain the axial grayscale distribution curve.
[0075] The axial coordinate range corresponding to the overlay transition zone is determined based on the axial gray-level distribution curve; a gray-level monotonically abrupt change segment is extracted based on the axial coordinate range; the difference between the maximum and minimum gray-level values within the monotonically abrupt change segment is calculated as the overlay linear abrupt change variable; the standard deviation of all pixel gray-level values in the overlay transition zone region of the enhanced image of the overlay area is calculated as the region gray-level fluctuation; and the ratio of the overlay linear abrupt change variable to the region gray-level fluctuation is used as the localization signal-to-noise ratio.
[0076] For example, the overlay transition zone region corresponds to an axial range of 18 pixels in rows and a horizontal range of 320 pixels in columns in the overlay region enhanced image. The average grayscale values of the 320 pixels in each of the 18 rows are taken to obtain an axial grayscale distribution curve of length 18. Row grayscale averaging compression concentrates the grayscale information of the two-dimensional region into the axial direction and smooths out the systematic brightness gradient in the horizontal direction caused by the curvature of the capsule surface, ensuring that subsequent transition segment extraction is performed only on a one-dimensional sequence.
[0077] The field of view of the image acquisition of the fitting area has been pre-aligned with the axial range of the fitting transition zone. In the axial gray-scale distribution curve, the axial coordinate range corresponding to the fitting transition zone is determined according to the continuous change range of gray value monotonically decreasing from the cap side to the body side. The axial coordinate range corresponding to the fitting transition zone is determined (in this embodiment, it is subscript 7 to 14, a total of 8 positions).
[0078] The overlapping transition zone corresponds to eight positions on the axial grayscale distribution curve, from index 7 to index 14. The grayscale values from index 7 to index 12 monotonically decrease from 162 to 75. Within the monotonically changing transition segment, the maximum grayscale value is 162 and the minimum is 75, with an overlapping linear jump of 87 grayscale levels. The standard deviation of the grayscale values for all 5760 pixels (18 rows × 320 columns) in the overlapping transition zone region is 12 grayscale levels, which is used as the region's grayscale fluctuation. This regional grayscale fluctuation is taken from all two-dimensional pixels in the overlapping transition zone region of the enhanced image, rather than the axial grayscale distribution curve after compression of the row grayscale mean. The localization signal-to-noise ratio is 7.25, calculated as 87 divided by 12.
[0079] The ratio of the overlay line jump variable to the regional grayscale fluctuation is used as the positioning signal-to-noise ratio instead of directly using the overall contrast ratio. This is because the overlay transition zone is a narrow-band jump structure with an axial width of only 0.2 to 0.5 mm. Flat grayscale areas of the cap wall and body wall dominate the overall region, diluting the overall contrast. Even with uneven production line lighting, the overall contrast may still be high, but the jump boundary at the overlay line is blurred, and the positioning accuracy of the gradient extremum coordinates decreases. The ratio of the overlay line jump variable to the regional grayscale fluctuation is high when the overlay line is clear and low when the overlay line is blurred or occluded, providing a more direct correlation with the reliability of the gradient extremum coordinates. For example, with an azimuth image acquired at 225°, the overlay line jump variable is 23 gray levels, the regional grayscale fluctuation is 18 gray levels, and the positioning signal-to-noise ratio is 1.28, which is lower than the 7.25 ratio acquired at 0° azimuth.
[0080] The method for obtaining the fitting skew defect index by performing waveform feature analysis on the spatial angle domain sequence based on the positioning signal-to-noise ratio includes:
[0081] Using the positioning signal-to-noise ratio of each acquisition azimuth angle, a sine fit is performed on the spatial angle domain sequence to obtain the fitting amplitude and the fitting residual of each acquisition azimuth angle; the weighted root mean square of the residual is obtained by calculating the fitting residual of each acquisition azimuth angle.
[0082] The fitting skewness defect index is obtained by dividing the fitted amplitude by the sum of the residual weighted root mean square and the regularization constant. The regularization constant is determined by statistical analysis of the test results of known normal capsules.
[0083] For example, the physical mechanism of the fitting misalignment defect is that there is a spatial angle between the cap axis and the body axis, causing the fitting line to change from a horizontal circular ring to a spatially inclined curve. The axial position of the fitting line at each acquisition azimuth angle exhibits a sinusoidal distribution along the circumference. A sinusoidal fitting model is selected as... ,in, For the first The axial position value of the fitting line corresponding to each acquisition azimuth angle, and the sinusoidal component coefficient. Cosine component coefficients Both are multiplied by the sine column of the design matrix. and cosine series Fitted amplitude The physical meaning is the projection amplitude of the cap tilt angle onto the axial position value of the fitting line. Using the axial position values of the fitting line corresponding to eight acquired azimuth angles (3.50mm, 3.80mm, 3.80mm, 3.70mm, 3.27mm, 3.03mm, 3.00mm, 3.15mm) and positioning signal-to-noise ratios (7.25, 6.83, 7.41, 1.28, 6.92, 7.15, 6.78, 7.03) as input, the weighted linear equation system is solved to obtain... =0.43mm =0.11mm =3.40mm, Fitted amplitude =0.44mm, and the absolute value of the fitting residual corresponding to each azimuth angle is less than 0.08mm.
[0084] The formula for calculating the weighted root mean square of the residuals is: ,in, To determine the signal-to-noise ratio; For the first The fitting residuals for each acquired azimuth angle. The positioning signal-to-noise ratio (SNR) is used instead of the equal-weighted root mean square (RMS) because acquired azimuth angles with poor image quality generally have larger fitting residuals; equal-weighting would artificially inflate the weighted RMS of the residuals. The resulting weighted RMS of the residuals is... =0.024mm.
[0085] Otting skew defect index Add a regularization constant. The reason lies in the normal capsule fitting amplitude Approaching zero, if directly with As an index of fitting misalignment defects, when the measurement noise is extremely low It is also close to zero, and the exponent will become numerically unstable as the denominator approaches zero. Regularization constant. The regularization constant in this embodiment is determined by statistically analyzing the test results of known normal capsules and taking the mean of the weighted root mean square of the residuals of each capsule. =0.03mm, weighted root mean square of residuals =0.024mm, Fitted amplitude =0.44mm, yielding the capsule fitting misalignment defect index. The value is 8.1. For a normal capsule from the same batch, the axial position values of the eight fitting lines range from 3.38 mm to 3.42 mm, and the fitted amplitude is... =0.02mm, weighted root mean square of residuals =0.03mm, fitting misalignment defect index It is 0.33.
[0086] The method for obtaining the fitting amplitude and fitting residuals of each acquired azimuth angle by sinusoidal fitting of the spatial angle domain sequence includes:
[0087] A design matrix is constructed using the sine, cosine, and constant values of each acquired azimuth angle as columns. The positioning signal-to-noise ratio is used as the initial composite weight. The weighted least squares equations constructed by the design matrix and the axial position values of each fitting line in the spatial angle domain sequence are solved to obtain the sine component coefficients, cosine component coefficients, axial mean coefficients, and initial fitting residuals.
[0088] The residual amplitude threshold is determined based on the fitting band width in the capsule specifications. For acquisition azimuth angles where the absolute value of the initial fitted residual does not exceed the residual amplitude threshold, the initial composite weight remains unchanged. For acquisition azimuth angles where the absolute value of the initial fitted residual exceeds the residual amplitude threshold, the initial composite weight is multiplied by the ratio of the residual amplitude threshold to the absolute value of the initial fitted residual to obtain the updated composite weight. The weighted least squares equations are re-solved based on the updated composite weight to obtain the updated sine component coefficients, cosine component coefficients, axial mean coefficients, and fitted residual. The process of updating the composite weight and solving the weighted least squares equations is repeated until the sine component coefficients, cosine component coefficients, and axial mean coefficients converge.
[0089] The arithmetic square root of the sum of the squares of the converged sine and cosine component coefficients is used to obtain the fitting amplitude. The fitting residual is obtained by subtracting the sum of the product of the converged sine component coefficient and the corresponding sine value of the azimuth angle, the product of the cosine component coefficient and the corresponding cosine value of the azimuth angle, and the axial mean coefficient from the axial position value of the fitting line corresponding to each acquisition azimuth angle.
[0090] For example, a sinusoidal fitting model Expand as , to nonlinear parameters , Transform into linear parameters , This ensures that the weighted least squares problem has an analytical closed-form solution. An 8×3 design matrix X is constructed using the sine, cosine, and constant terms of the eight acquisition azimuth angles (0°, 45°, 90°, 135°, 180°, 225°, 270°, and 315°). An initial diagonal weight matrix is constructed using the positioning signal-to-noise ratio. Solve ,in, For the solution vector ; This is the axial position value vector of the fitting line. The initial sinusoidal component system is obtained. =0.43mm, initial cosine component coefficient =0.11mm, initial axial mean coefficient =3.40mm, and the initial fitting residuals corresponding to each acquisition azimuth angle are -0.01mm, 0.02mm, -0.03mm, 0.07mm, -0.02mm, 0.01mm, 0.03mm, and -0.02mm, respectively.
[0091] The residual amplitude threshold is determined by the overlay width, because the magnitude of the fitting residual for any normal acquisition azimuth should not exceed the overlay width; any excess must originate from an abnormal acquisition azimuth. In this embodiment, the overlay width is 1.20 mm, and the initial residual amplitude threshold is 0.60 mm. All eight initial fitting residual absolute values are below 0.60 mm, and the composite weights for each acquisition azimuth remain unchanged, resulting in convergence after one update. If a certain acquisition azimuth is offset by 0.80 mm due to local pressure damage at the cap end, and the absolute value of the fitting residual for the acquisition azimuth exceeds the residual amplitude threshold, the composite weight is multiplied by 0.60 / 0.80 = 0.75, continuously reducing the influence of the acquisition azimuth on amplitude estimation in subsequent iterations. The update convergence criterion is that the absolute value of the difference between the fitting amplitudes obtained from two adjacent updates is below a predetermined accuracy threshold (0.001 mm in this embodiment), or the number of iterations reaches a preset upper limit (20 times in this embodiment).
[0092] Fitted amplitude = =0.44mm. Taking a 0° azimuth angle as an example, the product of the sinusoidal component coefficient and the corresponding sine value of the azimuth angle is... =0mm, the product of the cosine component coefficient and the corresponding cosine value of the acquired azimuth angle is =0.11mm, the sum of the three is 0 + 0.11 + 3.40 = 3.51mm, the axial position value of the fitting line is 3.50mm, and the fitting residual is 3.50 - 3.51 = -0.01mm. The axial position values of the fitting line corresponding to the 8 acquisition azimuth angles are 3.50mm, 3.80mm, 3.80mm, 3.70mm, 3.27mm, 3.03mm, 3.00mm, and 3.15mm, respectively, and the corresponding fitting residuals are -0.01mm, 0.02mm, -0.03mm, 0.07mm, -0.02mm, 0.01mm, 0.03mm, and -0.02mm, respectively.
[0093] It should be noted that when the capsule shell has ellipticity, the axial position of the fitting line along the circumference also includes a frequency component with a period of half a circle, which is twice the frequency of the acquired azimuth angle. At this time, the harmonic basis function values of the sine fitting also include double-angle sine and double-angle cosine values; the design matrix also includes double-angle sine and double-angle cosine value columns; the sine component coefficients, cosine component coefficients, second harmonic sine component coefficients, second harmonic cosine component coefficients, and axial mean coefficients are obtained by solving; the fundamental frequency fitting amplitude is obtained by taking the square root of the sum of the squares of the sine component coefficients and the cosine component coefficients, which is used to calculate the fitting skew defect index.
[0094] The method for determining the residual amplitude threshold includes:
[0095] Select the acquisition azimuth angle where the absolute value of the fitted residual is lower than the residual amplitude threshold used in the current update; construct a normal residual set from the fitted residuals corresponding to the selected acquisition azimuth angle; calculate the standard deviation of each fitted residual in the normal residual set as the measurement noise estimate for the current update; and take the square root of the product of the measurement noise estimate and the width of the fitting band in the capsule specification parameters as the residual amplitude threshold used in the next update.
[0096] For example, the initial residual amplitude threshold is 1.20 / 2 = 0.60 mm. The absolute values of all eight initial fitted residuals in the first iteration are below 0.60 mm, and all are included in the initial normal residual set. The standard deviation of the eight fitted residuals is calculated to obtain the measurement noise estimate for the first iteration. =0.031mm. Using half the width of the fitting tape as the initial residual amplitude threshold provides a conservative set of normal acquisition azimuth angles under the condition of no prior noise estimation, ensuring that the noise estimate of the first measurement is not contaminated by anomalies.
[0097] The formula for updating the residual amplitude threshold is as follows: ,in, This refers to the width of the fitting tape; Let be the number of iterations. Take the geometric mean of the measurement noise level and the overlay width. When the measurement noise is extremely low, the residual amplitude threshold shrinks towards the overlay width; when the measurement noise is high, the threshold shrinks towards the noise level, with the two balancing in magnitude. Substituting, we get... = =0.193mm. The normal residual set was redefined using 0.193mm. The maximum absolute value of the eight fitted residuals was 0.07mm, all below 0.193mm. The second iteration measured the noise estimate. =0.031mm, residual amplitude threshold =0.193mm, the absolute value of the difference between the residual amplitude thresholds of two adjacent iterations is 0, which is less than 1% of the width of the overlay band (i.e., 0.012mm), satisfying the convergence criterion. The iteration converges, and the residual amplitude threshold is determined to be 0.193mm. The convergence criterion for the residual amplitude threshold is that the absolute value of the difference between the residual amplitude thresholds of two adjacent iterations is less than 1% of the width of the overlay band, or the number of iterations reaches a preset upper limit (10 times in this embodiment).
[0098] Furthermore, the adaptive mechanism is further illustrated using the case of locally anomalous acquisition azimuth angles. If a 180° acquisition azimuth angle experiences local pressure damage at the cap end, causing the initial fitting residual to be 0.52 mm, which is below the initial residual amplitude threshold of 0.60 mm, it enters the initial normal residual set, leading to... The residual amplitude threshold was raised to 0.18 mm after the first update. =0.465mm. When re-defined at 0.465mm, 0.52mm exceeds the threshold, and the 180° acquired azimuth angle is excluded from the normal residual set. The residual amplitude threshold was reduced to 0.031 mm, and the 180° acquisition azimuth angle was suppressed in the composite weight update.
[0099] Example 2: Based on the same inventive concept, such as Figure 2 As shown, this embodiment also provides an intelligent detection system for capsule appearance defects based on multi-angle visual acquisition, including:
[0100] The image acquisition module is used to acquire images of the capsule cap and body fitting area using multiple lateral cameras, and obtain images of the fitting area corresponding to each acquisition azimuth angle.
[0101] The image preprocessing module is used to perform spatial pose correction on the fitting area image to obtain a fitted area corrected image; and to perform contrast enhancement and noise reduction on the fitting transition zone region in the fitted area corrected image to obtain a fitted area enhanced image.
[0102] The fitting position calculation module is used to perform grayscale projection on the fitting transition zone region in the enhanced image of the fitting area along the capsule axis, identify the axial position value of the fitting line, and calculate the positioning signal-to-noise ratio of the acquired azimuth angle.
[0103] The fitting defect analysis module is used to construct a spatial angle domain sequence by arranging the axial position values of the fitting line corresponding to the acquired azimuth angles in the order of the acquired azimuth angles; and to obtain the fitting skew defect index by performing waveform feature analysis on the spatial angle domain sequence based on the positioning signal-to-noise ratio.
[0104] The fitting defect identification module is used to identify fitting misalignment defects based on the fitting misalignment defect index and the preset fitting misalignment defect threshold.
[0105] It should be noted that the specific ways in which each module performs operations in the system described in the above embodiments have been described in detail in the embodiments related to the method, and will not be elaborated here.
[0106] Finally, it should be noted that although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for intelligent detection of capsule appearance defects based on multi-angle visual acquisition, characterized in that, The method includes: Multiple side cameras were used to acquire images of the capsule cap and body fitting area, and images of the fitting area corresponding to each acquisition azimuth angle were obtained. Spatial pose correction is performed on the fitting area image to obtain a fitted area corrected image; contrast enhancement and noise reduction processing are performed on the fitting transition zone region in the fitted area corrected image to obtain a fitted area enhanced image; The interlocking transition zone region in the enhanced image of the interlocking area is projected in grayscale along the capsule axis to identify the axial position value of the interlocking line; the positioning signal-to-noise ratio of the acquired azimuth angle is calculated. Arrange the axial position values of the mating line corresponding to the acquired azimuth angles in order of the acquired azimuth angles to construct a spatial angle domain sequence; perform waveform feature analysis on the spatial angle domain sequence based on the positioning signal-to-noise ratio to obtain the mating skew defect index; The fitting misalignment defect is identified based on the fitting misalignment defect index and the preset fitting misalignment defect threshold.
2. The intelligent detection method for capsule appearance defects based on multi-angle visual acquisition according to claim 1, characterized in that, The method for obtaining a corrected image of the fitting area by performing spatial pose correction on the fitting area image includes: Obtain the contour edges of the capsule on the left and right sides of the fitting area image; perform straight line fitting on the contour edges of the capsule on the left and right sides to determine the direction of the capsule axis; calculate the angle between the direction of the capsule axis and the vertical direction of the fitting area image as the image plane rotation angle; perform rotation transformation on the fitting area image according to the image plane rotation angle to obtain the fitting area corrected image; Obtain the top edge of the capsule cap in the corrected image of the fitting area; calculate the difference in axial pixel coordinates between the left and right sides of the top edge of the cap; using the nominal outer diameter in the capsule specification parameters as a reference, and combining the internal parameters of the corresponding side camera, convert the difference in axial pixel coordinates into the spatial attitude deflection angle of the capsule axis relative to the optical axis of the corresponding side camera; Based on the spatial attitude deflection angle, and taking the horizontal center column in the corrected image of the fitting area as a reference, the axial projection displacement of each column of pixels in the fitting transition zone is calculated; taking the axial coordinates of each column of pixels in the corrected image of the fitting area as a reference, the corrected axial coordinates are calculated based on the axial projection displacement; and the fitting transition zone is resampled based on the corrected axial coordinates to obtain the corrected image of the fitting area.
3. The intelligent detection method for capsule appearance defects based on multi-angle visual acquisition according to claim 1, characterized in that, The method for identifying the axial position value of the fitting line by performing grayscale projection of the fitting transition zone region in the enhanced image of the fitting area along the capsule axis includes: The average gray value of each row of pixels in the interlocking transition zone region of the enhanced image of the interlocking area is extracted along the direction perpendicular to the capsule axis, and the interlocking transition zone region is compressed to obtain the axial gray value distribution curve. The cap-side baseline grayscale and body-side baseline grayscale are extracted from the axial grayscale distribution curve. Based on the mean grayscale values of the cap-side and body-side baselines, the axial grayscale distribution curve is normalized to obtain a normalized grayscale profile. A point-by-point first-order difference is calculated along the capsule axis of the normalized grayscale profile to obtain a normalized axial gradient sequence. The gradient extremum point with the largest absolute value in the normalized axial gradient sequence is selected. The axial pixel coordinates corresponding to the gradient extremum point are used as the gradient extremum coordinates. The gradient extremum coordinates are converted using the calibration parameters of the corresponding lateral camera to obtain the axial position value of the overlay line.
4. The intelligent detection method for capsule appearance defects based on multi-angle visual acquisition according to claim 1, characterized in that, The method for calculating the positioning signal-to-noise ratio of the acquired azimuth angle includes: The average gray value of each row of pixels in the interlocking transition zone region of the enhanced image of the interlocking area is extracted along the direction perpendicular to the capsule axis, and the interlocking transition zone region is compressed to obtain the axial gray value distribution curve. The axial coordinate range corresponding to the overlay transition zone is determined based on the axial gray-level distribution curve; a gray-level monotonically abrupt change segment is extracted based on the axial coordinate range; the difference between the maximum and minimum gray-level values within the monotonically abrupt change segment is calculated as the overlay linear abrupt change variable; the standard deviation of all pixel gray-level values in the overlay transition zone region of the enhanced image of the overlay area is calculated as the region gray-level fluctuation; and the ratio of the overlay linear abrupt change variable to the region gray-level fluctuation is used as the localization signal-to-noise ratio.
5. The intelligent detection method for capsule appearance defects based on multi-angle visual acquisition according to claim 1, characterized in that, The method for obtaining the fitting skew defect index by performing waveform feature analysis on the spatial angle domain sequence based on the positioning signal-to-noise ratio includes: Using the positioning signal-to-noise ratio of each acquisition azimuth angle, a sine fit is performed on the spatial angle domain sequence to obtain the fitting amplitude and the fitting residual of each acquisition azimuth angle; the weighted root mean square of the residual is calculated by calculating the fitting residual of each acquisition azimuth angle. The fitting skewness defect index is obtained by dividing the fitted amplitude by the sum of the residual weighted root mean square and the regularization constant. The regularization constant is determined by statistical analysis of the test results of known normal capsules.
6. The intelligent detection method for capsule appearance defects based on multi-angle visual acquisition according to claim 5, characterized in that, The method for obtaining the fitting amplitude and fitting residuals of each acquired azimuth angle by sinusoidal fitting of the spatial angle domain sequence includes: A design matrix is constructed using the sine, cosine, and constant values of each acquired azimuth angle as columns; the positioning signal-to-noise ratio is used as the initial composite weight, and the weighted least squares equations constructed by the design matrix and the axial position values of each fitting line in the spatial angle domain sequence are solved to obtain the sine component coefficients, cosine component coefficients, axial mean coefficients, and initial fitting residuals. The residual amplitude threshold is determined based on the fitting band width in the capsule specifications. For acquisition azimuth angles where the absolute value of the initial fitted residual does not exceed the residual amplitude threshold, the initial composite weight remains unchanged. For acquisition azimuth angles where the absolute value of the initial fitted residual exceeds the residual amplitude threshold, the initial composite weight is multiplied by the ratio of the residual amplitude threshold to the absolute value of the initial fitted residual to obtain the updated composite weight. The weighted least squares equations are re-solved based on the updated composite weight to obtain the updated sine component coefficients, cosine component coefficients, axial mean coefficients, and fitted residual. The process of updating the composite weight and solving the weighted least squares equations is repeated until the sine component coefficients, cosine component coefficients, and axial mean coefficients converge. The arithmetic square root of the sum of the squares of the converged sine and cosine component coefficients is used to obtain the fitting amplitude. The fitting residual is obtained by subtracting the sum of the product of the converged sine component coefficient and the corresponding sine value of the azimuth angle, the product of the cosine component coefficient and the corresponding cosine value of the azimuth angle, and the axial mean coefficient from the axial position value of the fitting line corresponding to each acquisition azimuth angle.
7. The intelligent detection method for capsule appearance defects based on multi-angle visual acquisition according to claim 6, characterized in that, The method for determining the residual amplitude threshold includes: Select the acquisition azimuth angle where the absolute value of the fitted residual is lower than the residual amplitude threshold used in the current update; construct a normal residual set from the fitted residuals corresponding to the selected acquisition azimuth angle; calculate the standard deviation of each fitted residual in the normal residual set as the measurement noise estimate for the current update; and take the square root of the product of the measurement noise estimate and the width of the fitting band in the capsule specification parameters as the residual amplitude threshold used in the next update.
8. A capsule appearance defect intelligent detection system based on multi-angle visual acquisition, used for performing the method described in any one of claims 1 to 7, characterized in that, The system includes: The image acquisition module is used to acquire images of the capsule cap and body fitting area using multiple side cameras, and obtain the fitting area image corresponding to each acquisition azimuth angle; The image preprocessing module is used to perform spatial pose correction on the overlay area image to obtain an overlay area corrected image; and to perform contrast enhancement and noise reduction on the overlay transition zone region in the overlay area corrected image to obtain an overlay area enhanced image. The fitting position calculation module is used to perform grayscale projection on the fitting transition zone region in the enhanced image of the fitting area along the capsule axis, identify the axial position value of the fitting line, and calculate the positioning signal-to-noise ratio of the acquired azimuth angle; The fitting defect analysis module is used to construct a spatial angle domain sequence by arranging the axial position values of the fitting line corresponding to the acquired azimuth angles in the order of the acquired azimuth angles; and to obtain the fitting skew defect index by performing waveform feature analysis on the spatial angle domain sequence based on the positioning signal-to-noise ratio. The fitting defect identification module is used to identify fitting misalignment defects based on the fitting misalignment defect index and the preset fitting misalignment defect threshold.