A method and system for automatically detecting defects in printing of a hose based on image processing

CN122597295APending Publication Date: 2026-08-18GUANGZHOU HONGZHI PACKAGING MATERIALS CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202610695552.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-20
Publication Date
2026-08-18

AI Technical Summary

Technical Problem

[0003]现有技术CN110308156A公开了一种基于标准模板比对的检测系统,对套印不准等规则性缺陷具有一定检测效果,但未考虑软管弧面成像产生的几何形变,直接比对导致误报率升高;现有技术CN114494265B公开了一种利用形变度加权进行模板匹配的方法,部分解决了曲面形变下的匹配问题,但其形变度计算流程复杂,且对离散墨点、细微划痕等局部随机性缺陷灵敏度不足;现有技术CN117274176B公开了一种基于改进YOLOv5s模型的有监督深度学习检测方法,其性能高度依赖大规模多样化缺陷样本,而在实际生产中此类样本收集标注困难,模型对未知缺陷泛化能力较弱

Benefits of technology

1)双通道协同架构通过自适应曲面展平与无监督异常重构的互补机制,实现了对规则性缺陷与随机性缺陷的全面覆盖检测。传统视觉通道通过构建软管弧形曲面模型并计算形变场,将畸变图像展平为平面校正图像,经亚像素级配准后与标准模板逐像素比对,基于噪声统计模型生成第一缺陷置信图,有效分离了曲面形变与真实缺陷的差异响应,解决了直接比对误报率高的问题。深度学习通道利用仅由无缺陷样本训练的轻量级重构网络,将待检测图像强制映射至正常纹理流形进行重构,通过计算重构图像与原始图像的结构相似性差异生成第二缺陷置信图,灵敏捕获各类形态随机的异常纹理。两条通道在功能上互补,使系统对套印不准、偏色等全局性缺陷和墨点、划痕等局部随机性缺陷均能有效检出,消除了单一技术路线的检测盲区。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122597295A_ABST
    Figure CN122597295A_ABST
Patent Text Reader

Abstract

The present application relates to a kind of based on image processing hose printing defect automatic detection method and system, belong to the field of graphic data reading.The method includes: obtaining image to be detected and parallel distribution to traditional visual channel and deep learning channel.Traditional visual channel corrects image by adaptive curved surface flattening, and generates first defect confidence map by registration comparison with standard template;Deep learning channel generates reconstruction image using lightweight reconstruction network trained only by defect-free sample, and generates second defect confidence map by structural similarity comparison.Two-channel confidence map is fused at pixel level by bayesian decision, generates comprehensive defect confidence map and completes defect discrimination.The present application effectively overcomes curved surface deformation interference through double-channel collaborative architecture, covers the comprehensive detection of regularity and randomness defects, while significantly reducing the dependence of deep learning model on defect training samples.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of graphic data reading technology, specifically relating to an automatic detection method and system for printing defects in flexible tubes based on image processing. Background Technology

[0002] Composite flexible tubes, as an important packaging container, rely heavily on the printing quality of their surface, which is a key element of product appearance and brand image. However, due to the flexibility of the flexible tube substrate and the complexity of the printing process, various printing defects are easily generated during production, seriously affecting product quality. Current detection technologies for printing defects still have shortcomings.

[0003] Existing technology CN110308156A discloses a detection system based on standard template comparison, which has a certain detection effect on regular defects such as misregistration, but does not consider the geometric deformation caused by the curved surface imaging of the flexible tube, and direct comparison leads to an increased false alarm rate. Existing technology CN114494265B discloses a template matching method using deformation degree weighting, which partially solves the matching problem under curved surface deformation, but its deformation degree calculation process is complex and its sensitivity to local random defects such as discrete ink spots and fine scratches is insufficient. Existing technology CN117274176B discloses a supervised deep learning detection method based on an improved YOLOv5s model, whose performance is highly dependent on a large-scale and diverse number of defect samples. However, in actual production, it is difficult to collect and label such samples, and the model has a weak ability to generalize to unknown defects.

[0004] In summary, existing technologies struggle to simultaneously overcome interference from surface deformation, sensitively detect various random defects, and reduce reliance on defect samples. An innovative detection solution capable of addressing these multi-dimensional issues is urgently needed. Summary of the Invention

[0005] The purpose of this invention is to provide an automatic detection method and system for printing defects in flexible tubes based on image processing to solve the above-mentioned problems in the prior art. The specific technical solution is as follows: An automatic detection method for printing defects in flexible tubes based on image processing includes the following steps: Acquire an image of the surface of the printed material on the flexible tube to be inspected; The image to be detected is input into a pre-constructed traditional visual detection channel and a deep learning detection channel, respectively. In the traditional visual inspection channel, the image to be inspected is adaptively flattened and registered with a standard template. By comparing the registered image with the standard template at the pixel level grayscale difference, a first defect confidence map is generated. In the deep learning detection channel, a pre-trained lightweight reconstruction network is used to reconstruct the image to be detected, generating a corresponding reconstructed image. A second defect confidence map is generated by calculating the structural difference between the reconstructed image and the image to be detected. The lightweight reconstruction network is trained only on defect-free qualified hose printing sample images. The first defect confidence map and the second defect confidence map are fused pixel-level based on Bayesian decision to generate a comprehensive defect confidence map; Based on the comprehensive defect confidence map, it is determined whether there are defects on the surface of the printed tube to be inspected, and the defect area is located when defects are present.

[0006] As a preferred embodiment of this application, the adaptive surface flattening and standard template registration of the image to be detected includes: extracting the edge contour of the hose in the image to be detected; calculating the radius of curvature of the arc at each cross-section and interpolating it based on the visual width of the hose at each cross-section of the image and the known circumference of the hose to obtain the continuous surface equation; constructing a deformation field from the coordinates of the original distorted image to the coordinates of the corrected planar image based on the continuous surface equation; and using the deformation field to nonlinearly flatten the image to be detected into a planar corrected image through an interpolation algorithm; and performing sub-pixel level registration based on feature matching and iterative optimization with the pre-stored defect-free standard printing template to obtain an aligned image for the pixel-level grayscale difference comparison.

[0007] As a preferred embodiment of this application, the lightweight reconstruction network is a convolutional neural network based on an autoencoder structure, in which depth-separable convolutional modules are used in the encoder and decoder instead of standard convolutional modules; the training process of the lightweight reconstruction network includes: using defect-free qualified hose printing sample images as both input and training targets of the network, updating the network weights by minimizing the mean square error loss function between the reconstructed image and the input image, so that the lightweight reconstruction network learns the normal pattern distribution of the defect-free hose printing texture.

[0008] As a preferred embodiment of this application, the step of performing pixel-level fusion of the first defect confidence map and the second defect confidence map based on Bayesian decision to generate a comprehensive defect confidence map includes: obtaining a first conditional probability parameter representing the reliability of the traditional visual detection channel and a second conditional probability parameter representing the reliability of the deep learning detection channel; reading the first probability value in the first defect confidence map and the second probability value in the second defect confidence map pixel by pixel; performing fusion calculation based on the Bayesian inference framework using the first conditional probability parameter, the second conditional probability parameter, the first probability value, and the second probability value to obtain the posterior probability value of the pixel having a defect; and combining the posterior probability values ​​of all pixels to generate an initial comprehensive defect confidence map.

[0009] As a preferred embodiment of this application, after generating the initial integrated defect confidence map, the method further includes: performing median filtering and morphological closing operations on the initial integrated defect confidence map in sequence to remove isolated noise points and connect adjacent defect regions to obtain the final integrated defect confidence map.

[0010] As a preferred embodiment of this application, the step of determining whether there is a defect on the surface of the printed hose to be inspected based on the comprehensive defect confidence map includes: binarizing the comprehensive defect confidence map with a preset judgment threshold to generate a binary image; performing connected component analysis on the binary image and filtering out connected components with an area smaller than a preset minimum area threshold; if connected components still exist after filtering, it is determined that there is a defect, otherwise it is determined that there is no defect.

[0011] This application also provides an automatic detection system for printing defects in flexible tubes based on image processing, including: The image acquisition module is used to acquire the image of the surface of the printed tubing to be inspected. Traditional visual inspection modules are configured to adaptively flatten the image to be inspected and register it with a standard template. By comparing the registered image with the standard template at the pixel level grayscale difference, a first defect confidence map is generated. The deep learning detection module internally loads a lightweight reconstruction network trained only on defect-free qualified hose printing sample images. It is configured to use the lightweight reconstruction network to reconstruct the image to be detected, generate a reconstructed image, and generate a second defect confidence map by calculating the structural difference between the reconstructed image and the image to be detected. The collaborative fusion module is configured to receive the first defect confidence map and the second defect confidence map, perform pixel-level fusion based on Bayesian decision to generate a comprehensive defect confidence map, and determine and locate defects based on the comprehensive defect confidence map.

[0012] As a preferred embodiment of this application, the conventional visual inspection module includes: a surface flattening unit, used to extract the edge of the hose in the image to be inspected, calculate the radius of curvature based on the visual width of each cross section and the known circumference of the hose and interpolate to obtain the continuous surface equation, calculate the deformation field and flatten the image to be inspected into a planar corrected image through an interpolation algorithm; a template registration unit, used to perform sub-pixel level registration of the planar corrected image with a pre-stored defect-free standard printing template based on feature matching and iterative optimization; and a difference calculation unit, used to calculate the pixel-level grayscale difference between the registered and aligned image and the standard printing template, and convert the difference value into a probability value to generate the first defect confidence map.

[0013] As a preferred embodiment of this application, the deep learning detection module includes: a model loading and inference unit, used to load the pre-trained lightweight reconstruction network and perform forward inference operations on the image to be detected to generate a corresponding reconstructed image; and a difference analysis unit, used to calculate the structural similarity difference map between the reconstructed image and the image to be detected, and normalize the difference value to map it into a probability value to generate the second defect confidence map.

[0014] As a preferred embodiment of this application, the collaborative fusion module includes: a Bayesian fusion unit, used to read pre-stored first conditional probability parameters and second conditional probability parameters, perform Bayesian fusion calculation on the first defect confidence map and the second defect confidence map pixel by pixel to generate an initial comprehensive defect confidence map, and perform filtering and morphological closing operations on the initial comprehensive defect confidence map to obtain a final comprehensive defect confidence map; and a defect discrimination and localization unit, used to perform threshold segmentation and connected component analysis on the final comprehensive defect confidence map, filter out pseudo defects with an area smaller than a preset threshold, and output the judgment result of whether the defect exists and the location information of the defect.

[0015] The beneficial effects of this invention are as follows: 1) The dual-channel collaborative architecture achieves comprehensive coverage detection of both regular and random defects through a complementary mechanism of adaptive surface flattening and unsupervised anomaly reconstruction. The traditional visual channel constructs a flexible, curved surface model and calculates the deformation field to flatten the distorted image into a planar corrected image. After sub-pixel-level registration, it compares the image pixel-by-pixel with a standard template, generating a first defect confidence map based on a noise statistical model. This effectively separates the difference in response between surface deformation and real defects, solving the problem of high false alarm rates from direct comparison. The deep learning channel utilizes a lightweight reconstruction network trained only on defect-free samples to forcibly map the image to be detected onto a normal texture manifold for reconstruction. A second defect confidence map is generated by calculating the structural similarity difference between the reconstructed image and the original image, sensitively capturing various types of random texture anomalies. The two channels are functionally complementary, enabling the system to effectively detect both global defects such as misregistration and color casts, as well as local random defects such as ink spots and scratches, eliminating the detection blind spots of a single technical approach.

[0016] 2) The deep learning channel employs an unsupervised reconstruction paradigm, fundamentally reducing the reliance on defect samples in the training mechanism and endowing the model with the ability to generalize detection of unknown defects. The lightweight reconstruction network is trained using only defect-free, qualified samples, learning the distribution patterns of normal printed textures by minimizing the mean squared error between the reconstruction output and the ground truth, without the need for any defect samples. During inference, any texture structure that does not belong to the learned normal manifold cannot be correctly reconstructed by the network, resulting in a high response on the difference map. This mechanism allows the model to avoid re-collecting labeled data due to changes in defect morphology, avoiding the overfitting and missed detection problems caused by incomplete defect sample coverage in supervised methods.

[0017] 3) The Bayesian decision-level fusion mechanism integrates independent evidence from two channels within a probabilistic reasoning framework, achieving robust and optimal comprehensive judgment. Empirical confidence parameters for defect reporting from both channels are obtained through offline calibration. During online detection, a closed probabilistic fusion operation is performed on each pixel, adaptively adjusting the comprehensive posterior probability based on the current evidence strength and channel confidence. Judgment is strengthened when the evidence from both channels is consistent; when one signal is weak and the other has a strong response, the decision is dominated by the higher-confidence channel. This effectively balances the detection rate and false alarm rate, making the final comprehensive defect confidence map closer to the true defect distribution than either single channel output.

[0018] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Of course, implementing any product or method of this application does not necessarily require achieving all of the advantages described above at the same time. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a general flowchart of the automatic detection method for printing defects in hoses provided in this embodiment of the invention.

[0021] Figure 2 This is a flowchart of generating a first defect confidence map by template registration and comparison provided in an embodiment of the present invention.

[0022] Figure 3 This is a flowchart of generating a second defect confidence map through network reconstruction comparison provided in an embodiment of the present invention.

[0023] Figure 4This is a flowchart of generating a comprehensive defect confidence map based on Bayesian decision fusion, provided in an embodiment of the present invention.

[0024] Figure 5 This is an architecture diagram of the automatic detection system for printing defects in hoses provided in an embodiment of the present invention. Detailed Implementation

[0025] The technical solutions in the embodiments of the present invention will be clearly and completely described below. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0026] Example 1 This invention provides an automatic detection method for printing defects in flexible tubes based on image processing. For example... Figure 1 As shown, the specific steps include: S101. Acquire the image to be inspected. On the flexible tube production line, a conveyor transports continuously printed flexible tubes to the inspection station at a preset constant speed. An image acquisition device is fixedly installed on the structural frame of the inspection station. The core of this image acquisition device is a high-resolution industrial line scan camera. To ensure that the acquired images are free of geometric distortion along the length of the flexible tube, the line scan camera is synchronized with the movement speed of the flexible tube via a rotary encoder. Specifically, the rotary encoder monitors the displacement of the conveyor in real time and generates a pulse signal proportional to the displacement; this pulse signal is converted into a line trigger signal to control the line scanning frequency of the line scan camera, so that the camera acquires one line of image data every time the flexible tube moves a fixed physical distance, thereby achieving strict synchronization between image acquisition and flexible tube movement.

[0027] The optical axis of the line scan camera lens is adjusted to be directly aligned with the area to be inspected on the flexible tube. To obtain images with uniform illumination and clear features, a high-brightness, high-uniformity LED linear focusing light source is used for illumination. The projection angle of this light source is precisely adjusted to prevent the reflected light hitting the curved surface of the flexible tube from forming strong specular highlights, while simultaneously ensuring that the diffuse reflection light from the printed ink can fully enter the lens of the line scan camera, thereby enhancing the contrast between the printed features and the background in the image.

[0028] At the entrance of the inspection station, a through-beam photoelectric sensor is installed to precisely control the start and end times of image acquisition. When the tip of the hose to be inspected reaches and blocks the light beam of the photoelectric sensor, the sensor outputs a trigger signal that transitions from a low level to a high level. Upon receiving the rising edge of this trigger signal, the system main controller immediately sends a start acquisition command to the line scan camera. The line scan camera responds to the command to start exposure and, strictly following the line trigger signal synchronized with the encoder, scans the hose surface profile line by line through its field of view. As the hose continues to pass through the inspection area, the camera continuously acquires and outputs a line scan image data stream of each profile.

[0029] When the end of the hose leaves the position where the photoelectric sensor's beam is blocked, the sensor signal returns to a low level. Upon detecting this falling edge, the main controller sends a stop acquisition command to the line scan camera. At this point, a complete long-format image data, stitched together from all sequentially acquired line scan image data, is temporarily stored in the system memory. Based on the preset physical length information of a single hose and the number of pulses per millimeter of the encoder (i.e., resolution), the system accurately calculates the range of image rows corresponding to a single hose from the complete long-format image, and performs cropping accordingly to generate a digital image containing the printed graphic information of the complete circumference of the hose. This image is the image to be detected. The image to be detected is stored in memory in the form of a two-dimensional grayscale matrix, where the rows of the matrix correspond to the unfolded pixels in the circumferential direction of the hose, and the columns correspond to the pixels in the length direction of the hose.

[0030] S102, Parallel distribution to dual detection channels After acquiring the image to be detected, the system initiates a parallel processing flow on its internal heterogeneous computing platform. Specifically, the system's main processor copies the image data to be detected, stored in memory, into two identical copies. The first copy is transmitted via a high-speed data bus (such as a PCIe bus) to the first computing unit responsible for processing conventional machine vision algorithms. The first computing unit can be implemented as a field-programmable gate array (FPGA) board or a dedicated multi-core central processing unit. The transmission path of the first copy and the first computing unit together constitute the conventional vision detection channel.

[0031] Simultaneously, a second copy of the image data is transmitted via a separate high-speed interface (such as MIPICSI-2 or USB 3.0) to a second computing unit dedicated to deep learning inference computation. This second computing unit can be implemented as an embedded graphics processor module or a dedicated acceleration chip integrating a neural network processing unit. The transmission path of the second copy, together with the second computing unit, constitutes the deep learning detection channel.

[0032] The traditional visual inspection channel and the deep learning inspection channel are independent of each other at the hardware level, each with its own dedicated computing resources and memory bandwidth. The data flow processing of the two channels is not interlocked, meaning that either channel can execute its algorithm independently without waiting for the other's processing result. This parallel architecture ensures that the theoretical upper limit of the entire inspection process is determined by the channel with the longer processing time, rather than the sum of their times, thus effectively meeting the stringent real-time requirements of high-speed production lines.

[0033] S103. Generate the first defect confidence map through template registration and comparison. After the first computing unit receives a copy of the image to be detected, it immediately initiates the processing flow of this step. This step aims to detect printing defects that are regular and can be detected through geometric and grayscale comparison with a standard template, such as misregistration, large-area color deviation, and pattern distortion. Figure 2 As shown, the specific implementation is as follows: First, the image to be detected is preprocessed to suppress noise. Specifically, a two-dimensional Gaussian kernel with a size of 5x5 pixels and a standard deviation σ of 1.0 is used to convolve the image to filter out high-frequency readout noise inherent in the image sensor and fine texture noise from the surface of the flexible substrate. The standard deviation σ of the Gaussian kernel is used to control the smoothing intensity and can be adjusted within the range of 0.5 to 2.0 according to the actual image noise level.

[0034] The Canny edge detection algorithm is applied to the denoised image to extract edge features. The Canny algorithm sets a low-hysteresis threshold of 50 and a high-hysteresis threshold of 150. The threshold setting principle is: a high threshold is used to identify strong edge pixels, and a low threshold is used to connect weak edge pixels connected to strong edges. In practical applications, the thresholds can be adaptively set based on the overall contrast of the image by analyzing the gradient magnitude histogram. After the algorithm runs, multiple edge segments are detected in the image.

[0035] Based on the prior knowledge that the hose occupies the main area in the image and its boundary is a long vertical edge, the system analyzes all detected edge segments. By calculating the length of each edge connected region and the angle between its main direction and the vertical axis of the image, the system selects the two edge lines with the longest vertical length and whose main direction has an angle with the vertical axis of the image less than a preset angle threshold (e.g., 10 degrees), and marks them as the left and right boundaries of the hose image, respectively.

[0036] After obtaining the left and right boundaries, the system selects a series of cross-sections along the length of the hose at a preset sampling step size (e.g., every 10 pixels) for analysis. At any selected cross-sectional location, the difference between the x-coordinates of the left and right boundaries in that column is the visual width of the hose in the image at that cross-section. Combined with the pixel physical size parameters obtained in advance through camera calibration, this pixel width can be converted into the corresponding actual physical width.

[0037] Assuming the hose cross-section is a standard circular arc, the radius of curvature of the arc at that cross-section can be calculated geometrically based on the chord length (i.e., the physical width converted from the visual width) and the known hose circumference. This calculation is performed on all sampled cross-sections, yielding a series of discrete radius of curvature values ​​distributed along the hose's length. These discrete radius of curvature values ​​are then smoothly fitted using a cubic spline interpolation function, ultimately generating a continuous surface mathematical equation that describes the height variation of the entire hose's surface. This continuous surface equation defines the true three-dimensional spatial coordinates of any point on the hose surface relative to the camera's imaging plane.

[0038] Based on the continuous surface equation, the first computing unit constructs a dense mapping relationship from the original distorted image coordinates to the corrected planar image coordinates, i.e., a deformation field. The specific construction process includes: creating a blank double-precision floating-point matrix with the same size as the image to be detected, as a storage container for the deformation field. For any pixel in the image to be detected, its integer coordinates in the image are set to (u, v). Based on the camera's pinhole imaging model and the calibrated camera intrinsic parameter matrix, an imaging ray equation originating from the camera's optical center and passing through the pixel can be calculated. Simultaneously, from the fitted continuous surface equation, the three-dimensional coordinates (including height information) of the corresponding hose surface point can be obtained. By solving the system of equations combining the imaging ray equation and the surface equation, the three-dimensional intersection coordinates of the imaging ray and the actual hose surface are obtained.

[0039] After completing the ray intersection calculation, a virtual reference plane is specified, facing the camera's optical axis. All the obtained 3D intersection points of the surfaces are orthogonally projected onto the reference plane along the local normal direction of their respective surface positions, thus obtaining the new coordinates of each original pixel in the corrected world coordinate system. Finally, using the camera intrinsic parameter matrix again, the new coordinates (world coordinates) are projected back into the image coordinate system to obtain the corresponding corrected image coordinates, which are typically floating-point numbers with decimal places. Thus, a mapping relationship is established for each pixel in the original image to its sub-pixel position on the corrected plane image. This mapping relationship is stored in the form of a dense floating-point matrix, i.e., the deformation field.

[0040] After obtaining the deformation field, the system uses this deformation field to perform a backward mapping image deformation operation on the image to be detected to generate a planar corrected image. Specifically, a new blank image is created as a container for the planar corrected image. Then, each target integer coordinate point in the planar corrected image is traversed. Using a pre-established KD-tree spatial index structure for the deformation field, the system quickly finds the nearest neighbor points of the target point in the original deformation field coordinate set. Based on the mapping relationship of these neighbor points, the sub-pixel position coordinates of the target integer coordinate point in the original distorted image are calculated using a radial basis function interpolation algorithm.

[0041] Finally, on the original image to be detected, taking the calculated sub-pixel position coordinates as the center, the pixel grayscale values ​​in the surrounding 4x4 neighborhood are taken, and a grayscale value is calculated using a bicubic interpolation algorithm. This grayscale value is then assigned to the corresponding target integer coordinate point in the planar correction image. After traversal, a planar unfolded image that eliminates the geometric deformation caused by the curved surface of the flexible tube is obtained, denoted as the floating image.

[0042] In the memory of the first computing unit, a standard printing template image is pre-stored, denoted as the reference image. This reference image is a digital image obtained by acquiring and correcting a hose sample whose printing quality has been manually confirmed to be completely qualified, using the same image acquisition device, synchronization method, and surface flattening algorithm described above. It represents a standard printing state with no defects and absolutely accurate registration.

[0043] The system first performs coarse registration between the floating image and the reference image. Specifically, an accelerated robust feature extraction algorithm is used to extract feature points and their corresponding descriptor vectors from both the floating image and the reference image. By calculating the Euclidean distance between the feature point descriptor vectors in the two images and applying the criterion that the ratio of the nearest neighbor distance to the second nearest neighbor distance is less than 0.75, a batch of initially matching feature point pairs is selected. Then, a random sampling consensus algorithm is used to iteratively filter this batch of initially matching point pairs, removing outliers and robustly estimating an initial affine transformation matrix from the floating image to the reference image, thus completing the coarse registration.

[0044] Based on the coarse registration, the system performs fine registration to achieve sub-pixel level alignment accuracy. The system invokes an enhanced correlation coefficient algorithm, whose inputs are the reference image and the floating image initially aligned using the initial affine transformation matrix. The algorithm's initial transformation matrix is ​​set to an identity matrix, the maximum number of iterations is 100, and the minimum step size tolerance is 1e-4. In each iteration, the enhanced correlation coefficient algorithm calculates a similarity metric between the two images that is insensitive to linear changes in illumination, and solves for an incremental geometric transformation parameter to maximize this metric. The algorithm iterates repeatedly until the parameter update amount is less than the tolerance or the maximum number of iterations is reached. Finally, it outputs an accurate fine registration transformation matrix.

[0045] After obtaining the precise registration transformation matrix, the system applies this matrix to the floating image, precisely deforming and mapping the floating image to a coordinate space perfectly aligned with the reference image through image resampling. Let the aligned floating image be I_aligned, and the reference image be I_template. A single-channel floating-point matrix of the same size as the floating image is created as the difference map D1. For each pixel position (i,j) within the effective overlapping area of ​​the floating image and the reference image, the absolute value of its grayscale difference is calculated: D1(i,j) = |I_aligned(i,j) - I_template(i,j)|. This difference value D1(i,j) directly reflects the severity of the deviation of the printing ink density or geometric position at that pixel from the standard state.

[0046] After generating the difference map, the difference value D1(i,j) is converted into a confidence value representing the probability that the pixel has a defect. Specifically, the system reads a pre-defined known defect-free region (such as a solid color background area) from the difference map, performs statistical analysis on the difference values ​​of all pixels within that region, and calculates its mean μ_noise and standard deviation σ_noise. The standard deviation σ_noise is then used as an estimate of the system's inherent noise level.

[0047] Subsequently, a probability mapping method based on a Gaussian noise model is used to map the difference value to a probability value P_A(i,j) in the interval [0,1]. The specific mapping relationship is: P_A(i,j)=1-exp(-(D1(i,j)^2) / (2(kσ_noise)^2)). Here, k is a sensitivity coefficient used to adjust the system's threshold for distinguishing between noise and real defects. A larger k value indicates higher tolerance for noise, but may lead to missed detection of weak defects; a smaller k value indicates higher sensitivity to differences, but may increase the false alarm rate. Typical values ​​for k are [1.5, 3.0]. The mechanism of this formula is that when the difference value D1(i,j) is much smaller than kσ_noise, it is considered to be mainly caused by system noise, and the defect probability approaches 0; when D1(i,j) is much larger than kσ_noise, it is considered to be a real printing defect, and the defect probability approaches 1. This calculation generates an initial probability map.

[0048] Next, morphological filtering is performed on the initial probability map to optimize region continuity. First, a circular structuring element with a radius of 3 pixels is created. Then, this structuring element is used to perform a morphological dilation operation on the image, followed by a morphological erosion operation. This closing operation is used to fill small holes generated inside the real defect regions due to noise perturbation and to connect adjacent high-response regions that may be disconnected due to thresholding. After processing, the probability value of each pixel is constrained to the range [0,1]. The final floating-point matrix image, which is the same size as the image to be detected, is the first defect confidence map P_A. Each pixel value P_A(i,j) on this map quantitatively represents the independent initial probability of regular defects such as misregistration and color cast at that pixel.

[0049] S104. Generate a second defect confidence map through network reconstruction and comparison. After the second computing unit receives a copy of the image to be detected, the processing flow of this step is triggered. This step aims to sensitively detect random printing defects such as ink spots, ink splatter, scratches, and missing characters, which are diverse, irregular in shape, and difficult to describe using fixed geometric or grayscale rules. Figure 3 As shown, the specific implementation is as follows: In the dedicated memory of the second computing unit, a pre-trained lightweight reconstruction network model structure and all weight parameters are persistently loaded. The reconstruction network architecture is an improved U-Net convolutional neural network based on the autoencoder concept. This network learns the internal feature representation of a defect-free hose image through an encoder-decoder structure.

[0050] The network encoder consists of four downsampling stages. The first stage takes a single-channel image as input and first passes it through a depthwise separable convolutional module, which comprises depthwise convolutions and pointwise convolutions, followed by a batch normalization layer and a LeakyReLU activation function. This is followed by a 2x2 max-pooling layer, which halves the feature map's spatial resolution. The subsequent three stages have similar structures. At the beginning of each stage, the number of channels is doubled, and the pointwise convolutions in the depthwise separable convolutional module adjust the number of channels to the target value for that stage. Afterward, batch normalization, LeakyReLU activation, and 2x2 max-pooling downsampling are also performed.

[0051] The bottleneck layer of the network is located between the encoder and decoder, and consists of two consecutive depthwise separable convolutional modules and a spatial attention mechanism module. The spatial attention module calculates the average and maximum values ​​of the input feature map along the channel dimension, concatenates the two along the channel dimension, and then passes them through a 7x7 convolutional layer to generate a single-channel spatial attention weight map. It is then normalized to the [0,1] interval using the Sigmoid function, and finally multiplied element-wise with the original input feature map to enhance the feature response at important spatial locations.

[0052] The decoder section is symmetrical to the encoder and contains four upsampling stages. In each stage, a 2x2 transposed convolution is first used to double the spatial resolution of the feature map while halving the number of channels. Then, the upsampling result is concatenated with the feature map passed from the corresponding downsampling stage of the encoder via skip connections along the channel dimension. Finally, the concatenated feature map is fed into a decoding convolutional block composed of depthwise separable convolutional modules for feature fusion and reconstruction. The last layer of the network is a standard convolutional layer with one output channel and a 1x1 kernel size, followed by a sigmoid activation function to ensure that each pixel value of the reconstructed image is normalized to between 0 and 1.

[0053] The training process of the lightweight reconstruction network was completed offline. The training set consisted entirely of qualified hose images acquired under the same imaging conditions and rigorously screened by humans to ensure they were free of any printing defects. Training was set to 600 iterations with a batch size of 16. The Adam algorithm was chosen as the optimizer, with an initial learning rate of 1e-3, and a decay strategy where the learning rate decreased by 0.1 times every 200 training iterations. The loss function was set to minimize the mean squared error between the reconstructed image and the input defect-free ground truth image. The mathematical expression is: L_train = (1 / N) Σ(I_ok_i-f_W(I_ok_i))^2, where N is the number of samples in a single batch, I_ok_i is the i-th defect-free training sample, and f_W(I_ok_i) is the network's reconstructed output for I_ok_i. Through extensive iterative training, the network weights W are optimized, enabling it to learn the underlying statistical regularities of all normal textures, pattern gradients, character edges, and background distributions in defect-free hose printing images. The latent space constructed by its encoder effectively represents the manifold of the "normal" printing pattern. Therefore, during inference, for an input image, the network attempts to find the best match from its learned "normal" manifold for reconstruction. Any anomalous regions (i.e., random defects) that do not belong to this normal manifold will be replaced by the normal background or smooth texture learned by the network in the reconstructed image.

[0054] During the online inference phase, when the image to be detected is input into the trained reconstruction network, the network performs a forward propagation calculation and outputs the corresponding reconstructed image. This reconstructed image is the network's ideal estimate of the hose in a defect-free state.

[0055] After obtaining the reconstructed image, the second computing unit calculates the difference between it and the original input image to be detected. This embodiment uses a structural similarity index for comparison, which can better perceive differences in structural information. The calculation process uses an 11x11 Gaussian sliding window with a standard deviation of 1.5. This window starts from the top left corner of the image and traverses the entire image with a step size of 1 pixel. At each window position, corresponding local image patches are extracted from the image to be detected and the reconstructed image, and the mean brightness, standard deviation, and covariance between the two image patches are calculated. Using these three statistics, the local structural similarity value SSIM(i,j) of the center pixel of the window is calculated according to the standard formula for structural similarity. The values ​​calculated at all window positions together constitute a structural similarity map, with a value range of [-1, 1], where 1 indicates that the two image patches have completely identical structures.

[0056] The presence of defects causes abnormal texture in this region, and the reconstruction network removes these defects, resulting in a significant structural difference between the original and reconstructed image patches in this region, leading to a decrease in the SSIM value. Therefore, the difference index D2(i,j) is defined as follows: D2(i,j) = 1 - max(SSIM(i,j), 0). The max(SSIM(i,j), 0) operation truncates any possible negative values ​​to 0, corresponding to regions with completely opposite structures, where the difference is set to a maximum of 1. The larger the D2(i,j) value, the greater the difference between that location and the "normal" structure.

[0057] After obtaining the difference map D2, filtering is performed on it to smooth isolated high-response points caused by noise. Specifically, a Gaussian kernel of size 3x3 with a standard deviation of 0.8 is used to convolve the difference map. The standard deviation of the Gaussian kernel can be adjusted within the range of 0.5 to 1.2 according to the actual noise characteristics. After filtering, all pixel values ​​of the entire difference map are linearly scaled, mapping the minimum value to 0 and the maximum value to 1, thus completing normalization. At this time, the larger the value P_B(i,j) of each pixel, the higher the independent initial probability that the point belongs to a random defect. This generated normalized floating-point image is the second defect confidence map P_B.

[0058] S105. Generating a comprehensive defect confidence map based on Bayesian decision fusion. After channels S103 and S104 have completed parallel execution and output the first defect confidence map P_A and the second defect confidence map P_B respectively, the system main processor receives and stores these two single-channel confidence maps of the same size in memory. Figure 4 As shown, the specific implementation is as follows: Before performing the fusion operation, two key empirical parameters, denoted as CP_A and CP_B, are stored in the main processor's non-volatile memory. Parameter CP_A represents the conditional probability that the detection result of the traditional visual detection channel is a real defect when the pixel value of the first defect confidence map P_A approaches 1; it characterizes the reliability of the traditional visual detection channel. Parameter CP_B represents the conditional probability that the detection result of the deep learning detection channel is a real defect when the pixel value of the second defect confidence map P_B approaches 1; it characterizes the reliability of the deep learning detection channel.

[0059] These two parameters are obtained through the following offline calibration steps: Prepare a calibration image set containing M samples (M≥200), where the defect location and type of each sample image have been precisely labeled manually. Process this calibration image set using both the traditional visual detection channel and the deep learning detection channel, obtaining two sets of confidence map outputs. Based on the actual annotations, statistically analyze the detection results of the two channels: Taking the traditional visual channel as an example, binarize its output confidence map with a threshold of 0.5, compare the results with the annotations, and calculate its precision, i.e., CP_A = number of true positives detected by the traditional visual channel / total number of positives reported by the traditional visual channel. The calculation of CP_B is similar. For example, after testing a set containing 200 labeled samples, CP_A = 0.75 and CP_B = 0.85 can be set. These two parameters can be fine-tuned based on feedback from false positives and false negatives during actual production line operation.

[0060] After completing the parameter reading, the main processor traverses each pixel coordinate (i,j) of the image. For this coordinate point, it reads the pixel value v_A=P_A(i,j) from the first defect confidence map and the pixel value v_B=P_B(i,j) from the second defect confidence map. Under the Bayesian inference framework, v_A and v_B are regarded as evidence from two independent detection modules regarding "this point is a defect".

[0061] Assuming the results of the two detection channels are conditionally independent under a given true defect state, the formula for fusing the results to calculate the posterior probability P_fusion(i,j) of the point being a true defect is as follows: P_fusion(i,j)=(v_A v_B P_prior) / (v_A v_B P_prior+(1-v_A CP_A) (1-v_B CP_B) (1-P_prior)). Here, P_prior is the prior probability that the point is a defect, which can be set based on the historical average defect rate of the production line, and its value is usually much less than 0.5. The logic of this formula is: when both v_A and v_B are large (i.e., both channels give strong evidence of defects), the numerator dominates, and P_fusion approaches 1; when both v_A and v_B are small, (1-P_A) in the denominator... CP_A) (1-v_B The CP_B term (i.e., the joint probability of both channels providing weak defect evidence, tending towards normality) dominates, and P_fusion approaches 0. When only one side's evidence is strong while the other side's evidence is weak, the final probability is jointly determined by the strength of the evidence and its corresponding channel confidence levels CP_A and CP_B. The main processor performs the above fusion operation on every pixel of the entire image, fills the obtained P_fusion value into a new floating-point matrix, and generates an initial comprehensive defect confidence map.

[0062] After obtaining the initial fusion result, a median filter is first applied to suppress isolated noise points. The kernel window size for the median filter is set to 3x3. For each pixel in the image, all nine probability values ​​within its 3x3 neighborhood are collected. A fast sorting algorithm is used to find the median value, and this median value replaces the original value of the center pixel. This operation is used to remove isolated, discontinuous high-response single points in the image caused by probability calculation errors or local perturbations, while also preserving the boundaries of the true defective regions relatively well.

[0063] Then, a morphological closing operation is performed on the median-filtered image to fuse neighboring defect regions and fill internal holes. A disk-shaped structuring element with a radius of 4 pixels is created. First, a dilation operation is performed on the image: for each pixel in the image, the maximum probability value within the neighborhood covered by the structuring element is assigned to that pixel. Subsequently, an erosion operation is performed on the dilation result: the minimum probability value within the neighborhood covered by the structuring element is assigned to that pixel. This closing operation connects the response breaks on the confidence map caused by subtle texture changes inside the defect and fills in small holes within the region, making the response of the defect region more complete and coherent. The final processed image is the final comprehensive defect confidence map P_final.

[0064] S106, Thresholding Discrimination and Defect Location The main processor acquires the final comprehensive defect confidence map P_final after morphological post-processing. First, threshold segmentation is performed to transform the probability map into a binary decision map. A fixed decision threshold T is set, typically 0.60. This threshold T is used to balance the detection rate and false alarm rate and can be adjusted according to actual product quality inspection standards, typically ranging from 0.5 to 0.8. An empty binary image BW of the same size as P_final is created. All pixel values ​​in P_final greater than or equal to T are marked as 1, representing foreground defect pixels; pixel values ​​less than T are marked as 0, representing background normal pixels.

[0065] Next, connected component analysis is performed on the generated binary image BW to identify independent defect regions. A two-pass scanning algorithm is used. In the first pass, a temporary label is assigned to each pixel with a value of 1, and the equivalence relationship between different labels is recorded. In the second pass, all labels are replaced with the smallest equivalent label according to the equivalence relationship, so that all pixels belonging to the same connected region are assigned the same unique integer number.

[0066] After completing the connected component labeling, the system iterates through and counts the total number of pixels in each connected component, i.e., its area. A minimum defect area threshold A_min is set, with a value of 15 pixels. This threshold is used to filter out false defects with excessively small areas caused by image noise, calculation errors, or tiny dust particles. The setting of A_min should be related to the image resolution and the acceptable minimum physical size of the defect. For example, if each pixel corresponds to an actual size of 0.1 mm, then 15 pixels correspond to a defect of 1.5 mm. This threshold can be adjusted according to actual quality acceptance standards. If the pixel area of ​​a connected component is smaller than A_min, it is judged as a false defect, and the system forcibly modifies the label of all pixels in that connected component to 0, i.e., erasing that area on the binary image BW.

[0067] For all remaining connected components, each component represents an independent real printing defect. The system extracts quantitative information about these defects, including: calculating the average of all pixel coordinates within the connected component as the center coordinates of the defect; finding the minimum and maximum row and column numbers of the pixels within the connected component to determine the positive bounding rectangle that can enclose the defect; and recording the pixel area of ​​the connected component as a measure of the defect size.

[0068] If, after minimum area filtering, there are no connected components with a value of 1 in the binary graph BW, the entire printed tube to be inspected is determined to have no detectable defects and is considered a qualified product. A "qualified" signal is then output to the subsequent production line control system. If one or more valid connected components exist, the tube is determined to be a defective product. The location (center coordinates), size (area), and extent (bounding rectangle) information of all defects are packaged into a structured data message and output to the subsequent rejection control module.

[0069] Example 2 This invention also provides an automatic detection system for printing defects in flexible tubes based on image processing, such as... Figure 5 As shown, it specifically includes: Image acquisition module The physical implementation of the image acquisition module consists of an industrial camera and auxiliary components, with its core being a high-resolution monochrome linear array charge-coupled device (CCD) industrial camera with 4096 pixels. This camera is connected to the system's embedded motherboard via a gigabit Ethernet data interface. A fine-tuning focus ring is installed at the front of the camera lens to precisely focus the light path at the highest point of the flexible tube during system installation and debugging. The illumination device is an LED linear focusing light source connected to a high-power constant current controller, with a color temperature of 5000K. The mounting bracket for the light source has multiple degrees of freedom, allowing adjustment of its pitch and lateral rotation angles to find the optimal angle that ensures uniform light reflection from the tube surface without overexposure.

[0070] A laser beam sensor is mounted on a fixed bracket on one side of the conveyor belt, with its transmitter and receiver located on opposite sides of the belt. The laser beam is interrupted when the flexible tube passes by. This sensor is equipped with a high-speed signal conditioning board that converts the abrupt changes in the on / off signal into a clean, jitter-free low-voltage differential signal pulse, which is then sent to a dedicated digital input / output interface card on the system motherboard. This interface card has a built-in encoder signal receiving circuit that directly interfaces with the rotary encoder on the production line to acquire the linear velocity pulse signal of the production line in real time.

[0071] When the laser sensor at the tip of the flexible tube is triggered, the digital input / output interface card receives the transition signal and immediately controls the line scan camera to begin acquiring a line scan image based on the preset exposure stroke corresponding to the tube length. Simultaneously, the encoder pulse is converted into a line trigger signal to control the camera's acquisition frequency, achieving synchronous acquisition. Finally, the complete long-format image data of the flexible tube is efficiently transmitted to the system motherboard's Double Data Rate Synchronous Dynamic Random Access Memory (DRAM) via direct memory access, forming the image to be detected.

[0072] Traditional visual inspection module Traditional vision inspection modules are deployed on the main central processing unit of the embedded motherboard of the system, or optionally on a field-programmable gate array (FPGA) accelerator card. This module is the main execution unit for generating the first defect confidence map, and it internally contains three sequentially connected functional processing units.

[0073] The surface flattening unit stores the camera's factory calibration parameters in its read-only memory. Upon receiving the image to be detected from system memory, this unit immediately invokes its integrated Canny edge detection and surface equation fitting function library to construct an arc-shaped surface model of the hose. Specifically, it extracts the left and right boundary edges of the hose in the image, calculates the radius of curvature of the arc at each cross-section based on the visual width of the edges on each cross-section of the image and the known circumference of the hose, and obtains the continuous surface equation using cubic spline interpolation. Based on this surface equation, the surface flattening unit performs intensive calculations of the deformation field on the image and uses a bicubic interpolation algorithm for spatial transformation, ultimately generating a planar corrected image (i.e., a floating image) using hardware acceleration.

[0074] The template registration unit stores a standard, defect-free template image (reference image) in its non-volatile memory. It receives the corrected image from the surface flattening unit and activates its internal accelerated robust feature extraction and enhanced correlation coefficient alignment engine. This unit first performs coarse registration from the floating image to the reference image using feature point matching and random sample consensus algorithms to obtain an initial affine transformation matrix. Then, it iteratively optimizes the matrix using the enhanced correlation coefficient algorithm, ultimately calculating a fine registration transformation matrix with sub-pixel accuracy and aligning the floating image to the reference image coordinate system.

[0075] The difference calculation and probability generation unit receives the aligned floating image and the stored reference image, performs pixel-level gray-level difference calculation, and generates a difference map D1. This unit reads a pre-defined defect-free region from the difference map and performs noise statistical modeling to obtain an estimate of the noise standard deviation σ_noise. Then, using a pre-established probability mapping function or lookup table based on a Gaussian model, this unit quickly maps the gray-level difference value D1(i,j) of each pixel to a defect probability value in the interval [0,1], generating an initial difference probability map in floating-point format. Finally, this unit calls a morphological filtering function, using a circular structuring element with a radius of 3 pixels to perform a closing operation on the initial probability map, filling small holes and connecting fracture areas, ultimately outputting the first defect confidence map P_A.

[0076] Deep learning detection module The deep learning detection module is an embedded artificial intelligence acceleration computing module integrated with the system motherboard via a high-bandwidth interface. Its core is an embedded graphics processing unit (GPU) core board with multiple computing cores, or a dedicated neural network processor chip with equivalent computing power and its peripheral low-power memory. This module is the main entity responsible for generating the second defect confidence map.

[0077] The model loading and inference unit manages the deployment and execution of the deep learning model. Its dedicated flash memory stores the complete computational graph structure and layer weights of a pre-trained, lightweight U-Net reconstruction network. Upon system startup, this unit loads the network structure and weights into the accelerator's memory and performs computational graph optimization and kernel driver initialization. During online detection, once the image to be detected is received from the image acquisition module, it is used as the input tensor of the computational graph, initiating a heterogeneous parallel forward inference operation. The network extracts multi-scale features through the encoder, enhances them through the spatial attention mechanism of the bottleneck layer, and then gradually restores the resolution through the decoder, ultimately generating a reconstructed image of the input image. Theoretically, this image should have eliminated random defects and textures.

[0078] The difference analysis unit then starts. It reads the same input image and the reconstructed image just generated by the inference unit, and calls the structural similarity calculation function library. This unit uses the parallel floating-point computing unit within the accelerator to traverse the entire image with an 11x11 Gaussian sliding window with a standard deviation of 1.5, calculating the structural similarity value SSIM for each local window to form a structural similarity map. Then, it performs a difference transformation operation D2=1-max(SSIM,0) on each pixel to obtain the difference map. Finally, it uses a 3x3 Gaussian kernel with a standard deviation of 0.8 to filter and smooth the difference map, and linearly normalizes all difference values ​​to the [0,1] interval to generate the second defect confidence map P_B.

[0079] Collaborative Integration Module The collaborative fusion module runs on the high-performance multi-core central processing unit of the system motherboard and is the core logic unit that completes the final decision. It is divided into a Bayesian fusion unit and a defect discrimination and localization unit.

[0080] The Bayesian fusion unit, during initialization, reads two conditional probability parameters, CP_A and CP_B, and the defect prior probability, P_prior, from the system configuration file. During online runtime, it starts a message listening thread. Once it detects that the completion flags of both the traditional visual detection module and the deep learning detection module are set in the specified address region of main memory, it directly reads the data of the first defect confidence map P_A and the second defect confidence map P_B at high speed via memory pointers. Then, it initiates multi-threaded parallel computation, executing the Bayesian fusion calculation formula for each corresponding pixel in the two confidence maps according to the stored CP_A, CP_B, and P_prior parameters, and filling all pixel calculation results into a new floating-point matrix to generate the initial comprehensive defect confidence map. Subsequently, the unit further calls the median filtering function and morphological closing operation function from the open-source computer vision library, sequentially performing 3x3 median filtering and disk-shaped structural element closing operations with a radius of 4 on the initial fusion map to generate the final comprehensive defect confidence map P_final.

[0081] The defect identification and localization unit takes over the final comprehensive defect confidence map P_final. It first calls a threshold function to binarize P_final with a decision threshold T of 0.60, generating a binary image BW. Then, it calls a connected component analysis function to perform connected component labeling on the binary image BW and directly obtains the area, centroid coordinates, and bounding rectangle information of each connected component. Subsequently, it traverses all detected connected components, removing false defects with an area less than 15 pixels. For all valid defects that are ultimately retained, their location and size information are encapsulated into a structure and sent to the rejection control module via inter-process communication. If no valid defects are found, a "qualified" message is sent to the rejection control module.

[0082] Elimination control module The rejection control module consists of a high-speed solenoid valve driver board, input / output interface circuits, and a microcontroller. The microcontroller communicates bidirectionally with the system motherboard via a fieldbus, maintaining a first-in-first-out workpiece tracking queue. Each queue element contains a workpiece identifier, a defect flag (pass / fail), and the initial encoder count value when the hose triggers data acquisition.

[0083] When the collaborative fusion module on the system motherboard determines that a hose is defective, it sends a data packet containing the hose's identifier and defect information to the microcontroller via the bus. Upon receiving the packet, the microcontroller creates a tracking record for this defective hose and enqueues it. This record contains the encoder count value at the moment the hose triggers data acquisition. Simultaneously, the microcontroller continuously receives pulse signals from the rotary encoder on the production line and maintains an internal counter for accumulation.

[0084] During the initial system calibration phase, the physical distance between the camera's shooting point and the action point of the rejection actuator (such as an air nozzle) has been measured and converted into the corresponding total number of encoder pulses, denoted as the total number of hysteresis pulses N_lag. In each encoder pulse interrupt service routine, the microcontroller compares the current cumulative pulse count with the initial count value stored in each tracking record in the queue. When it finds that the "initial count value + N_lag" corresponding to a defective hose equals the current total pulse count, it means that the defective hose has moved to the rejection station. The microcontroller immediately sends a high-level pulse lasting 50ms to the high-speed solenoid valve drive board through the input / output interface circuit. The solenoid valve is energized and opened, the connected high-pressure air circuit is instantaneously opened, and a strong airflow is ejected from the air nozzle facing the side of the conveyor belt, blowing the defective hose away from the main production flow and causing it to fall into the waste collection chute below, completing the rejection operation. For qualified products in the queue that are not marked as defective, when they move to the rejection station, the microcontroller does not send a trigger signal, the solenoid valve does not operate, and the hose flows smoothly.

[0085] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the invention. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, it is intended that all variations falling within the meaning and scope of equivalents of the claims be included within the present invention.

Claims

1. A method for automatically detecting defects in printing on a hose based on image processing, characterized in that, Includes the following steps: Acquire an image of the surface of the printed material on the flexible tube to be inspected; The image to be detected is input into a pre-constructed traditional visual detection channel and a deep learning detection channel, respectively. In the traditional visual inspection channel, the image to be inspected is adaptively flattened and registered with a standard template. By comparing the registered image with the standard template at the pixel level grayscale difference, a first defect confidence map is generated. In the deep learning detection channel, a pre-trained lightweight reconstruction network is used to reconstruct the image to be detected, generating a corresponding reconstructed image. A second defect confidence map is generated by calculating the structural difference between the reconstructed image and the image to be detected. The lightweight reconstruction network is trained only on defect-free qualified hose printing sample images. The first defect confidence map and the second defect confidence map are fused pixel-level based on Bayesian decision to generate a comprehensive defect confidence map; Based on the comprehensive defect confidence map, it is determined whether there are defects on the surface of the printed tube to be inspected, and the defect area is located when defects are present.

2. The method according to claim 1, characterized in that, The adaptive surface flattening and standard template registration of the image to be detected includes: Extract the edge contour of the hose in the image to be detected. Based on the visual width of the hose at each cross section of the image and the known circumference of the hose, calculate the radius of curvature of the arc at each cross section and interpolate to obtain the equation of the continuous surface. Based on the continuous surface equation, a deformation field is constructed from the coordinates of the original distorted image to the coordinates of the corrected planar image. The deformation field is then used to nonlinearly flatten the image to be detected into a planar corrected image through an interpolation algorithm. The planar corrected image is registered with a pre-stored defect-free standard printing template at the sub-pixel level based on feature matching and iterative optimization to obtain an aligned image for use in the pixel-level grayscale difference comparison.

3. The method according to claim 1, characterized in that, The lightweight reconstruction network is a convolutional neural network based on an autoencoder structure, in which depth-separable convolutional modules are used in the encoder and decoder instead of standard convolutional modules. The training process of the lightweight reconstruction network includes: using defect-free, qualified hose printing sample images as both input and training targets of the network, updating the network weights by minimizing the mean square error loss function between the reconstructed image and the input image, so that the lightweight reconstruction network learns the normal pattern distribution of the defect-free hose printing texture.

4. The method according to claim 1, characterized in that, The step of performing pixel-level fusion of the first defect confidence map and the second defect confidence map based on Bayesian decision to generate a comprehensive defect confidence map includes: Obtain a first conditional probability parameter characterizing the reliability of the traditional visual detection channel and a second conditional probability parameter characterizing the reliability of the deep learning detection channel, respectively. Read the first probability value in the first defect confidence map and the second probability value in the second defect confidence map pixel by pixel; Based on the Bayesian inference framework, the first conditional probability parameter, the second conditional probability parameter, the first probability value and the second probability value are fused and calculated to obtain the posterior probability value of the pixel having a defect. The posterior probability values ​​of all pixels are combined to generate an initial comprehensive defect confidence map.

5. The method according to claim 4, characterized in that, After generating the initial integrated defect confidence map, the method further includes: performing median filtering and morphological closing operations on the initial integrated defect confidence map in sequence to remove isolated noise points and connect adjacent defect regions to obtain the final integrated defect confidence map.

6. The method according to claim 1, characterized in that, The step of determining whether there are defects on the surface of the printed tube to be inspected based on the comprehensive defect confidence map includes: The comprehensive defect confidence map is binarized using a preset judgment threshold to generate a binary image; Perform connected component analysis on the binary image and filter out connected components with an area smaller than a preset minimum area threshold; If connected components still exist after filtering, it is determined that there is a defect; otherwise, it is determined that there is no defect.

7. An automatic detection system for printing defects in flexible tubes based on image processing, wherein the system applies the method as described in any one of claims 1 to 6, characterized in that, include: The image acquisition module is used to acquire the image of the surface of the printed tubing to be inspected. Traditional visual inspection modules are configured to adaptively flatten the image to be inspected and register it with a standard template. By comparing the registered image with the standard template at the pixel level grayscale difference, a first defect confidence map is generated. The deep learning detection module internally loads a lightweight reconstruction network trained only on defect-free qualified hose printing sample images. It is configured to use the lightweight reconstruction network to reconstruct the image to be detected, generate a reconstructed image, and generate a second defect confidence map by calculating the structural difference between the reconstructed image and the image to be detected. The collaborative fusion module is configured to receive the first defect confidence map and the second defect confidence map, perform pixel-level fusion based on Bayesian decision to generate a comprehensive defect confidence map, and determine and locate defects based on the comprehensive defect confidence map.

8. The system according to claim 7, characterized in that, The conventional visual inspection module includes: The surface flattening unit is used to extract the edge of the hose in the image to be detected, calculate the radius of curvature based on the visual width of each cross section and the known circumference of the hose, and interpolate to obtain the equation of the continuous surface. It also calculates the deformation field and flattens the image to be detected into a planar corrected image through an interpolation algorithm. The template registration unit is used to perform sub-pixel-level registration of the planar corrected image with a pre-stored defect-free standard printing template based on feature matching and iterative optimization. The difference calculation unit is used to calculate the pixel-level grayscale difference between the registered and aligned image and the standard printing template, and convert the difference value into a probability value to generate the first defect confidence map.

9. The system according to claim 7, characterized in that, The deep learning detection module includes: The model loading and inference unit is used to load the trained lightweight reconstruction network and perform forward inference operations on the image to be detected to generate the corresponding reconstructed image. The difference analysis unit is used to calculate the structural similarity difference map between the reconstructed image and the image to be detected, and normalize the difference value to map it into a probability value to generate the second defect confidence map.

10. The system according to claim 7, characterized in that, The collaborative fusion module includes: The Bayesian fusion unit is used to read the pre-stored first conditional probability parameter and second conditional probability parameter, perform Bayesian fusion calculation on the first defect confidence map and the second defect confidence map pixel by pixel to generate an initial comprehensive defect confidence map, and perform filtering and morphological closing operation on the initial comprehensive defect confidence map to obtain the final comprehensive defect confidence map. The defect identification and location unit is used to perform threshold segmentation and connected component analysis on the final comprehensive defect confidence map, filter out false defects with an area smaller than a preset threshold, and output the judgment result of whether the defect exists and the location information of the defect.

Citation Information

Patent Citations

  • Automatic detection and removal system for tube-making and printing defects

    CN110308156A

  • Methods and Artificial Intelligence Systems for Identifying Packaging and Printing Quality in the Cosmetics Manufacturing Industry

    CN114494265B

  • Variable data printing defect detection method and system based on YOLOv5s model

    CN117274176B