An Early Warning Method for Abnormal Sealing of Strip Packaging Based on OCR Traceability
By using OCR traceability technology, the real-time correlation between the location of sealing anomalies and the batch code is achieved, which solves the problem of real-time correlation between sealing quality data and product traceability information, improves the speed of quality risk handling and the closed-loop application of production data, and forms a proactive early warning mechanism.
Patent Information
- Application Number
- CN202511163623.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-20
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2045-08-20
AI Technical Summary
In existing technologies, sealing quality data and product traceability information cannot be automatically linked in real time. This results in the inability to synchronously link key traceability information such as batch and production line workstation when sealing is abnormal. This leads to serious delays in the isolation and handling of problematic batches, increases the probability of quality risk spread, hinders the closed-loop application of production data, and restricts the improvement of quality control efficiency.
By using an OCR-based traceability method, images of the sealing area and the OCR area are acquired simultaneously. Coordinate transformation is performed using the physical size parameters of the packaging bag to achieve accurate traceability of the sealing anomaly location and batch code. A spatial coordinate density distribution map is generated, the probability of sealing failure is calculated, and a graded early warning instruction is generated.
It achieves real-time correlation between the location of sealing anomalies and batch information, significantly shortens the time for locating problematic batches, reduces the probability of non-conforming products flowing out, and provides real-time data support through density trend analysis, forming a closed-loop quality control system and realizing the transformation from passive detection to proactive early warning.
Smart Images

Figure CN120672749B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of quality monitoring technology for pharmaceutical and food packaging production lines, and more specifically, to a method for early warning of abnormal sealing of strip packaging based on OCR traceability. Background Technology
[0002] In the pharmaceutical and food industries, high-speed packaging of viscous liquid products (such as strong loquat syrup) using composite films has become the mainstream process on strip packaging production lines. These lines are typically equipped with vision inspection systems to assess the quality of the seal appearance, and laser marking technology to mark traceability codes containing batch numbers, expiration dates, and other information on the product surface to meet production traceability and compliance requirements. Current technical solutions generally implement seal defect detection and OCR information recognition as separate processes: the vision system analyzes images to determine if there are cracks, contamination, or incomplete sealing in the sealing area, while the OCR module focuses on decoding the character information on the packaging surface. These two types of data are stored in separate databases, creating information silos.
[0003] The aforementioned separate processing mechanism prevents sealing quality data from being automatically linked to product traceability information in real time. When the production line detects a sealing anomaly, the system can only output the defect type and the time of occurrence, but cannot simultaneously link the batch, production line station, and other key traceability information corresponding to the abnormal packaging. Operators must manually retrieve production logs and match timestamps with OCR database records one by one to locate the specific batch of the affected product. This lagging and inefficient traceability method, on the one hand, leads to a serious delay in the isolation and disposal of problematic batches of products, increasing the probability of quality risk spread; on the other hand, it hinders the closed-loop application of production data, resulting in a lack of real-time data support for sealing process optimization and restricting the improvement of quality control efficiency. Summary of the Invention
[0004] In order to overcome the above-mentioned defects of the prior art, the present invention provides a method for early warning of abnormal sealing of strip packaging based on OCR traceability to solve the problems mentioned in the background art.
[0005] To achieve the above objectives, the present invention provides the following technical solution:
[0006] The method for early warning of abnormal sealing of strip packaging based on OCR traceability includes the following steps:
[0007] S1. Simultaneously acquire images of the sealing area and OCR area of the strip packaging bag;
[0008] S2. Determine whether the sealing status meets the preset sealing form standard based on the image of the sealing area. If it does not meet the standard, extract the coordinates of the abnormal position.
[0009] S3. Based on the physical size parameters of the strip packaging bag, convert the coordinates of the abnormal location into mapped coordinates in the OCR area coordinate system;
[0010] S4. Locate the target region corresponding to the mapped coordinates in the OCR region image, and recognize the batch-coded character image within the target region;
[0011] S5. Based on the successfully identified batch code character images, aggregate the distribution data of the residual material in the sealing area of all strip packaging bags in the current production period corresponding to the batch code character images, and generate a spatial coordinate density distribution map.
[0012] S6. When the density value of the spatial coordinate density distribution map in the preset coordinate range continues to increase for three consecutive production units, calculate the predicted value of the sealing failure probability of the corresponding batch.
[0013] S7. Bind the abnormal location coordinates, the successfully identified batch code character image, and the predicted value of the seal failure probability to generate a graded early warning instruction.
[0014] Furthermore, images of the sealing area and OCR area of the strip packaging bag are acquired simultaneously, including:
[0015] Control the industrial camera to capture images of strip-shaped packaging bags passing through a fixed shooting station while the conveyor belt speed is constant;
[0016] Adjust the illumination angle of the ring light source to eliminate the interference of aluminum foil reflection in the sealing area on image clarity;
[0017] Obtain the sealed area image and the OCR area image separately, ensuring that the sealed area image and the OCR area image have the same timestamp and spatial location label.
[0018] Furthermore, based on the image of the sealed area, it is determined whether the sealing status meets the preset sealing form standard. If it does not meet the standard, the coordinates of the abnormal location are extracted, including:
[0019] The continuity of the heat seal line in the sealed area image is checked to determine whether there is a break or a false seal.
[0020] When there is a break or a false seal, analyze whether the texture and ripple direction of the sealing edge conforms to the preset angle range.
[0021] When the direction of the texture ripples does not conform to the preset angle range, verify the grayscale consistency of the sealed area under non-uniform lighting compensation conditions.
[0022] When grayscale consistency verification fails, locate the coordinates of the abnormal position and convert them to physical coordinates with the lower left corner of the packaging bag as the origin.
[0023] Furthermore, based on the physical size parameters of the strip packaging bag, the coordinates of the abnormal location are converted into mapped coordinates in the OCR area coordinate system, including:
[0024] Obtain the physical length and physical width values of the strip packaging bag in the length direction and width direction;
[0025] A two-dimensional coordinate system for the surface of the packaging bag is established based on the physical length and physical width values;
[0026] Read the coordinate components of the abnormal location coordinates in the two-dimensional coordinate system;
[0027] Based on the fixed position offset of the OCR area on the surface of the packaging bag, calculate the mapped coordinate components of the abnormal position coordinates in the OCR area coordinate system.
[0028] Combine the mapped coordinate components to generate mapped coordinates.
[0029] Furthermore, the two-dimensional coordinate system on the surface of the packaging bag has the lower left corner as the origin, the length direction as the X-axis, and the width direction as the Y-axis.
[0030] Furthermore, the target region corresponding to the mapped coordinates in the OCR region image is located, and the batch-encoded character image within the target region is identified, including:
[0031] A rectangular recognition frame is defined based on the mapped coordinates, and the length and width of the rectangular recognition frame match the physical dimensions of the laser-coded characters on the surface of the strip packaging bag;
[0032] Dynamic local binarization is performed on the image area covered by the rectangular recognition box to eliminate grayscale distortion caused by aluminum foil reflection;
[0033] Extract the set of connected components from the binarized image and filter out interference regions that do not meet the aspect ratio threshold of the batch-encoded character image;
[0034] Project the connected component set along the character arrangement direction to segment it and output the separated batch-encoded character images.
[0035] Furthermore, based on the successfully identified batch code character images, the distribution data of residue in the sealing areas of all strip-shaped packaging bags within the current production period corresponding to the batch code character images are aggregated to generate a spatial coordinate density distribution map, including:
[0036] Extract the pixel coordinates of the residue edge contour from the image of the sealed area of the strip packaging bag associated with the batch code character image;
[0037] Convert the pixel coordinates of the residue edge contour to physical coordinates with the bottom left corner of the packaging bag as the origin;
[0038] Accumulate the physical coordinates of the residues in all strip packaging bags corresponding to the same batch of coded character images within a preset time window;
[0039] The density value per unit area in a two-dimensional plane is calculated based on the accumulated physical coordinates of the residue, forming a spatial coordinate density distribution map.
[0040] Furthermore, when the density value of the spatial coordinate density distribution map continuously increases for three consecutive production units within a preset coordinate range, the predicted sealing failure probability value for the corresponding batch is calculated, including:
[0041] Obtain the spatial coordinate density distribution map of three consecutive production units within a preset coordinate interval;
[0042] Calculate the average density value of the spatial coordinate density distribution map for each production unit and generate a density value sequence;
[0043] Verify whether the density value sequence satisfies the monotonically increasing condition;
[0044] When the monotonically increasing condition is met, retrieve the number of sealing failure records corresponding to the same density growth pattern in the historical batch database.
[0045] The predicted probability of sealing failure is calculated based on the ratio of the number of times the seal failure records are retrieved to the total number of historical batches.
[0046] Furthermore, the abnormal location coordinates, successfully identified batch code character images, and predicted seal failure probability values are linked to generate tiered early warning instructions, including:
[0047] Synchronize the coordinates of the abnormal locations with the timestamps of the successfully identified batch of encoded character images;
[0048] Match a predefined threshold range of instruction status codes based on the predicted value of seal failure probability;
[0049] Generate data packets and convert them into a hierarchical early warning instruction format that can be parsed by the production line control system.
[0050] Furthermore, the data packet contains timestamp data of the abnormal location coordinates, timestamp data of the successfully recognized batch-coded character images, and instruction status codes.
[0051] Compared with the prior art, the present invention has the following beneficial effects:
[0052] 1. By using a physical coordinate system transformation mechanism, the location of sealing anomalies is directly mapped to the OCR area, solving the technical challenge of real-time correlation between sealing quality data and product batch information. This method utilizes the actual size parameters of the packaging bag to establish a mathematical transformation relationship between the anomaly coordinates and the OCR area, enabling precise traceability from physical defects to batch information. When a sealing anomaly is detected, the system simultaneously outputs the batch code character image corresponding to the anomaly point, eliminating the need for manual timestamp matching and improving the location speed of problematic batches to the millisecond level. This significantly shortens the quality risk handling window and reduces the probability of non-conforming products leaving the market. Simultaneously, based on the density trend analysis of the distribution of residues in the same batch, a breakthrough is achieved in predicting batch risks from single-point anomalies, providing real-time data support for process optimization.
[0053] 2. By analyzing the spatial coordinate density variation trends of three consecutive production units, the risk of batch-level sealing failure can be accurately predicted. This method effectively utilizes the unique residue distribution characteristics of viscous liquid packaging, transforming data considered as interference signals in traditional detection into predictive factors. When the density value continues to increase, the probability calculation module is automatically triggered, and a quantitative risk value is generated by combining historical failure records, realizing the transformation from passive detection to proactive early warning. Combined with the hierarchical mechanism of instruction status codes, the production line can execute differentiated control strategies according to different risk levels, maximizing production efficiency while ensuring quality and safety, forming a data-driven closed-loop quality control system. Attached Figure Description
[0054] Figure 1 This is a flowchart of the OCR-based traceability-based early warning method for abnormal sealing of strip packaging according to the present invention. Detailed Implementation
[0055] 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. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0056] Example: Figure 1 This invention presents a method for early warning of abnormal sealing of strip packaging based on OCR traceability, which includes the following steps:
[0057] S1. Simultaneously acquire images of the sealing area and OCR area of the strip packaging bag;
[0058] S2. Determine whether the sealing status meets the preset sealing form standard based on the image of the sealing area. If it does not meet the standard, extract the coordinates of the abnormal position.
[0059] S3. Based on the physical size parameters of the strip packaging bag, convert the coordinates of the abnormal location into mapped coordinates in the OCR area coordinate system;
[0060] S4. Locate the target region corresponding to the mapped coordinates in the OCR region image, and recognize the batch-coded character image within the target region;
[0061] S5. Based on the successfully identified batch code character images, aggregate the distribution data of the residual material in the sealing area of all strip packaging bags in the current production period corresponding to the batch code character images, and generate a spatial coordinate density distribution map.
[0062] S6. When the density value of the spatial coordinate density distribution map in the preset coordinate range continues to increase for three consecutive production units, calculate the predicted value of the sealing failure probability of the corresponding batch.
[0063] S7. Bind the abnormal location coordinates, the successfully identified batch code character image, and the predicted value of the seal failure probability to generate a graded early warning instruction.
[0064] S1. Simultaneously acquire images of the sealed area and OCR area of the strip packaging bag, specifically as follows:
[0065] The industrial camera performs image capture while the conveyor belt operates at a constant speed; this constant speed is set to 0.5 meters per second based on the tensile strength test results of the strip packaging bag material; when the strip packaging bag passes through the fixed shooting position, the industrial camera receives the pulse signal sent by the photoelectric sensor at a trigger position 3.0 meters away from the start of the conveyor belt; the industrial camera uses a global shutter model; data is transmitted via gigabit Ethernet protocol; image frames are acquired at a sampling frequency based on a single packaging bag as the trigger unit; ensuring that the displacement of the packaging bag during image acquisition does not exceed 0.5 millimeters; the trigger position positioning error is controlled within ±5 millimeters; the displacement is measured in real time by an incremental rotary encoder; the encoder generates 10 pulse signals per millimeter of displacement.
[0066] The ring light source uses a mechanical bracket to adjust the illumination angle to eliminate the interference of aluminum foil reflection in the sealing area; the inner diameter of the ring light source is 60 mm; the installation height is set to 300 mm; the central axis of the light source forms a 45-degree angle with the normal of the packaging bag surface; the power output value of the light source is dynamically adjusted by a digital controller based on image analysis results; the adjustment mechanism is to calculate the grayscale standard deviation of the aluminum foil area after image acquisition; when the standard deviation value is greater than the set threshold of 80 gray levels, the power value increases by 5%; when the standard deviation value is less than 40 gray levels, the power value decreases by 2.5%; the main wavelength of the ring light source is selected from the 650 nm red light band; the diffuse reflectance of this band on the aluminum foil surface is 8 percentage points higher than the specular reflectance, as measured by a spectrophotometer.
[0067] The system simultaneously acquires images of the sealing area and the OCR area using a beam splitter prism system. The beam splitter prism input port receives imaging light from an industrial camera lens. The first output port connects to a 700nm long-pass filter to acquire the sealing area image. This filter blocks visible light with wavelengths less than 700nm and transmits near-infrared spectral light, allowing it to penetrate drug residues and capture the sealing texture. The second output port connects to a visible light sensor to acquire the OCR area image. The sensor's spectral response range covers wavelengths from 400 to 650nm. The contrast of the character area is enhanced through a hardware gain circuit, and the gain value is automatically compensated based on the median grayscale value of the background.
[0068] The timestamps of the sealing area image and the OCR area image are generated synchronously via a GPS timing module; the time synchronization accuracy reaches ±0.5 milliseconds; the timestamp data is written to the extended attribute field of the image file; the spatial position tag uses an absolute encoder to record the spatial coordinates of the packaging bag; the encoder resolution is set to 0.1 mm; the origin of the spatial coordinates is set to the zero point of the conveyor belt machinery; the position tag data package contains the X-axis coordinate value, Y-axis coordinate value, and rotation angle value of the lower left corner vertex of the packaging bag in the conveyor belt coordinate system; the sealing area image and the OCR area image corresponding to each packaging bag share a unique identification number; this number consists of hexadecimal characters; it is generated by concatenating the machine serial number, date and timestamp, and serial number in sequence; the identification number is also written to the operation log database of the production line control system and the image file header.
[0069] The specific formula for adjusting the power of the ring light source is expressed as follows:
[0070] ;
[0071] in, This indicates the adjusted power output value of the light source, in watts (W). This indicates the original power output value before the light source was adjusted, in watts (W). This represents the power response regulation coefficient, a dimensionless proportional constant. This represents the actual standard deviation of grayscale values for the aluminum foil region in the current image, expressed in grayscale levels. This represents the ideal target value for the standard deviation of grayscale in the aluminum foil area, expressed in grayscale levels.
[0072] The ideal grayscale standard deviation is set to 60 grayscale levels; the adjustment coefficient k is set to 0.02; and the upper limit of the power adjustment step size is set to 10% of the total power. When the actual grayscale standard deviation deviates from the ideal value by more than 30 grayscale levels, the power calibration mode is triggered; the calibration mode gradually adjusts in 10% increments until it falls within the standard deviation regression threshold range. The industrial camera trigger position deviation compensation mechanism is as follows: the compensation delay is calculated based on the real-time displacement data of the encoder; the delay compensation value = measured position deviation / conveyor belt speed; this value is written to the motion compensation register of the PLC controller; the register address is mapped to the camera trigger timing controller.
[0073] The optical path calibration process for the beam splitter prism system includes: using a standard checkerboard calibration plate; acquiring an image at a distance of 50 cm from the calibration plate; calculating the optical distortion rate in the X / Y dual-axis directions; when the distortion rate is greater than 1%; rotating the prism bracket fine-tuning screws to compensate for the optical axis; adjusting the angle by 0.5 degrees each time. The visible light sensor gain compensation formula is:
[0074] ;
[0075] in, This indicates the gain compensation factor that the sensor needs to be set; it is a dimensionless proportional value. This represents the sensitivity coefficient for gain adjustment, expressed per gray level. This represents the preset ideal background grayscale reference value, in grayscale levels. This represents the average background grayscale value obtained by the sensor, expressed in grayscale levels.
[0076] The ideal background grayscale value is set to 160 grayscale levels; the gain adjustment step is 0.1 times. The absolute encoder spatial coordinate transformation method is as follows: A rectangular coordinate system is established with the beginning of the conveyor belt as the origin; the positive X-axis is the conveying direction; the Y-axis is perpendicular to the conveying plane; the coordinates of the lower left corner vertex of the packaging bag are calculated using the fixed offset of the mechanical clamp positioning pin; the X-axis offset is 2 mm; the Y-axis offset is 3 mm; the coordinate values are retained to two decimal places.
[0077] S2. Based on the image of the sealing area, determine whether the sealing status meets the preset sealing form standard. If it does not meet the standard, extract the coordinates of the abnormal position. The specific implementation is as follows:
[0078] The continuity of the heat seal line is detected in the sealed area image. The detection method is edge extraction using the Sobel operator, which uses a 3×3 pixel convolution kernel. The gradient magnitude is calculated in both the horizontal and vertical directions. When a broken area with a length exceeding 0.5 mm is detected, or a false seal area with a local gradient magnitude below 50 gray units is detected, a break or false seal is determined. The threshold for this determination is based on the analysis of sealing strength test data from 100 qualified samples. Qualified samples are defined as packaging bags with a sealing strength of 20 Newtons / 15 mm or higher after airtightness testing. The 0.5 mm break length threshold is determined by microscopic measurement of failed sealing samples.
[0079] When a break or false seal is detected, the texture ripple direction of the sealing edge is analyzed. The specific method is as follows: A 1mm wide image area is extracted from both sides of the center line of the heat seal. This area is processed using a Gabor filter bank. The filter bank parameters include: a directional angle range covering 0 to 180 degrees; an interval angle of 15 degrees; and a spatial wavelength set to twice the standard heat seal texture spacing (e.g., a wavelength of 0.8mm when the standard spacing is 0.4mm). The peak values of the filter response in each direction are recorded during the analysis. When the directional angle deviation corresponding to the maximum response value exceeds ±5 degrees of the standard heat seal direction, the texture ripple direction is determined to be inconsistent with the preset angle range. This tolerance threshold of ±5 degrees is based on statistical analysis of 50 failed sealing samples; when the angle deviation is greater than 5 degrees, the probability of seal failure reaches over 85%.
[0080] Non-uniform illumination compensation is performed on the sealed area with abnormal texture. The compensation process is implemented by grid partitioning: the area to be processed is divided into 10×10 unit grids; each grid size is 1 square millimeter; the median gray value of each grid area is calculated; the first grid in the upper left corner is used as the reference point; compensation value is generated based on spatial distance attenuation; the distance attenuation coefficient is set to 0.01 per millimeter; the compensation formula is expressed as: target grid compensation value = reference grid gray value × (1 - 0.01 × distance in millimeters); gray-level consistency verification is performed on the compensated image: the gray standard deviation of the entire sealed area is calculated; when the standard deviation value is greater than 25 gray levels, the verification is considered to have failed; the threshold of 25 gray levels is determined by material reflectivity testing: 10 qualified sealed areas under different illumination conditions are selected; the upper limit of the standard deviation is measured to be 25 gray levels.
[0081] After grayscale verification fails, the abnormal location coordinates are located and transformed. The location method is to extract the smallest bounding rectangle of the abnormal contour. The intersection of the diagonals of the rectangle is calculated as the coordinate center point. The pixel coordinates of this point are recorded with the upper left corner of the image as the origin. The process of converting pixel coordinates to physical coordinates is as follows: physical coordinate X value = pixel coordinate X value × single pixel physical size + lower left corner X-axis offset. The single pixel physical size is calibrated to 0.05 mm / pixel by a standard calibration plate. The lower left corner offset is a fixed value of 3.0 mm. This offset is measured by a laser positioning system: a reference point is set on the conveyor belt clamp. The average distance from the reference point to the actual lower left corner of the packaging bag is 3.0 mm.
[0082] The sub-pixel precision positioning method for heat seal line breakage detection is as follows: Based on pixel-level detection; a circular search area with a diameter of 1 mm is delineated centered on the initial coordinates; the gradient change rate of each point within the area is calculated; a quadratic surface fitting is used to locate the gradient peak point; the coordinate accuracy of this point reaches 0.01 mm; the iteration termination condition is that the coordinate offset is less than 0.005 mm for three consecutive iterations or the maximum number of iterations reaches 50. The texture analysis direction angle calibration process includes: with the packaging machine stopped; attaching a high-precision angle gauge to the heat seal roller; acquiring a reference image and calculating the reference angle value; writing this value into the system parameter configuration file and marking the calibration date.
[0083] Pixel physical size calibration procedure: A NIST-certified standard ceramic calibration plate is used; the plate surface is etched with a grid line spacing of 0.1 mm; after image acquisition, the average number of pixels between 10 adjacent grid lines is calculated; for example, 1.0 mm of actual distance between 10 grid lines corresponds to 200 pixels; therefore, the single pixel size = 1.0 / 200 = 0.005 mm; the measured value of this system is stable at 0.05 mm / pixel; this difference is corrected by adjusting the lens magnification. Optimization process of illumination compensation distance attenuation coefficient: Under controlled variable conditions; the attenuation rate is adjusted from 0.005 to 0.02; when 0.01 is taken, the standard deviation after compensation drops to the minimum value of 18 gray levels; below the acceptable line of 25 gray levels; therefore, the final attenuation rate is selected as 0.01.
[0084] The origin of the physical coordinate system remains consistent with subsequent steps: the positive X-axis is parallel to the bag length from left to right; the Y-axis is along the bag width from bottom to top; the Z-axis is perpendicular to the bag surface; the origin is defined at the lower left corner of the packaging bag, coinciding with the center of the contact surface of the conveyor belt positioning fixture. The self-updating mechanism for the judgment threshold: after the system completes the inspection of every 500 packaging bags, it automatically retrieves the inspection data of the 50 most recent qualified samples and recalculates the grayscale consistency standard deviation threshold as the new benchmark value; for example, the new threshold range is updated to 20-28 gray levels; this dynamic adjustment can adapt to slow changes in ambient light.
[0085] S3. Based on the physical size parameters of the strip packaging bag, convert the coordinates of the abnormal location into mapped coordinates in the OCR area coordinate system. The specific implementation is as follows:
[0086] Obtain the actual physical length and width of the strip packaging bag. The physical length is obtained by reading the production line packaging specification parameter file, which is stored in the industrial control computer's memory address range of 0x5000-0x50FF. The parameters are recorded in millimeters as the design length value; for example, the physical length value corresponding to material batch number X190901 is 142.0 millimeters. The physical width is obtained by measuring the spacing between the conveyor belt positioning fixtures; the average value of 10 packaging bags is measured continuously using a digital caliper; for example, the measured average value is 24.3 millimeters. The measured values are retained to one decimal place.
[0087] A two-dimensional coordinate system is established on the surface of the packaging bag based on its physical length and width values. The coordinate system is defined as follows: the origin and zero point are the lower left corner of the packaging bag, which is fixed in place by a mechanical positioning pin; the length direction is the positive X-axis; the width direction is the positive Y-axis; the coordinate system scale is set in millimeter increments; the coordinate range is 0 to 142.0 mm for the X-axis and 0 to 24.3 mm for the Y-axis; the coordinate system data is stored in a two-dimensional array data structure; the array row index corresponds to the integer part of the X-axis in millimeters; the column index corresponds to the integer part of the Y-axis in millimeters; coordinate values accurate to one decimal place are stored using a floating-point register.
[0088] Read the coordinate components of the abnormal location in the two-dimensional coordinate system; the abnormal location coordinates come from the physical coordinate system coordinates output in step S2; the component reading method is to perform double-precision matching in the coordinate coefficient group; the matching condition is that the absolute value of the difference between the coordinate value and the array index value is less than 0.05 mm; when there are multiple matching points, the nearest neighbor interpolation method is used to determine the final position; the interpolation calculation formula is: target component value = (adjacent high-order index value × weight coefficient) + (adjacent low-order index value × (1 - weight coefficient)); the weight coefficient is dynamically calculated based on the decimal places of the coordinates; for example, when the coordinate X = 35.72 mm; the weight of the value corresponding to index 35 is 0.28; the weight of the value corresponding to index 36 is 0.72.
[0089] The mapped coordinate components are calculated based on the fixed position offset of the OCR area on the surface of the packaging bag. The offset is divided into X-axis offset and Y-axis offset. The offset data comes from the position parameter table of the laser marking machine. This parameter table is stored in sector 0x2100 of the programmable memory. The storage format is 16-bit integer data. The unit conversion ratio is 0.01 mm / unit. For example, the value 3500 represents 35.00 mm. The calculation formula for the mapped coordinate components is: Mapped coordinate X component = Abnormal position coordinate X component - X-axis offset; Mapped coordinate Y component = Abnormal position coordinate Y component - Y-axis offset. The calculation process retains three decimal places of precision.
[0090] The final mapped coordinates are generated by combining the mapped coordinate components. The combination method is to construct a three-dimensional data structure. The structure contains the following fields: the X coordinate component data type is a single-precision floating-point number; the Y coordinate component data type is a single-precision floating-point number; the coordinate system identifier is set to the OCR coordinate system code value 0xA5; the data packaging protocol refers to the MODBUS-RTU standard; the X component bytes and Y component bytes are merged into a continuous four-byte data stream; the low-order byte comes first and the high-order byte comes last; for example, X=25.30 mm (0x41CA0000) and Y=8.20 mm (0x41033333) are packaged into a byte stream [00 00 CA 41 33 33 03 41].
[0091] The coordinate transformation accuracy verification method is as follows: Select test point locations; mark the actual measurement point locations on the surface of the packaging bag; use a coordinate measuring machine to determine the absolute coordinates; simultaneously input the coordinates into the system to calculate the mapped coordinates; the error judgment standard is that the absolute value error is less than 0.1 mm; when the error exceeds the threshold for three consecutive tests, the calibration mode is activated; the calibration method is to adjust the offset compensation coefficient; the compensation value calculation formula is: new offset = original offset + (actual position value - system calculated value) × 0.8; the coefficient 0.8 is set according to the damped oscillation principle; the maximum number of calibrations is limited to 10.
[0092] The dynamic offset compensation mechanism is implemented through linkage with a temperature sensor; a PT100 temperature sensor is integrated into the laser marking head; the offset is automatically adjusted by 0.001 mm / ℃ for every degree Celsius temperature change; the temperature compensation coefficient is determined based on the material's coefficient of thermal expansion; the linear expansion coefficient of the packaging bag composite film material is 8.5 × 10⁻⁶. -5 / ℃; The compensation calculation formula is: compensation offset = temperature change × material expansion coefficient × original offset; for example, when the temperature rises by 5℃; the 35 mm offset compensation value = 5 × 0.000085 × 35 = 0.014875 mm.
[0093] Key parameters for coordinate system transformation are stored in non-volatile FRAM; the address allocation table is as follows: physical length value address 0x6000 (floating-point); physical width value address 0x6004 (floating-point); X-axis offset address 0x6010 (integer); Y-axis offset address 0x6014 (integer); read / write instructions use the SPI protocol; clock frequency 10MHz; data verification uses the CRC-8 algorithm; polynomial coefficient 0x07. Parameters are automatically loaded each time the system starts; verification is forcibly refreshed every 24 hours.
[0094] The optimized process for coordinate component interpolation calculation is as follows: Establish a subpixel-level coordinate scale table; insert 20 subdivision scales between millimeter integer scales; each subdivision scale represents 0.05 millimeters; the coordinate values of the subdivision scales are generated through bilinear interpolation; for example, establish subdivision points between the main scales 35 millimeters and 36 millimeters: point number 1 corresponds to 35.05 millimeters; value = (index 35 value × 0.95) + (index 36 value × 0.05); and so on up to point number 20.
[0095] Boundary protection strategy for mapped coordinate components: When the calculated X component is greater than the actual length of the OCR area, it is forcibly corrected to the maximum boundary value of the area; the same applies to the Y component. For example, if the OCR area size is 15 mm × 10 mm, and X = 16.2 mm, it is corrected to 15.0 mm. The correction triggers alarm event EVT_015, which is recorded in the system log. Smoothing filtering is performed before the mapped coordinates are output; a three-point moving average method is used; the formula is: final coordinates = (current value × 0.5 + previous value × 0.3 + previous value × 0.2); this reduces coordinate jitter caused by mechanical vibration.
[0096] S4. Locate the target region corresponding to the mapped coordinates in the OCR region image, and recognize the batch-coded character image within the target region. Specifically, this is implemented as follows:
[0097] In the coordinate mapping application stage, a rectangular recognition frame is drawn with the coordinate value as the center point. The long side of the rectangular recognition frame is set to 1.5 times the standard height of the laser-marked character. For example, when the standard character height is 2 mm, the height of the rectangular frame is 3.0 mm. The width is determined by the total width of the characters. According to the number and spacing specifications of the laser-marked characters on the surface of the bar packaging bag, for example, the physical total width of a 9-digit character code is 18.0 mm, then the width of the rectangular frame is 22.0 mm. This magnification ratio is verified and determined through 200 sets of test samples to ensure complete coverage of possible character position offsets. The boundary of the rectangular frame maintains a minimum safety distance of 0.5 mm from the edge of the packaging bag.
[0098] The dynamic local binarization process is as follows: The image within the rectangular recognition box is divided into 4×4 sub-grids; the gray-level histogram of each sub-grid region is calculated; the valley value of the histogram is taken as the binarization threshold of that grid; when the threshold difference between adjacent grids exceeds 40 gray levels, interpolation smoothing is initiated; the smoothing method uses cubic spline curve fitting; for example, the difference between the threshold of grid 1 (120) and the threshold of grid 2 (160) is 40; the inserted intermediate threshold sequence is 130, 140, and 150; during processing, a 0.5 mm wide overlap area is retained for feathering transition; after binarization, the proportion of aluminum foil reflection pixels in the background area of the image is reduced to below 5%.
[0099] Extracting connected component sets from a binarized image: The eight-neighbor connectivity labeling algorithm is applied to scan the entire image; continuous regions with the same pixel value are labeled; the minimum connected component area is limited to 50 square pixels, corresponding to a physical size of 0.125 square millimeters; noise points with too small an area are filtered out; the connected component set is stored in a linked list data structure; each node contains the coordinates of the bounding rectangle of the region, the area value, and the location information of the center point.
[0100] Interference region filtering is performed based on the connected component set: the aspect ratio of the bounding rectangle of each connected component is calculated; the aspect ratio threshold range is set from 0.2 to 5.0; this range covers the printing specifications of batch-encoded characters; for example, the aspect ratio of the number "1" is 0.3; the aspect ratio of the letter "W" is 1.2; connected components with aspect ratios of 0.1 or 6.0 are directly eliminated; in addition, shape fit verification is performed: the minimum bounding rectangle of the standard character template is used as a reference; the intersection-union ratio (IUR) of the connected component rectangle and the reference rectangle is calculated; the IUR threshold is set to 0.65; regions below this value are considered invalid.
[0101] Projection segmentation is performed along the character arrangement direction: the projection direction is determined according to the installation parameters of the laser marking equipment; for example, the default setting is horizontal to the right; this orientation is parallel to the length direction of the packaging bag; the projection method is to perform vertical pixel density integration within the rectangular recognition box; the specific formula is expressed as: projection value X = the number of binarized pixels in the Xth column accumulated along the Y direction; the valley point position of the projection curve is identified; the valley point is defined as three consecutive columns of projection values being less than 35% of the peak value; the valley point position is used as the segmentation boundary; the segmentation process ensures that each character area retains at least a 0.1 mm safety margin; after segmentation, several batches of coded character sub-images are output.
[0102] The optimization process for setting the size of the rectangular recognition frame is as follows: A size adaptive model is established; the model input parameters include the character size tolerance coefficient and the thermal deformation compensation value of the packaging bag; the tolerance coefficient is between 1.2 and 1.8; obtained through linear regression analysis of 100 sets of offset data; thermal deformation compensation is based on the material's temperature expansion characteristics: a 1-micron size increment is compensated for every 1℃ temperature rise; the mechanism to ensure the positioning accuracy of the rectangular frame is: a reference point calibration is performed after every 20 recognitions; the calibration method is to identify a dedicated positioning mark symbol; when the deviation between the actual recognition position and the theoretical position exceeds 0.05 mm, the coordinate system offset parameters are automatically adjusted.
[0103] The optimization strategy for binarized mesh generation is as follows: 8×8 fine mesh is used in areas with strong aluminum foil reflection (based on the S1 grayscale distribution map); 4×4 mesh is maintained in ordinary areas; mesh type identifiers are pre-written into the configuration file; the location is referenced from the laser marking machine's work log; the mesh threshold calculation method adds an illumination compensation factor: final threshold = histogram valley value × (1 + illumination intensity coefficient); the coefficient ranges from 0 to 0.15; data is provided in real time by the S1 ambient light sensor; the maximum time constraint for partition processing is 80 milliseconds.
[0104] The criteria for setting the aspect ratio threshold of connected components are as follows: all valid coding images from the packaging production line were collected over three months; the aspect ratio distribution of 12,350 character samples was statistically analyzed; the aspect ratio range covering 98% of valid characters was determined to be [0.25, 4.5]; this was conservatively extended to [0.2, 5.0] as the execution threshold; the standard character template library for intersection-union verification is updated monthly; the update method is to randomly select 100 qualified characters from the current day to generate a new template; the template image is normalized to a size of 50×100 pixels.
[0105] Orientation tolerance handling for projection segmentation: Create projection direction groups within a ±10 degree range of the reference orientation; for example, in addition to the default horizontal direction; add two projection paths at 85 degrees and 95 degrees; calculate the peak-valley contrast of the projection curves of each path; select the path with the largest contrast as the actual segmentation direction; this mechanism adapts to the ±8 degree angle deviation of the packaging bag on the conveyor belt; sub-pixel positioning of the segmentation boundary adopts a Gaussian fitting algorithm: take 7 points near the valley point; fit the extreme points of the parabolic function; the positioning accuracy reaches 0.1 pixels; corresponding to a physical size of 0.005 mm.
[0106] The data structure for outputting batch-encoded character images is as follows: each character image is encapsulated as an independent data unit; the unit header information includes the original position coordinates of the character (based on the mapped coordinate system), the character sequence number, and the credibility score; the credibility score is calculated by weighting three parts: binarization consistency weight 40%, aspect ratio matching weight 30%, and projected contour clarity weight 30%; the scoring threshold is set to 0.75; character units with a score below this value trigger a re-recognition process; the maximum number of retries is set to 3; and the time limit is 100 milliseconds.
[0107] Environmental adaptability parameter configuration table: Set compensation parameter groups in the temperature range of 30-50℃; each group includes 12 parameters such as rectangular frame size compensation coefficient and binarization threshold offset; the parameter group switching condition is that the measured value of the infrared temperature sensor crosses a 5℃ range; for example, the size compensation coefficient of the 35℃ group is 1.02; the threshold offset is +8 gray levels; this configuration is obtained through constant temperature chamber simulation test; the test temperature gradient is set to 5℃; 500 sets of data are collected at each temperature point.
[0108] All image processing results are error-recorded: a metadata field is added to the output data structure to record operation traces, including the number of binarization grid changes, connected component filtering ratio, and projection segmentation correction amount; when the recognition success rate is continuously below 95%, an expert review mode is initiated; this mode freezes the current parameter configuration; the 100 most recent failed cases are uploaded to the quality analysis system; the frozen state is lifted after manual intervention; the time constraint for the entire processing chain is 250 milliseconds; the time allocation strategy is 50 milliseconds for rectangular positioning, 70 milliseconds for binarization processing, 60 milliseconds for connected component analysis, and 70 milliseconds for projection segmentation; time monitoring is implemented through the timestamp counter of the real-time operating system; the timeout error code is ERR_TM_4.
[0109] S5. Based on the successfully identified batch code character images, aggregate the distribution data of residue in the sealing area of all strip-shaped packaging bags within the current production period corresponding to the batch code character images, and generate a spatial coordinate density distribution map. The specific implementation is as follows:
[0110] Extract the pixel coordinates of the residue edge contour from the image of the sealed area of a strip packaging bag associated with the batch code character image; the association method is to match data through shared timestamps; the timestamp accuracy is ±1 millisecond; the extraction process uses the Cannibal edge detection operator; the operator parameters are set as follows: Gaussian filter kernel size 5×5 pixels; low threshold 50 gray levels; high threshold 150 gray levels; the detection result generates a set of closed contour points; each point contains pixel coordinates X and Y values; the contour point set is stored as a dynamic array; the array index order is arranged along the contour direction; the minimum contour area is limited to 100 square pixels, corresponding to a physical size of 0.25 square millimeters; and minor noise is filtered out.
[0111] The pixel coordinates of the residue edge contour are converted to physical coordinates. The conversion reference is the lower left corner of the packaging bag as the origin. The conversion formula is: Physical coordinate X = Pixel coordinate X × Pixel physical size + Lower left corner X offset. The pixel physical size is fixed at 0.05 mm / pixel. The lower left corner X offset is 3.0 mm. This offset is determined by calibration through a mechanical positioning system. The conversion calculation uses a floating-point arithmetic unit. Three decimal places are retained. The converted physical coordinates are written into a structure. The structure contains the following fields: Batch code identifier (16 bytes), Timestamp (8 bytes), Physical coordinate X (4-byte floating point), and Physical coordinate Y (4-byte floating point).
[0112] Accumulate the physical coordinates of residues from the same batch within a preset time window; the time window is defined as the current production batch period plus the maximum lag time; the production batch period starts from the batch start signal and ends with the batch end signal; the maximum lag time is set to 5 seconds; the accumulation method is as follows: create a batch-specific memory buffer; the buffer capacity is 10,000 coordinate points; when a new coordinate point arrives, it is stored in a circular queue; when the buffer is full, the oldest data is overwritten; the coordinate points corresponding to the same batch code character image are indexed by a hash table; the hash key value is the CRC32 checksum of the batch code string.
[0113] The density value per unit area is calculated based on cumulative coordinates. The calculation area is divided according to the following rules: the length of the packaging bag is the X-axis, and the width is the Y-axis. A 1 mm × 1 mm grid coordinate system is established. The density value is calculated using the following formula: grid density = number of coordinate points in the grid / grid area. The grid area is fixed at 1 square millimeter. The density value is rounded to two decimal places. The calculation results generate a two-dimensional density matrix. The number of rows in the matrix is equal to the physical length value divided by 1 mm and rounded down. For example, a length of 142 mm corresponds to 142 rows. The number of columns is equal to the physical width value divided by 1 mm and rounded down. For example, a width of 24 mm corresponds to 24 columns.
[0114] Spatial coordinate density distribution map generation process: Map the density matrix to a pseudo-color image; density values from 0 to 0.5 points / square millimeter are mapped to the blue family; 0.5 to 2.0 points / square millimeter are mapped to the green family; values above 2.0 are mapped to the red family; color gradation is achieved through a lookup table; the lookup table has a preset 256-level gradient color spectrum; the image resolution is set to 10 pixels per millimeter; the generated image size is 1420×240 pixels; the image file format uses lossless PNG encoding; the batch code and generation timestamp are written to the file header.
[0115] Optimization mechanism for residue contour extraction: Dual edge detection is used in the reflective area of the aluminum foil (based on S1 light source adjustment records); first, a high threshold (200 gray levels) is performed to detect the main contour; then, a low threshold (80 gray levels) is performed to supplement weak edges; after the two results are superimposed, morphological closing operations are performed to fill the gaps; the closing operation kernel size is 3×3 pixels; the contour area is calculated using Green's formula.
[0116] ;
[0117] in, This represents the calculated area of the closed contour region, expressed in square millimeters (mm²). This represents the total number of feature points that constitute the contour boundary. This represents the index number of the feature point being calculated, with a value ranging from 1 to N; This represents the X-axis coordinate value of the i-th feature point in the contour feature point sequence; This represents the Y-axis coordinate value of the i-th feature point in the contour feature point sequence; This represents the X-axis coordinate value of the (i+1)th feature point in the contour feature point sequence; This represents the Y-axis coordinate value of the (i+1)th feature point in the contour feature point sequence; when hour, and This achieves a closed loop.
[0118] Dynamic adjustment strategy for time window: The maximum lag time is corrected in real time according to the production line speed; the correction formula is: lag time = 5 seconds × (base speed / current speed); the base speed is 0.5 m / s; the current speed is calculated by the encoder pulse frequency; for example, when the speed increases to 0.6 m / s, the lag time is adjusted to 4.17 seconds; the buffer capacity is adjusted synchronously: new capacity = original capacity × (current speed / base speed); the upper limit is 20,000 points.
[0119] Boundary handling for density calculation: When the coordinate point is located at the grid boundary, a four-grid weighted allocation method is used; for example, the coordinate point (35.3, 12.7) is assigned to grids (35, 12), (35, 13), (36, 12), and (36, 13); the weight coefficient is calculated inversely proportional to the distance: the weight of grid (35, 12) = 1 / (0.3 + 0.3) = 1.67; and so on; the total weight is normalized to 1.
[0120] Outlier suppression in distribution map generation: Perform 3×3 median filtering on the density matrix; the filter kernel traverses all grids; replace the center value with the median of the nine-square grid; detect outlier grids after filtering; the outlier determination criterion is: grid value > 3 times the average of neighboring grids; outlier grid values are corrected to the neighborhood mean; the maximum correction ratio is limited to 5% of the total number of grids.
[0121] Data storage and transmission protocol: The density matrix is stored as a CSV format text file; each row represents the X-axis density sequence when the Y-axis is fixed; file naming rule: batch code_start timestamp.csv; the distribution map image file is transmitted to the server via Gigabit Ethernet; the transmission protocol is TFTP; port number 69; packet size 512 bytes; transmission integrity is verified using MD5 hash value comparison.
[0122] Temperature compensation mechanism: Material thermal expansion compensation is added during coordinate transformation; compensation amount = temperature change × linear expansion coefficient × original size; the expansion coefficient of the composite membrane material is taken as 8.5 × 10⁻⁶. -5 / ℃; the temperature change is acquired in real time by a patch sensor; for example, when the temperature rises by 10℃; the X-direction compensation is 10 × 0.000085 × 142 = 0.1207 mm.
[0123] Processing timeliness guarantee scheme: Multi-threaded parallelism is enabled in the coordinate extraction stage; the number of threads is equal to the number of CPU cores; each thread processes an independent image partition; density calculation is accelerated by GPU; CUDA core allocation scheme: 142 thread blocks in the X-axis direction; 24 thread blocks in the Y-axis direction; single thread block processes single grid calculation; time constraint is 500 milliseconds; timeout triggers degradation mode: grid size is increased to 2 mm × 2 mm.
[0124] Quality monitoring indicators: The system records key parameters for each batch, including average density value, peak density location, and number of valid coordinate points. When the peak density increases by more than 20% for three consecutive batches, the sampling frequency is automatically increased to twice per bag. The data storage period is 90 days. The storage medium uses a RAID5 disk array. Daily incremental backups are performed to a remote server.
[0125] S6. When the density value of the spatial coordinate density distribution map continuously increases for three consecutive production units within the preset coordinate range, calculate the predicted sealing failure probability value for the corresponding batch. The specific implementation is as follows:
[0126] Obtain the spatial coordinate density distribution map of three consecutive production units within a preset coordinate interval. The preset coordinate interval is set by dividing the packaging bag sealing area into a high-concern sub-region. This region is determined based on historical fault location statistics. For example, a rectangular area of 80 mm to 90 mm on the X-axis and 10 mm to 15 mm on the Y-axis is selected. The production unit is defined from the batch management system file. Each production unit corresponds to a processing cycle with a fixed material input. For example, 120 kg of raw materials corresponds to one production unit. The spatial coordinate density distribution map file is obtained sequentially through the database timestamp index. The acquisition condition is three consecutive units within the same production batch. The time interval fluctuation is controlled within ±5 seconds.
[0127] Calculate the average density value of each spatial coordinate density distribution map; the calculation method is to obtain the arithmetic mean of the density values of all grid cells within the preset coordinate interval; the specific formula is: average density value = sum of grid density values / number of grids; the formula for calculating the number of grids is: (X-axis length range) × (Y-axis length range) / grid area; for example, an X-axis range of 10 mm corresponds to 10 grids; a Y-axis range of 5 mm corresponds to 5 grids; the total number of grids is 50; the density value is retained to three decimal places; the calculation results form a density value sequence; the sequence is arranged in the order of production units and stored as a dynamic array.
[0128] Verify the monotonically increasing condition of the density value sequence; the verification algorithm is to traverse the sequence elements; compare whether the nth value is less than the (n+1)th value; this operation is performed twice consecutively (n starts from 1); the verification terminates when the (n+1)th value is found to be less than or equal to the nth value; the tolerance mechanism is set to allow 0.5% measurement fluctuation; for example, the sequence [1.200, 1.215, 1.230] is determined to be increasing; the sequence [1.200, 1.205, 1.198] is determined to be failing; the verification result is stored as a Boolean type flag.
[0129] When the monotonically increasing condition is met, the database retrieves the same density growth pattern. The growth pattern is defined as a combination of two consecutive growth amplitudes. The amplitude calculation formula is: Amplitude 1 = (2nd density value - 1st density value) / 1st density value; Amplitude 2 = (3rd density value - 2nd density value) / 2nd density value. The amplitude precision is retained to two decimal places. The growth pattern storage format is "Amplitude 1:Amplitude 2"; for example, "0.02:0.015" indicates an initial growth of 2% and a second growth of 1.5%. The database retrieval uses an exact matching algorithm; the range tolerance is set to ±0.003; the hit result returns the number of sealing failure records.
[0130] The predicted probability of sealing failure is calculated based on the search results. The calculation formula is: Predicted probability = Number of sealing failure records / Total number of occurrences of the matching pattern. The denominator data comes from the pattern statistics table, which records the historical occurrences of each growth pattern. The calculation result is converted into a percentage form. For example, a calculated value of 0.35 represents 35%. The value is kept as an integer. The predicted probability is stored as an 8-bit integer and written into the early warning event data packet.
[0131] Tolerance rule optimization for density growth patterns: When no identical growth pattern is matched, an approximate matching mechanism is activated; the approximate range is set to ±0.005 amplitude difference; the matching priority order is: 1) same growth rate combination; 2) growth rate 1 deviation ≤ 0.005 and growth rate 2 is the same; 3) growth rate 2 deviation ≤ 0.005 and growth rate 1 is the same; 4) both growth rate deviations ≤ 0.005; when multiple patterns are matched, the one with the highest failure probability is selected.
[0132] Historical database construction specifications: collect production data for no less than 6 months; the minimum number of occurrences of the density growth pattern in the database is limited to 3 times; the data table structure includes: pattern number (primary key), growth pattern string, number of sealing failures, and total number of occurrences; the database index is built on the growth pattern string field; a B+ tree index structure is used; the retrieval response time is required to be less than 200 milliseconds; data statistical analysis tasks are executed at 1:00 AM every day.
[0133] Outlier handling mechanism in growth calculation: When a density value is abnormally high (e.g., greater than 3 times the standard deviation of the average), a review process is triggered. The review method is to obtain alternative data from three adjacent production units. The substitution rule is to advance one production unit. The review pass rate threshold is set to 85%. If the review fails three times, the sequence calculation is terminated. An error log ERR_DN_6 is recorded.
[0134] Confirmation criteria for sealing failure records: Any of the following conditions must be met: 1) Online airtightness test fails; 2) Leakage is found during sampling and unpacking inspection; 3) Customer complaint is verified; Confirmed failure events are marked with timestamps and fault coordinates; Record sheets are audited and cleaned every quarter; Retention period is five years.
[0135] Dynamic correction method for probability prediction values: Establish a probability confidence assessment model; confidence = min(total occurrences of matching patterns, 50) / 50; calculate the final prediction value = original probability value × confidence + baseline value × (1 - confidence); the baseline value is the average failure probability of the month; when the total occurrences are ≥50, the confidence is 100%; for example, original probability 60%; confidence 80%; baseline value 10%; then the final probability = 60% × 0.8 + 10% × 0.2 = 50%.
[0136] The fault warning linkage mechanism activates triple protection when the predicted value exceeds 30%: 1) Increase the detection frequency to twice per bag; 2) Reduce the production line speed by 20%; 3) Output the warning code to the Kanban system; the warning code is defined as a 5-level hierarchical structure; each 10% increase in the predicted value corresponds to a one-level increase; the highest level 5 triggers equipment shutdown for inspection.
[0137] Quality control closed loop: Monthly prediction accuracy report generated; statistical model includes true positive rate and false positive rate; when the false positive rate exceeds 15% for three consecutive months; start retraining of growth pattern library; retraining method is to add new fault feature dimension; add "density spatial distribution pattern" classification index; reclassify growth pattern categories.
[0138] S7. The abnormal location coordinates, successfully identified batch code character images, and predicted seal failure probability values are bound together to generate a tiered early warning instruction. The specific implementation is as follows:
[0139] The coordinates of the abnormal location are timestamped and synchronized with the successfully identified batch coded character images. The time stamping reference uses a GPS atomic clock timing signal. The time source accuracy is ±0.1 milliseconds. The synchronization marking method is to attach the same time identifier to both data types. The identifier format is a 64-bit integer timestamp. The content is the number of milliseconds since 00:00 UTC on January 1, 1970. The marking operation is completed within 2 milliseconds after data acquisition. After marking, the absolute value of the time difference is verified. When the difference exceeds 1 millisecond, the data set is discarded and a re-acquisition process is triggered. The maximum number of re-acquisitions is set to 3. The time verification mechanism is implemented using a hardware timer with a clock frequency of 100MHz.
[0140] The system matches the predicted probability of seal failure against a predefined threshold range of command status codes. The predicted probability value is input from 0 to 100%. The threshold range is divided as follows: 0%–20% corresponds to code 100 (no warning); 21%–40% corresponds to code 200 (observation level); 41%–60% corresponds to code 300 (warning level); 61%–80% corresponds to code 400 (emergency level); and 81%–100% corresponds to code 500 (shutdown level). The range boundaries include the lower limit but not the upper limit. The matching process involves sequentially comparing whether the probability value falls within each range. Upon a match, the corresponding command status code integer value is output. The code is stored as an 8-bit unsigned integer.
[0141] Generate a data packet containing timestamp data of abnormal location coordinates, timestamp data of successfully identified batch coded character images, and instruction status codes. The data packet structure adopts TLV (Type-Length-Value) format. The type field is defined as follows: 0xA1 identifies abnormal location coordinates; 0xB1 identifies batch character images; 0xC1 identifies instruction codes; the length field records the number of bytes occupied by subsequent values; the value field stores the specific data content; the value field of abnormal location coordinates is stored as two floating-point numbers (4 bytes for X coordinate, 4 bytes for Y coordinate); the value field of batch character images stores JPEG compressed image data; the compression quality parameter is set to 85%; the instruction status code occupies 1 byte; a 4-byte synchronization header 0xAA55AA55 is appended to the data packet header; and a 2-byte cyclic redundancy check code is appended to the tail.
[0142] The data packets are converted into a hierarchical early warning instruction format that can be parsed by the production line control system. The conversion rules are based on the PLC communication protocol specification. The target format is defined as follows: start character 2 bytes (0x3A01); function code 1 byte (0x05 indicates an early warning instruction); data length 2 bytes; payload area is the original data packet content; check area 2 bytes (Modbus-CRC16); the conversion process includes data reassembly and byte order adjustment; the reassembly method is to rearrange the payload of the TLV data packet according to the field order; the byte order is uniformly converted to big-endian mode; the converted instructions are sent via industrial Ethernet; target port number 502; transmission interval 50 milliseconds; retransmission count 3 times.
[0143] Fault-tolerant handling of timestamp synchronization: When the GPS signal is interrupted, it automatically switches to the local high-stability crystal oscillator clock; the crystal oscillator accuracy is 0.5ppm; the switching time is less than 100 microseconds; the clock source status is recorded in the system log; time reference calibration is triggered when the crystal oscillator has accumulated more than 72 hours of operation; the calibration method is to compare the time difference of the most recent valid GPS signal; automatic compensation for clock drift; the compensation value calculation formula is: compensation milliseconds = (local time - last GPS time) × drift coefficient; the drift coefficient is taken as the measured value of 0.8.
[0144] Dynamic adjustment mechanism for instruction status codes: Establish a monthly failure probability calibration model; the model input parameters include the average ambient humidity and material viscosity change for the month; the output is the code threshold offset; for example, when the humidity increases by 10%, the lower threshold increases by 5%; the upper limit is adjusted to remain unchanged at 100%; the calibration data comes from the production line database; the parameters are automatically updated on the last day of each month; after the update, the old threshold is backed up and archived and marked with a version number.
[0145] Data packet structure optimization scheme: Add metadata area to store processing traces; metadata fields include timestamp synchronization difference (2 bytes), image compression ratio (1 byte), and instruction code decision duration (4 bytes); value field compression algorithm optimization: abnormal position coordinates are stored using relative coordinates; the reference point is the position of the first packet in the batch; store coordinate difference (1 byte offset); batch character images are preprocessed using run-length encoding; compression efficiency improvement parameters are determined through optimization using 10,000 samples; the target compression ratio is set to 50% ± 5%.
[0146] Protocol adaptation layer for instruction format conversion: Supports multiple PLC protocols based on general conversion rules; Protocol type is selected through configuration file; For example, Siemens S7 protocol requires adding 7 bytes of device address before the start character; Mitsubishi MC protocol requires adding check bytes at the end; The adaptation layer calls different conversion templates according to the target device model; Template files are stored in ROM area; Hot updates are supported.
[0147] Error handling and recovery process: When the conversion fails, the exception handling code is triggered; error types include packet verification failure, protocol format mismatch, and network timeout; the error handling strategy is as follows: first attempt protocol downgrade conversion (such as TCP to UDP); if the downgrade fails, the instruction is saved to the local cache; retry when the system is idle; the retry interval is exponentially backed up from 200 milliseconds to 1.6 seconds; at the same time, the alarm light is triggered in a three-flash mode; the operation panel displays the error code ERR_PC_7.
[0148] Command tracing and auditing: All sent commands are recorded in binary logs; the logs include the original data packets, converted commands, sending time, and device response status; log files are archived by shift; compressed and backed up off-site; the auditing tool supports command playback; playback accuracy can be located to the millisecond level; the audit trigger condition is quality incident tracing or random sampling; playback verification content includes data packet integrity, protocol compliance, and execution timeliness.
[0149] Environmental adaptability design: In areas with strong electromagnetic interference (greater than 10V / m), the command redundancy transmission mode is enabled; each command is sent twice consecutively; the receiver automatically filters duplicate commands; in high-temperature environments (>50℃), the Ethernet rate is reduced to 10Mbps; temperature compensation delay is added (1 microsecond delay is added for each℃); humidity compensation weights the data packet verification algorithm; the weighting coefficient is the humidity percentage value / 100.
[0150] All calculations involved in the embodiments are dimensionless numerical calculations, and the preset parameters and thresholds in the calculations are set by those skilled in the art according to the actual situation.
[0151] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, in the form of a computer program product.
[0152] Those skilled in the art will recognize that the modules and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and inventive constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0153] In addition, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module.
[0154] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.
[0155] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0156] In conclusion, the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. 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 early warning of abnormal sealing of strip packaging based on OCR traceability, characterized in that, Includes the following steps: S1. Simultaneously acquire images of the sealing area and OCR area of the strip packaging bag; S2. Determine whether the sealing status meets the preset sealing form standard based on the image of the sealing area. If it does not meet the standard, extract the coordinates of the abnormal position. S3. Based on the physical size parameters of the strip packaging bag, convert the coordinates of the abnormal location into mapped coordinates in the OCR area coordinate system; S4. Locate the target region corresponding to the mapped coordinates in the OCR region image, and recognize the batch-encoded character image within the target region, including: A rectangular recognition frame is defined based on the mapped coordinates, and the length and width of the rectangular recognition frame match the physical dimensions of the laser-coded characters on the surface of the strip packaging bag; Dynamic local binarization is performed on the image area covered by the rectangular recognition box to eliminate grayscale distortion caused by aluminum foil reflection; Extract the set of connected components from the binarized image and filter out interference regions that do not meet the aspect ratio threshold of the batch-encoded character image; Project the connected component set along the character arrangement direction to segment it and output the separated batch-encoded character images; S5. Based on the successfully identified batch code character images, aggregate the residual distribution data of the sealing areas of all strip-shaped packaging bags within the current production period corresponding to the batch code character images, and generate a spatial coordinate density distribution map, including: Extract the pixel coordinates of the residue edge contour from the image of the sealed area of the strip packaging bag associated with the batch code character image; Convert the pixel coordinates of the residue edge contour to physical coordinates with the bottom left corner of the packaging bag as the origin; Accumulate the physical coordinates of the residues in all strip packaging bags corresponding to the same batch of coded character images within a preset time window; The density value per unit area in a two-dimensional plane is calculated based on the accumulated physical coordinates of the residue, forming a spatial coordinate density distribution map; S6. When the density value of the spatial coordinate density distribution map continuously increases for three consecutive production units within the preset coordinate range, calculate the predicted sealing failure probability value for the corresponding batch, including: Obtain the spatial coordinate density distribution map of three consecutive production units within a preset coordinate interval; Calculate the average density value of the spatial coordinate density distribution map for each production unit and generate a density value sequence; Verify whether the density value sequence satisfies the monotonically increasing condition; When the monotonically increasing condition is met, retrieve the number of sealing failure records corresponding to the same density growth pattern in the historical batch database. The predicted probability of sealing failure is calculated based on the ratio of the number of times the sealing failure records are retrieved to the total number of historical batches. S7. Bind the abnormal location coordinates, the successfully identified batch code character image, and the predicted value of the seal failure probability to generate a graded early warning instruction.
2. The method for early warning of abnormal sealing of strip packaging based on OCR traceability according to claim 1, characterized in that, Simultaneously acquire images of the sealed area and OCR area of the strip packaging bag, including: Control the industrial camera to capture images of strip-shaped packaging bags passing through a fixed shooting station while the conveyor belt speed is constant; Adjust the illumination angle of the ring light source to eliminate the interference of aluminum foil reflection in the sealing area on image clarity; Obtain the sealed area image and the OCR area image separately, ensuring that the sealed area image and the OCR area image have the same timestamp and spatial location label.
3. The method for early warning of abnormal sealing of strip packaging based on OCR traceability according to claim 2, characterized in that, Based on the image of the sealed area, determine whether the sealing status meets the preset sealing form standard. If it does not meet the standard, extract the coordinates of the abnormal location, including: The continuity of the heat seal line in the sealed area image is checked to determine whether there is a break or a false seal. When there is a break or a false seal, analyze whether the texture and ripple direction of the sealing edge conforms to the preset angle range. When the direction of the texture ripples does not conform to the preset angle range, verify the grayscale consistency of the sealed area under non-uniform lighting compensation conditions. When grayscale consistency verification fails, locate the coordinates of the abnormal position and convert them to physical coordinates with the lower left corner of the packaging bag as the origin.
4. The method for early warning of abnormal sealing of strip packaging based on OCR traceability according to claim 3, characterized in that, Based on the physical dimensions of the strip packaging bag, the coordinates of the abnormal location are converted into mapped coordinates in the OCR area coordinate system, including: Obtain the physical length and physical width values of the strip packaging bag in the length direction and width direction; A two-dimensional coordinate system for the surface of the packaging bag is established based on the physical length and physical width values; Read the coordinate components of the abnormal location coordinates in the two-dimensional coordinate system; Based on the fixed position offset of the OCR area on the surface of the packaging bag, calculate the mapped coordinate components of the abnormal position coordinates in the OCR area coordinate system. Combine the mapped coordinate components to generate mapped coordinates.
5. The method for early warning of abnormal sealing of strip packaging based on OCR traceability according to claim 4, characterized in that, The two-dimensional coordinate system on the surface of the packaging bag has the lower left corner as the origin, the length direction as the X-axis, and the width direction as the Y-axis.
6. The method for early warning of abnormal sealing of strip packaging based on OCR traceability according to claim 4, characterized in that, The abnormal location coordinates, successfully identified batch code character images, and predicted seal failure probability values are linked to generate tiered early warning instructions, including: Synchronize the coordinates of the abnormal locations with the timestamps of the successfully identified batch of encoded character images; Match a predefined threshold range of instruction status codes based on the predicted value of seal failure probability; Generate data packets and convert them into a hierarchical early warning instruction format that can be parsed by the production line control system.
7. The method for early warning of abnormal sealing of strip packaging based on OCR traceability according to claim 6, characterized in that, The data packet contains timestamp data of the abnormal location coordinates, timestamp data of the successfully recognized batch-encoded character images, and instruction status codes.
Citation Information
Patent Citations
Method and device for detecting false sealing of food package
CN118392884A
Packaging box finished product detection method and system based on image positioning and packaging machine
CN118464930A