OCR traceability-based strip-type package sealing abnormity early warning method
By synchronously capturing seal and OCR area images on strip packaging bags and utilizing physical coordinate system conversion technology to achieve real-time association between seal anomalies and batch information, the real-time association problem between seal quality data and product traceability information is solved, thereby improving the speed of quality risk management and the closed-loop application capability of production data.
Patent Information
- Application Number
- CN202511163623.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-20
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2045-08-20
AI Technical Summary
In the existing technology, sealing quality data and product traceability information cannot be automatically associated in real time, resulting in the inability to synchronously associate key traceability information such as batches and production line workstations when sealing anomalies occur. This leads to delayed isolation and disposal of problem batches of products, increases the probability of quality risk spread, hinders the closed-loop application of production data, and restricts the improvement of quality control efficiency.
By synchronously collecting the sealing area image and OCR area image of the strip packaging bag, the abnormal position is determined based on the sealing area image, and the physical coordinate system conversion mechanism is used to map the abnormal position to the OCR area. The batch code character image is identified and a spatial coordinate density distribution map is generated. The predicted value of the sealing failure probability is calculated and bound to generate a graded warning instruction.
It realizes the real-time correlation between the abnormal sealing position and batch information, significantly shortens the speed of locating problem batches, reduces the probability of defective products flowing out, provides real-time data support for process optimization, and forms a data-driven closed-loop quality control system.
Smart Images

Figure CN120672749A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of quality monitoring of pharmaceutical and food packaging production lines, and more specifically, to an OCR traceability-based early warning method for strip packaging sealing anomalies. Background Art
[0002] On strip packaging lines in the pharmaceutical and food industries, high-speed composite film packaging of viscous liquid products (such as potent loquat juice) has become a mainstream process. These lines are typically equipped with visual inspection systems to assess the appearance of seals and use laser coding technology to mark product surfaces with traceability codes containing batch and expiration date information to meet production traceability and compliance requirements. Existing technical solutions generally implement seal defect detection and optical character recognition (OCR) as separate processes: the visual system uses image analysis to determine whether the seal area contains anomalies such as cracks, contamination, or an incomplete seal, while the OCR module focuses on decoding the text on the packaging surface. These two types of data are stored in separate databases, creating information silos.
[0003] This separate processing mechanism prevents the automatic, real-time association of sealing quality data with product traceability information. When a sealing anomaly is detected on the production line, the system only outputs the defect type and time of occurrence, but is unable to synchronously associate key traceability information such as the batch and production line station 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 affected products. This lagging and inefficient traceability method, on the one hand, leads to serious delays in the isolation and disposal of problem 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, which restricts 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 strip packaging sealing abnormality early warning method based on OCR traceability to solve the problems raised in the above-mentioned background technology.
[0005] To achieve the above object, the present invention provides the following technical solutions: The strip packaging sealing abnormality warning method based on OCR traceability includes the following steps: S1, synchronously collecting the sealing area image and OCR area image of the strip packaging bag; S2. Determine whether the sealing state meets the preset sealing shape standard based on the sealing area image, and if not, extract the abnormal position coordinates; S3. Convert the abnormal position coordinates into mapping coordinates in the OCR area coordinate system according to the physical size parameters of the strip packaging bag; S4, locating the target area corresponding to the mapping coordinates in the OCR area image, and identifying the batch coded character image in the target area; S5. Based on the successfully recognized batch code character image, aggregate the residue distribution data of the sealing area of all strip packaging bags corresponding to the batch code character image in the current production period to generate a spatial coordinate density distribution map; S6. When the density value of the spatial coordinate density distribution graph in the preset coordinate interval continues to increase for three consecutive production units, calculate the predicted value of the sealing failure probability of the corresponding batch; S7. Bind the abnormal position coordinates, the successfully recognized batch code character image, and the sealing failure probability prediction value to generate a graded warning instruction.
[0006] Furthermore, the sealing area image and the OCR area image of the strip packaging bag are collected simultaneously, including: Control the industrial camera to capture images of strip 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 sealing area image and the OCR area image separately, and ensure that the sealing area image and the OCR area image have the same timestamp and spatial location label.
[0007] Furthermore, based on the sealing area image, it is determined whether the sealing state meets the preset sealing shape standard. If not, the coordinates of the abnormal position are extracted, including: Check whether the continuity of the heat seal line in the sealing area image is complete and whether there is any breakage or virtual sealing; When there is a break or a virtual seal, analyze whether the texture corrugation direction of the sealing edge is within the preset angle range; When the texture ripple direction does not conform to the preset angle range, verify the grayscale consistency of the sealed area under non-uniform lighting compensation conditions; When the grayscale consistency verification fails, locate the coordinates of the abnormal position and convert them into the physical coordinate system coordinates with the lower left corner of the packaging bag as the origin.
[0008] Furthermore, based on the physical size parameters of the strip packaging bag, the coordinates of the abnormal position are converted into mapping coordinates in the OCR area coordinate system, including: Obtain the physical length value of the strip packaging bag in the longitudinal direction and the physical width value in the width direction; Establish a two-dimensional coordinate system on the surface of the packaging bag based on the physical length value and the physical width value; Read the coordinate components of the abnormal position coordinates in the two-dimensional coordinate system; Based on the fixed position offset of the OCR area on the packaging bag surface, the mapping coordinate components of the abnormal position coordinates in the OCR area coordinate system are calculated; The mapped coordinate components are combined to generate the mapped coordinates.
[0009] Furthermore, the two-dimensional coordinate system of the packaging bag surface has the lower left corner as the origin, the length direction as the X axis, and the width direction as the Y axis.
[0010] Furthermore, locating a target area corresponding to the mapping coordinates in the OCR area image and identifying the batch coded character images in the target area includes: A rectangular identification frame is defined based on the mapping coordinates, and the length and width of the rectangular identification frame match the physical dimensions of the laser-coded characters on the surface of the strip packaging bag; Perform dynamic local binarization on the image area covered by the rectangular recognition frame to eliminate the grayscale distortion caused by the reflection of the aluminum foil; Extract the connected domain set from the binarized image and filter out the interference areas that do not meet the aspect ratio threshold of the batch-encoded character image; The connected component set is projected and segmented along the character arrangement direction, and separated batch encoded character images are output.
[0011] Furthermore, based on the successfully recognized batch code character images, the residue distribution data of the sealing areas of all the strip packaging bags corresponding to the batch code character images in the current production period are aggregated to generate a spatial coordinate density distribution map, including: Extracting pixel coordinates of the edge contour of the residue in the sealing area image of the strip packaging bag associated with the batch code character image; Convert the pixel coordinates of the residue edge contour into the physical coordinate system coordinates with the lower left corner of the packaging bag as the origin; Accumulate the physical coordinates of the residues of all strip packaging bags corresponding to the coded character images of the same batch 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 residues to form a spatial coordinate density distribution map.
[0012] Furthermore, when the density value of the spatial coordinate density distribution graph in the preset coordinate interval continues to increase for three consecutive production units, the predicted value of the sealing failure probability of the corresponding batch is calculated, including: Obtain the spatial coordinate density distribution diagram of three consecutive production units within a preset coordinate interval; Calculate the average density value of the spatial coordinate density distribution map of each production unit and generate a density value sequence; Verify whether the density value sequence meets the monotonically increasing condition; When the monotonically increasing condition is met, the number of sealing failure records corresponding to the same density growth pattern in the historical batch database is retrieved; The predicted value of the sealing failure probability is calculated based on the ratio of the number of retrieved sealing failure records to the total number of historical batches.
[0013] Furthermore, the abnormal position coordinates, the successfully recognized batch code character images and the predicted value of the sealing failure probability are bound to generate a graded warning instruction, including: The abnormal position coordinates and the successfully recognized batch coded character images are time stamped and synchronized; Matching a predefined instruction status code threshold interval according to the sealing failure probability prediction value; Generate data packets and convert them into hierarchical warning instruction formats that can be parsed by the production line control system.
[0014] Furthermore, the data packet includes timestamp data of the abnormal position coordinates, timestamp data of the successfully recognized batch coded character images, and an instruction status code.
[0015] Compared with the prior art, the present invention has the following beneficial effects: 1. Through the physical coordinate system conversion mechanism, the sealing anomaly position is directly spatially mapped to the OCR area, solving the technical problem of real-time association between sealing quality data and product batch information. This method uses the actual size parameters of the packaging bag to establish a mathematical conversion relationship between the anomaly coordinates and the OCR area, achieving accurate traceability from physical defects to batch information. When a sealing anomaly is detected, the system synchronously outputs the batch code character image corresponding to the anomaly point, eliminating the manual matching of timestamps, and speeding up the location of the problem batch to milliseconds, significantly shortening the quality risk handling window and reducing the probability of defective products flowing out. At the same time, based on the density trend analysis of the residue distribution in the same batch, a breakthrough is achieved in predicting batch risks from single-point anomalies, providing real-time data support for process optimization.
[0016] 2. Accurately predict batch-level sealing failure risks by analyzing spatial coordinate density trends across three consecutive production units. This method effectively utilizes the unique residue distribution characteristics of viscous liquid packaging to convert data that is traditionally considered an interference signal into a predictive factor. A probability calculation module is automatically triggered when the density value continues to increase, generating a quantitative risk value based on historical failure records, thus achieving a transition from passive detection to active early warning. Combined with a hierarchical mechanism for instruction status codes, the production line can implement differentiated control strategies based on different risk levels, maximizing production efficiency while ensuring quality and safety, thus forming a data-driven closed-loop quality control system. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 The figure is a flow chart of the strip packaging sealing abnormality early warning method based on OCR traceability of the present invention. DETAILED DESCRIPTION
[0018] The following will provide a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0019] Example: Figure 1 The present invention provides a strip packaging sealing abnormality early warning method based on OCR traceability, which includes the following steps: S1, synchronously collecting the sealing area image and OCR area image of the strip packaging bag; S2. Determine whether the sealing state meets the preset sealing shape standard based on the sealing area image, and if not, extract the abnormal position coordinates; S3. Convert the abnormal position coordinates into mapping coordinates in the OCR area coordinate system according to the physical size parameters of the strip packaging bag; S4, locating the target area corresponding to the mapping coordinates in the OCR area image, and identifying the batch coded character image in the target area; S5. Based on the successfully recognized batch code character image, aggregate the residue distribution data of the sealing area of all strip packaging bags corresponding to the batch code character image in the current production period to generate a spatial coordinate density distribution map; S6. When the density value of the spatial coordinate density distribution graph in the preset coordinate interval continues to increase for three consecutive production units, calculate the predicted value of the sealing failure probability of the corresponding batch; S7. Bind the abnormal position coordinates, the successfully recognized batch code character image, and the sealing failure probability prediction value to generate a graded warning instruction.
[0020] S1. Synchronously capture the sealing area image and OCR area image of the strip packaging bag, specifically implemented as follows: The industrial camera performs image capture operations while the conveyor belt runs at a constant speed; the 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 station; the industrial camera receives the pulse signal sent by the photoelectric sensor at a trigger position 3.0 meters away from the starting end of the conveyor belt; the industrial camera uses a global shutter model; data is transmitted via the Gigabit Ethernet protocol; image frames are acquired at an acquisition frequency with a single packaging bag as the trigger unit; ensure that the movement displacement of the packaging bag does not exceed 0.5 mm during image acquisition; the trigger position positioning error is controlled within the range of ±5 mm; the displacement is measured in real time by an incremental rotary encoder; the encoder generates 10 pulse signals for every millimeter of displacement.
[0021] The ring light source adjusts its illumination angle through a mechanical bracket to eliminate the interference of aluminum foil reflections 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 light source power output value is dynamically adjusted by a digital controller based on the image analysis results. The adjustment mechanism is to calculate the grayscale standard deviation of the aluminum foil area after collecting the image. 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 the 650-nanometer red light band. The diffuse reflectance of this band on the surface of the aluminum foil material is 8 percentage points higher than the mirror reflectance as measured by a spectrophotometer.
[0022] The sealing area image and the OCR area image are synchronously acquired through a beam splitter system; the beam splitter input port receives imaging light from the industrial camera lens; the first output port is connected to a 700-nanometer long-wave pass filter to acquire the sealing area image; the filter blocks visible light with a wavelength less than 700 nanometers and transmits light in the near-infrared spectrum band; it is used to penetrate drug residues and capture the sealing texture; the second output port is connected to a visible light sensor to acquire the OCR area image; the sensor spectral response range covers wavelengths from 400 to 650 nanometers; the contrast of the character area is enhanced through a hardware gain circuit; the gain value is automatically compensated according to the median grayscale value of the background.
[0023] The timestamps of the sealing area image and the OCR area image are generated synchronously through the GPS timing module; the time synchronization accuracy reaches ±0.5 milliseconds; the timestamp data is written into 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 spatial coordinate origin is set to the mechanical zero point of the conveyor belt; the position tag data packet contains the X-axis coordinate value, Y-axis coordinate value and rotation angle value of the vertex of the lower left corner of the packaging bag in the conveyor belt coordinate system; the sealing area image and OCR area image corresponding to each packaging bag share a unique identification number; the number consists of hexadecimal characters; it is generated by splicing the three parts in sequence: machine serial number, date and time stamp, and serial number; the identification number is also written into the operation log database of the production line control system and the image file header.
[0024] The specific formula for adjusting the power of the ring light source is: ; in, Indicates the adjusted light source power output value in watts (W); Indicates the original power output value of the light source before adjustment, in watts (W); Represents the power response adjustment coefficient, a unitless proportional constant; Indicates the actual grayscale standard deviation measurement value of the aluminum foil area in the current image, in grayscale units; It represents the ideal target value of the grayscale standard deviation of the aluminum foil area, in grayscale level.
[0025] 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 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 the power within the standard deviation regression threshold in a 10% gradient. The industrial camera trigger position deviation compensation mechanism calculates the compensation delay based on the encoder's real-time displacement data. The delay compensation value is calculated as the measured position deviation divided by the conveyor speed. This value is written to the motion compensation register of the PLC controller, and the register address is mapped to the camera trigger timing controller.
[0026] The optical path calibration process for the beam splitter prism system includes: using a standard checkerboard calibration plate; capturing an image at a distance of 50 cm from the calibration plate; calculating the optical distortion rate in the X / Y axis direction; when the distortion rate is greater than 1%, rotating the prism bracket fine-tuning screw to compensate for the optical axis; each adjustment angle is 0.5 degrees. The visible light sensor gain compensation formula is: ; in, Indicates the gain compensation multiple that the sensor needs to set, a unitless proportional value; Indicates the sensitivity coefficient of gain adjustment, the unit is per gray level; Indicates the preset ideal background grayscale reference value, the unit is grayscale; Indicates the average background grayscale value actually measured by the sensor, in grayscale level.
[0027] The ideal background grayscale value is set to 160 grayscale levels; the gain adjustment step is 0.1. The absolute encoder spatial coordinate conversion method: Establish a rectangular coordinate system with the conveyor belt starting point as the origin. The positive X-axis is the conveyor direction; the Y-axis is perpendicular to the conveyor plane. The coordinates of the lower left corner of the bag are calculated using the fixed offset of the mechanical fixture's positioning pin. The X-axis offset is 2 mm; the Y-axis offset is 3 mm. Coordinate values are rounded to two decimal places.
[0028] S2. Determine whether the sealing state meets the preset sealing shape standard based on the sealing area image. If not, extract the abnormal position coordinates. The specific implementation is as follows: The continuity of the heat seal line is detected in the sealed area image. The detection method is to apply the Sobel operator for edge extraction. The operator uses a 3×3 pixel convolution kernel. The gradient amplitude is calculated in the horizontal and vertical directions respectively. When a fracture area with a length exceeding 0.5 mm is detected, or there is a virtual seal area with a local gradient amplitude less than 50 grayscale units, it is determined that there is a fracture or virtual seal. The judgment threshold is set based on: through the analysis of the test data of the sealing strength of 100 qualified samples; qualified samples are defined as packaging bags with a sealing strength of more than 20 Newtons / 15 mm after airtightness testing; the 0.5 mm fracture length threshold is determined by measuring the seal failure samples under a microscope.
[0029] When a break or a false seal is detected, the direction of the seal edge texture ripple is analyzed. The specific method is as follows: an image area with a width of 1 mm on both sides of the center line of the heat seal line is intercepted; the area is processed with a Gabor filter group; the parameter configuration of the filter group includes: the direction angle range covers 0 degrees to 180 degrees; the interval angle is 15 degrees; the spatial wavelength is set to twice the value of the standard heat seal texture spacing; for example, when the standard spacing is 0.4 mm, the wavelength is 0.8 mm; the peak value of the filter response in each direction is recorded during the analysis process; when the directional angle deviation corresponding to the maximum response value exceeds ±5 degrees from the standard heat seal direction, it is determined that the texture ripple direction does not conform to the preset angle range; the tolerance threshold of ±5 degrees is set based on: counting 50 sealing failure samples; when the angle deviation is greater than 5 degrees, the probability of sealing failure is more than 85%.
[0030] Non-uniform illumination compensation is performed on the sealing area with abnormal texture; the compensation process is implemented according to grid partitioning: the area to be processed is divided into 10×10 unit grids; the size of each grid is 1 square millimeter; the median of the grayscale value of each grid area is calculated; the first grid in the upper left corner is used as the reference point; the 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 grayscale value × (1-0.01×distance in millimeters); the grayscale consistency of the compensated image is verified: the grayscale standard deviation of the entire sealing area is calculated; when the standard deviation value is greater than 25 grayscale levels, the verification is judged to have failed; the threshold of 25 grayscale levels is determined by material reflectivity test: qualified sealing areas under 10 different lighting conditions are selected; the upper limit of the measured standard deviation is 25 grayscale levels.
[0031] After grayscale verification fails, coordinate location and conversion of the abnormal position are performed. The location method is to extract the minimum bounding rectangle of the abnormal outline, calculate the intersection of the rectangle's diagonals as the coordinate center point, and record the pixel coordinates of this point with the upper left corner of the image as the origin. The pixel coordinates are converted to physical coordinate system coordinates 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 using a standard calibration plate. The lower left corner offset is fixed at 3.0 mm. This offset is measured using a laser positioning system: a reference point is set on the conveyor belt fixture, and the average distance from the reference point to the actual lower left corner of the packaging bag is measured to be 3.0 mm.
[0032] The sub-pixel precision positioning method for heat seal line break detection involves: building on pixel-level detection, defining a 1mm diameter circular search area centered on the initial coordinates; calculating the gradient change rate at each point within the area; and locating the gradient peak using quadratic surface fitting. The coordinate accuracy of this point is 0.01mm. The iteration termination criteria are when the coordinate offset is less than 0.005mm for three consecutive iterations or when a maximum of 50 iterations is reached. The texture analysis direction angle calibration process involves: with the packaging machine stopped, attaching a high-precision angle gauge to the heat seal roller; capturing a reference image and calculating the reference angle value; and writing this value into the system parameter configuration file, marking the calibration date.
[0033] Pixel physical size calibration procedures: Use a NIST-certified standard ceramic calibration plate; etch the plate surface with 0.1mm grid lines. After image acquisition, calculate the average number of pixels between 10 adjacent grid lines. For example, 10 grid lines with an actual distance of 1.0mm correspond to 200 pixels; the single pixel size = 1.0 / 200 = 0.005mm. The measured value of this system is stable at 0.05mm / pixel; this difference is corrected by adjusting the lens magnification. Optimization of the illumination compensation distance attenuation coefficient: Under controlled variable conditions, adjust the attenuation rate from 0.005 to 0.02. At 0.01, the standard deviation after compensation is reduced to a minimum of 18 grayscale levels, which is below the acceptable limit of 25 grayscale levels. Therefore, an attenuation rate of 0.01 was ultimately selected.
[0034] The physical coordinate system's origin remains consistent throughout subsequent steps: the positive X-axis runs parallel to the bag's length from left to right; the Y-axis runs along the bag's width from bottom to top; and the Z-axis is perpendicular to the bag's surface. The origin is defined at the bag's lower left corner, coinciding with the center of the conveyor belt's positioning fixture's contact surface. The threshold automatically updates after every 500 bags inspected. The system automatically retrieves the test data for the most recent 50 qualified samples and recalculates the grayscale consistency standard deviation threshold as the new baseline value. For example, the new threshold range is updated to 20-28 grayscale levels. This dynamic adjustment adapts to gradual changes in ambient light.
[0035] S3. Convert the abnormal position coordinates into mapping coordinates in the OCR area coordinate system according to the physical size parameters of the strip packaging bag. The specific implementation is as follows: Obtain the actual physical length value of the strip packaging bag in the length direction and the actual physical width value in the width direction; the physical length value is obtained by reading the production line packaging specification parameter file; the file is stored in the industrial computer memory address range 0x5000-0x50FF; the parameter records the length design value in millimeters; for example, the physical length value corresponding to material batch number X190901 is 142.0 mm; the physical width value is obtained by measuring the spacing between the conveyor belt positioning fixtures; use a digital caliper to continuously measure the average value of 10 packaging bags; for example, the measured average value is 24.3 mm; the measured value is rounded to one decimal place.
[0036] A two-dimensional coordinate system for the packaging bag surface is established based on the physical length value and the physical width value; the coordinate system definition rule is: the vertex of the lower left corner of the packaging bag is the origin coordinate zero point; the point is fixed in position by a mechanical positioning pin; the length direction is the positive direction of the X-axis; the width direction is the positive direction of the Y-axis; the coordinate system scale is set in units of millimeters; the coordinate range is 0 to 142.0 mm on the X-axis; 0 to 24.3 mm on the Y-axis; the coordinate system data is stored in a two-dimensional array data structure; the array row index corresponds to the integer digit of millimeters on the X-axis; the column index corresponds to the integer digit of millimeters on the Y-axis; the coordinate values accurate to one decimal place are stored using floating-point registers.
[0037] Read the coordinate components of the abnormal position coordinates in the two-dimensional coordinate system; the abnormal position coordinates come from the physical coordinate system coordinates output by 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 expressed as: 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 place of the coordinate; 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.
[0038] The mapping coordinate components are calculated based on the fixed position offset of the OCR area on the packaging bag surface. The offset is divided into X-axis offset and Y-axis offset. The offset data comes from the laser marking machine position parameter table, which is stored in the programmable memory sector 0x2100. 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 mapping coordinate component calculation formula is: Mapping coordinate X component = Abnormal position coordinate X component - X-axis offset; Mapping coordinate Y component = Abnormal position coordinate Y component - Y-axis offset. The calculation process retains three decimal places of precision.
[0039] Combine the mapping coordinate components to generate the final mapping coordinates. 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 the Y component bytes are combined into a continuous four-byte data stream, with the low-order byte first and the high-order byte last; for example, X = 25.30 mm (0x41CA0000) and Y = 8.20 mm (0x41033333) are packaged into the byte stream [00 00 CA 41 33 33 03 41].
[0040] The method for verifying the accuracy of coordinate transformation is as follows: select the test point position; mark the measured point position on the surface of the packaging bag respectively; use a three-coordinate measuring machine to measure the absolute coordinates; and input the system to calculate the mapping coordinates at the same time; 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 started; the calibration method is to adjust the offset compensation coefficient; the compensation value calculation formula is: new offset = original offset + (measured 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 times.
[0041] The dynamic offset compensation mechanism is achieved through the linkage of temperature sensors. A PT100 temperature sensor is integrated into the laser marking head. The offset is automatically adjusted by 0.001 mm / °C for every degree Celsius temperature change. The temperature compensation coefficient is determined based on the thermal expansion coefficient of the material. The linear expansion coefficient of the composite film material of the packaging bag 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 35mm offset compensation value = 5×0.000085×35=0.014875mm.
[0042] Key parameters for coordinate system conversion are stored in non-volatile FRAM memory. 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 and write instructions use the SPI protocol; the clock frequency is 10 MHz; data verification uses the CRC-8 algorithm; the polynomial coefficient is 0x07. Parameters are automatically loaded at each system startup; a mandatory refresh and verification is performed every 24 hours.
[0043] The optimized process of the interpolation calculation method for coordinate components is as follows: establish a sub-pixel coordinate graduation table; insert 20 subdivision scales between the millimeter integer scales; each subdivision scale represents 0.05 mm; the coordinate values of the subdivision scales are generated by bilinear interpolation; for example, a subdivision point is established between the main scales 35 mm and 36 mm: point number 1 corresponds to 35.05 mm; the value = (index 35 value × 0.95) + (index 36 value × 0.05); and so on to point number 20.
[0044] Boundary protection strategy for mapped coordinate components: When the calculated X component is larger than the actual length of the OCR area, it is forcibly corrected to the area's maximum boundary value. The same applies to the Y component. For example, if the OCR area size is 15 mm x 10 mm and the calculated X = 16.2 mm, it is corrected to 15.0 mm. This correction triggers alarm event EVT_015 and is recorded in the system log. Mapped coordinates are smoothed and filtered before output, using a three-point moving average method. The formula is: Final coordinate = (Current value × 0.5 + Previous value × 0.3 + Previous previous value × 0.2). This reduces coordinate jitter caused by mechanical vibration.
[0045] S4, locating the target area corresponding to the mapping coordinates in the OCR area image, and identifying the batch coded character image in the target area, which is specifically implemented as follows: During the mapping coordinate application phase, a rectangular identification frame is delineated with the coordinate value as the center point. The long side of the rectangular identification frame is set to 1.5 times the standard height of the laser-coded characters. For example, when the standard character height is 2 mm, the rectangular frame height is 3.0 mm. The width is determined by the total width of the characters. The width is based on the number and spacing specifications of the laser-coded characters on the surface of the strip packaging bag. For example, the total physical width of a 9-bit character code is 18.0 mm, so the rectangular frame width is 22.0 mm. The magnification ratio is verified and determined by 200 sets of test samples to ensure complete coverage of possible character position offsets. A minimum safety distance of 0.5 mm is maintained between the rectangular frame boundary and the edge of the packaging bag.
[0046] The implementation process of dynamic local binarization processing is as follows: the image within the rectangular recognition frame is divided into 4×4 sub-grids; the grayscale histogram of each sub-grid area is calculated; the bottom value of the histogram is taken as the binarization threshold of the grid; when the difference between the thresholds of adjacent grids exceeds 40 gray levels, interpolation smoothing is started; 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, an overlapping area with a width of 0.5 mm is retained for feathering transition; after binarization processing, the proportion of aluminum foil reflection pixels in the background area of the image is reduced to less than 5%.
[0047] Extract connected domain sets from binary images: Apply the eight-neighborhood connected labeling algorithm to scan the entire image; mark continuous regions with the same pixel values; limit the minimum connected domain area to 50 square pixels, corresponding to a physical size of 0.125 square millimeters; filter out noise points with too small an area; store the connected domain set in a linked list data structure; each node contains the coordinates of the region's circumscribed rectangle, area value, and center point location information.
[0048] Interference area filtering is performed based on the connected domain set: the aspect ratio of the circumscribed rectangle of each connected domain is calculated; the aspect ratio threshold range is set to 0.2 to 5.0; this range covers the printing specifications of batch coded characters; for example, the aspect ratio of the number "1" is 0.3; the aspect ratio of the letter "W" is 1.2; when a connected domain with an aspect ratio of 0.1 or 6.0 is detected, it is directly eliminated; in addition, shape fitting verification is performed: the minimum enclosing rectangle of the standard character template is used as a reference; the intersection and union ratio of the connected domain rectangle and the reference rectangle is calculated; the intersection and union ratio threshold is set to 0.65; areas below this value are considered invalid.
[0049] Perform projection segmentation along the character arrangement direction: the projection direction is determined by the installation parameters of the laser coding equipment; for example, the default setting is horizontal rightward; this direction is parallel to the length direction of the packaging bag; the projection method is to perform vertical pixel density integration within the rectangular recognition frame; the specific formula is expressed as: projection value X = the number of binary pixels accumulated in the Xth column along the Y direction; identify the valley point position of the projection curve; the valley point is defined as three consecutive columns with projection values 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 a safety margin of at least 0.1 mm; after segmentation, several batches of coded character sub-images are output.
[0050] The optimization process of rectangular recognition frame size setting: establish a size adaptive model; model input parameters include character size tolerance coefficient and packaging bag thermal deformation compensation value; the tolerance coefficient is 1.2-1.8; obtained through linear regression analysis of 100 sets of offset data; thermal deformation compensation is based on the material temperature expansion characteristics: 1 micron size increment is compensated when the temperature rises by 1°C; the guarantee mechanism for rectangular frame positioning accuracy is: a reference point calibration is performed after every 20 recognitions; the calibration method is to identify special positioning mark symbols; when the actual recognition position deviates from the theoretical position by more than 0.05 mm, the coordinate system offset parameters are automatically adjusted.
[0051] Optimization strategy for binary grid partitioning: Use an 8×8 fine grid in areas with strong aluminum foil reflectivity (based on the S1 grayscale distribution map); maintain a 4×4 grid in general areas; pre-write the grid type identifier into the configuration file; refer to the laser marking machine's work log for location; add an illumination compensation factor to the grid threshold calculation method: final threshold = histogram valley value × (1 + illumination intensity coefficient); this coefficient ranges from 0 to 0.15; data is provided in real time by the S1 ambient light sensor; and the maximum time constraint for partition processing is 80 milliseconds.
[0052] The connected domain aspect ratio threshold is set based on the following: Three months of collecting all valid coding images from the packaging production line; statistically analyzing the aspect ratio distribution of 12,350 character samples; determining the aspect ratio range covering 98% of valid characters to be [0.25, 4.5]; conservatively expanding it to [0.2, 5.0] as the execution threshold; updating the standard character template library for intersection-over-union verification monthly; and updating the template by randomly selecting 100 qualified characters from the day to generate a new template. The normalized size of the template image is 50×100 pixels.
[0053] Azimuth tolerance processing for projection segmentation: Create a projection direction group within the range of ±10 degrees from the base orientation; for example, in addition to the default horizontal direction, add two projection paths of 85 degrees and 95 degrees; calculate the peak-to-valley contrast of the projection curve of each path; select the path with the largest contrast as the actual segmentation direction; this mechanism adapts to the angle deviation of the packaging bag on the conveyor belt of ±8 degrees; the sub-pixel positioning of the segmentation boundary uses a Gaussian fitting algorithm: select 7 points near the valley point; fit the extreme points of the parabolic function; the positioning accuracy reaches 0.1 pixel; the corresponding physical size is 0.005 mm.
[0054] The data structure of the output batch-coded character image: each character image is encapsulated as an independent data unit; the unit header information contains the original position coordinates of the character (based on the mapping coordinate system), the character serial number, and the credibility score; the credibility score is calculated by weighting three parts: a 40% binarization consistency weight, a 30% aspect ratio matching weight, and a 30% projection contour clarity weight; the scoring threshold is set to 0.75; character units below this value trigger the re-recognition process; the maximum number of retries is set to 3 times; the time limit is 100 milliseconds.
[0055] Environmental adaptability parameter configuration table: Compensation parameter groups are set in the temperature range of 30-50°C; each group contains 12 parameters, such as the rectangular frame size compensation coefficient and the binarization threshold offset; the parameter group switching condition is that the actual measured value of the infrared temperature sensor crosses the 5°C range; for example, the size compensation coefficient of the 35°C group is 1.02; the threshold offset is +8 gray levels; this configuration is obtained through a constant temperature chamber simulation test; the test temperature gradient is set to 5°C; 500 sets of data are collected at each temperature point.
[0056] All image processing results are error-logged: metadata fields are added to the output data structure to record operation traces; this includes the number of binarization grid changes, the connected domain filtering ratio, and the projection segmentation correction amount. When the recognition success rate is continuously below 95%, the expert review mode is activated; this mode freezes the current parameter configuration; the most recent 100 failure cases are uploaded to the quality analysis system; the freeze state is released after manual intervention. The time constraint for the entire processing chain is 250 milliseconds; the time allocation strategy is 50 milliseconds for rectangle positioning, 70 milliseconds for binarization processing, 60 milliseconds for connected domain 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.
[0057] S5. Based on the successfully recognized batch code character image, aggregate the residue distribution data of the sealing area of all strip packaging bags in the current production period corresponding to the batch code character image to generate a spatial coordinate density distribution map, which is specifically implemented as follows: The pixel coordinates of the edge contours of residues in the seal area image of the strip packaging bag associated with the batch code character image are extracted. The association method is to match data through a shared timestamp; the timestamp accuracy is ±1 millisecond. The Canny edge detection operator is applied in the extraction process. 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 closed contour point set; each point contains the pixel coordinate X and Y values; the contour point set is stored as a dynamic array; the array index sequence 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 small noise is filtered.
[0058] Convert the pixel coordinates of the residue edge outline to physical coordinate system coordinates. The conversion basis 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 of the mechanical positioning system. The conversion calculation uses a floating-point unit and retains three decimal places of precision. The converted physical coordinate system coordinates are written to 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).
[0059] 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 at the end signal; the maximum lag time is set to 5 seconds; the accumulation method is: create a batch-specific memory buffer; the buffer has a capacity of 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 coded character image are indexed through a hash table; the hash key value is the CRC32 checksum of the batch coded string.
[0060] The density value per unit area is calculated based on the cumulative coordinates. The calculation area division rules are as follows: the length direction of the packaging bag is the X-axis; the width direction is the Y-axis; a 1 mm × 1 mm grid coordinate system is established; the density value calculation formula is: 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 result generates a two-dimensional density matrix; the number of matrix rows is equal to the physical length value divided by 1 mm rounded; 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 rounded; for example, a width of 24 mm corresponds to 24 columns.
[0061] The process of generating the spatial coordinate density distribution map is as follows: the density matrix is mapped to a pseudo-color image; density values of 0 to 0.5 dots / square millimeter are mapped to the blue series; 0.5 to 2.0 dots / square millimeter are mapped to the green series; and 2.0 and above are mapped to the red series; color gradation is achieved through a lookup table; the lookup table presets a 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 into the file header.
[0062] Optimized mechanism for residue contour extraction: Double edge detection is used in the reflective area of the aluminum foil (based on the S1 light source adjustment record); a high threshold (200 grayscale levels) is first applied to detect the main contour; a low threshold (80 grayscale levels) is then applied to supplement weak edges; the two results are superimposed and morphological closing is performed to fill in the gaps; the closing kernel size is 3×3 pixels; and the contour area is calculated using Green's formula: ; in, Indicates the calculated area value of the closed contour area, in square millimeters (mm²); Indicates the total number of feature points that constitute the contour boundary; Indicates the index number of the feature point currently being calculated, ranging from 1 to N; Represents the X-axis coordinate value of the i-th feature point in the contour feature point sequence; Indicates the Y-axis coordinate value of the i-th feature point in the contour feature point sequence; Indicates the X-axis coordinate value of the i+1th feature point in the contour feature point sequence; Indicates the Y-axis coordinate value of the i+1th feature point in the contour feature point sequence; when hour, and , to achieve end-to-end closure.
[0063] Dynamic adjustment strategy for the 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 × (reference speed / current speed); the reference speed is 0.5 m / s; the current speed is calculated using the encoder pulse frequency; for example, when the speed rises 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 / reference speed); the upper limit is 20,000 points.
[0064] Boundary processing of density calculation: When the coordinate point is located at the grid boundary, the four-grid weighted allocation method is used. For example, the coordinate point (35.3, 12.7) is allocated to the grids (35, 12), (35, 13), (36, 12), and (36, 13). The weight coefficient is calculated inversely proportional to the distance: the weight of the grid (35, 12) = 1 / (0.3 + 0.3) = 1.67. The rest are deduced by analogy. The total weight is normalized to 1.
[0065] Outlier suppression in distribution map generation: perform a 3×3 median filter 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 judgment criterion is: grid value > 3 times the average value of adjacent grids; outlier grid values are corrected to the neighborhood mean; the maximum correction ratio is limited to 5% of the total number of grids.
[0066] Data storage and transmission protocol: The density matrix is stored as a CSV-formatted text file; each row represents the X-axis density sequence when the Y-axis is fixed; the file naming convention is: batch code_start timestamp.csv; the distribution map image file is transmitted to the server via Gigabit Ethernet; the transmission protocol is TFTP; the port number is 69; the packet size is 512 bytes; and the transmission integrity is verified using MD5 hash value comparison.
[0067] Temperature compensation mechanism: Add material thermal expansion compensation in the coordinate conversion link; compensation amount = temperature change × linear expansion coefficient × original size; the expansion coefficient of the composite film material is 8.5×10 -5 / ℃; the temperature change is obtained in real time through the patch sensor; for example, when the temperature rises by 10℃; the X-direction compensation amount = 10×0.000085×142=0.1207 mm.
[0068] Processing time guarantee plan: 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 plan: 142 thread blocks in the X-axis direction; 24 thread blocks in the Y-axis direction; a single thread block processes a single grid calculation; the time constraint is 500 milliseconds; timeout triggers degradation mode: the grid size is expanded to 2 mm × 2 mm.
[0069] Quality monitoring indicators: The system records key parameters for each batch, including average density, 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, and the storage medium uses a RAID5 disk array. Daily incremental backups are sent to an off-site server.
[0070] S6. When the density value of the spatial coordinate density distribution graph in the preset coordinate interval continues to increase for three consecutive production units, calculate the predicted value of the sealing failure probability of the corresponding batch, which is specifically implemented as follows: Obtain the spatial coordinate density distribution diagram of three consecutive production units within a preset coordinate interval; the method for setting the preset coordinate interval is: divide the high-attention sub-area in the packaging bag sealing area; the basis for determining the area is the historical fault location statistics; for example, select a rectangular area of 80 mm to 90 mm on the X axis and 10 mm to 15 mm on the Y axis; the definition of the production unit comes 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 diagram 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.
[0071] Calculate the average density value of each spatial coordinate density distribution diagram; the calculation method is to obtain the arithmetic average of the density values of all grid cells within the preset coordinate interval; the specific formula is: average density value = total grid density value / 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 rounded to three decimal places; the calculation result forms a density value sequence; the sequence is arranged in the order of production units and stored as a dynamic array.
[0072] 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+1th value; this operation is performed twice in a row (n starts from 1); the verification is terminated when it is found that the n+1th value is 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 judged to be increasing; the sequence [1.200, 1.205, 1.198] is judged to fail; the verification result is stored as a Boolean type flag.
[0073] When the monotonically increasing condition is met; search for the same density growth pattern in the historical batch database; the growth pattern is defined as a combination of two consecutive growth amplitudes; the amplitude calculation formula is: increase 1 = (the second density value - the first density value) / the first density value; increase 2 = (the third density value - the second density value) / the second density value; the increase precision is retained to two decimal places; the growth pattern storage format is "increase 1: increase 2"; for example, "0.02:0.015" means the first increase is 2%; the second increase is 1.5%; the database search uses an exact matching algorithm; the range tolerance is set to ±0.003; the hit result returns the number of sealing failure records.
[0074] Calculate the sealing failure probability prediction value based on the search results; the calculation formula is: probability prediction value = number of sealing failure records / total number of occurrences of the matching pattern; the denominator data comes from the pattern statistics table; this table records the historical number of occurrences of each growth pattern; the calculation result is converted into a percentage; for example, the calculated value of 0.35 is expressed as 35%; the value retains the integer digit; the probability prediction value is stored as 8-bit integer data; and it is written into the warning event data packet.
[0075] Tolerance rule optimization for density growth patterns: When no identical growth pattern is matched, the approximate matching mechanism is activated; the approximate range is set to ±0.005 amplitude difference; the matching priority order is: 1) same increase combination; 2) increase 1 deviation ≤ 0.005 and increase 2 is the same; 3) increase 2 deviation ≤ 0.005 and increase 1 is the same; 4) double increase deviations ≤ 0.005; when multiple patterns are matched, the one with the highest failure probability is selected.
[0076] Specifications for building a historical database: The collection cycle is no less than 6 months of production data; the minimum number of occurrences of the storage density growth pattern 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 established 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; and data statistical analysis tasks are performed at 1:00 a.m. every day.
[0077] Outlier handling mechanism in increase calculation: When a density value is abnormally high (for example, greater than three standard deviations of the mean), the review process is triggered. The review method is to obtain alternative data from three adjacent production units. The replacement rule is to fill in one production unit forward. The review pass rate threshold is set to 85%. If three reviews fail, the sequence calculation is terminated. The error log ERR_DN_6 is recorded.
[0078] Confirmation criteria for seal failure records: any of the following conditions must be met: 1) online airtightness test fails; 2) leakage is detected during sampling and unpacking inspection; 3) customer complaint verification; confirmed failure events are marked with timestamps and fault coordinates; record sheets are audited and cleared quarterly; and the record period is five years.
[0079] Dynamic correction method for probability prediction value: establish a probability confidence assessment model; confidence = min (total number of occurrences of matching pattern, 50) / 50; calculate the final prediction value = original probability value × confidence + reference value × (1-confidence); the reference value is the average failure probability of the month; when the total number of occurrences ≥ 50, the confidence is 100%; for example, the original probability is 60%; the confidence is 80%; the reference value is 10%; then the final probability = 60% × 0.8 + 10% × 0.2 = 50%.
[0080] Fault warning linkage mechanism: When the predicted value exceeds 30%, triple protection is activated: 1) increase the inspection 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 hierarchy; each 10% increase in the predicted value corresponds to a corresponding increase in level; the highest level 5 triggers equipment shutdown inspection.
[0081] Closed-loop quality control: Generate prediction accuracy reports monthly; statistical models include true positive rate and false positive rate; when the false positive rate exceeds 15% for three consecutive months, initiate retraining of the growth pattern library; the retraining method is to add new fault feature dimensions; add a new "density spatial distribution morphology" classification indicator; and reclassify growth pattern categories.
[0082] S7. Bind the abnormal position coordinates, the successfully recognized batch code character image, and the predicted value of the sealing failure probability to generate a graded warning instruction, which is specifically implemented as follows: The coordinates of the abnormal position and the batch coded character images that have been successfully identified are time-stamped and synchronized. The time-stamping benchmark uses the 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 the two data types. The identifier format is a 64-bit integer timestamp. The content is the number of milliseconds since 00:00 on January 1, 1970, Coordinated Universal Time. The marking operation is completed within 2 milliseconds after the data is acquired. After the marking is completed, the absolute value of the time difference is verified. When the difference exceeds 1 millisecond, the group of data is discarded and the re-collection process is triggered. The upper limit of the number of re-collections is set to 3 times. The time verification mechanism is implemented using a hardware timer. The timer clock frequency is 100MHz.
[0083] The predefined instruction status code threshold interval is matched according to the predicted value of the sealing failure probability; the probability prediction value input range is 0 to 100%; the threshold interval division rules are as follows: 0% to 20% corresponds to code 100 (no warning); 21% to 40% corresponds to code 200 (observation level); 41% to 60% corresponds to code 300 (warning level); 61% to 80% corresponds to code 400 (emergency level); 81% to 100% corresponds to code 500 (shutdown level); the interval boundary includes the lower limit but excludes the upper limit; the matching process is to sequentially compare whether the probability value falls into each interval range; after a hit, the corresponding instruction status code integer value is output; the code is stored as an 8-bit unsigned integer.
[0084] Generates a data packet containing the timestamp data of the abnormal position coordinates, the timestamp data of the successfully recognized batch coded character images, and the instruction status code; the data packet structure adopts the TLV (type-length-value) format; the type field is defined as follows: 0xA1 identifies the abnormal position coordinates; 0xB1 identifies the batch character image; 0xC1 identifies the instruction code; the length field records the number of bytes occupied by the subsequent value; the value field stores the specific data content; the value field of the abnormal position coordinates is stored as two floating-point numbers (4 bytes for the X coordinate and 4 bytes for the Y coordinate); the value field of the batch character image 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 packet header; and a 2-byte cyclic redundancy check code is appended to the tail.
[0085] The data packet is converted into a hierarchical warning instruction format that can be parsed by the production line control system; the conversion rules are based on the PLC communication protocol specifications; the target format definition: 2 bytes of start character (0x3A01); 1 byte of function code (0x05 indicates a warning instruction); 2 bytes of data length; the payload area is the original data packet content; the check area is 2 bytes (Modbus-CRC16); the conversion process includes data reorganization and byte order adjustment; the reorganization method is to rearrange the payload of the TLV data packet in field order; the byte order is uniformly converted to big-endian mode; the converted instructions are sent via industrial Ethernet; the target port number is 502; the sending interval is 50 milliseconds; the number of retransmissions is 3.
[0086] Fault-tolerant timestamp synchronization: Automatically switches to a local, highly stable crystal oscillator when the GPS signal is interrupted; crystal oscillator accuracy is 0.5ppm; switching time is less than 100 microseconds; clock source status is recorded in the system log; time base calibration is triggered when the crystal oscillator has been running for more than 72 hours; calibration is performed by comparing the time difference with the most recent valid GPS signal; clock drift is automatically compensated; compensation value calculation formula: compensated milliseconds = (local time - last GPS time) × drift coefficient; the drift coefficient is taken as the measured value of 0.8.
[0087] Dynamic adjustment mechanism for instruction status codes: Establish a monthly failure probability calibration model; model input parameters include the average ambient humidity of the month and the change in material viscosity; the output is the code threshold offset; for example, when the humidity increases by 10%, the lower threshold increases by 5%; the upper limit remains unchanged at 100%; calibration data comes from the production line database; 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 the version number.
[0088] Data packet structure optimization plan: 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; coordinate difference is stored (1 byte offset); batch character images are preprocessed using run-length encoding; compression efficiency improvement parameters are determined through optimization of 10,000 samples; the target compression rate is set to 50%±5%.
[0089] Protocol adaptation layer for instruction format conversion: supports multiple PLC protocols based on general conversion rules; protocol type is selected through configuration files; for example, the Siemens S7 protocol requires a 7-byte device address before the start character; the Mitsubishi MC protocol requires a checksum byte at the end; the adaptation layer calls different conversion templates based on the target device model; template files are stored in the ROM area; hot updates are supported.
[0090] Error handling and recovery process: When 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: first try protocol downgrade conversion (such as TCP to UDP); if downgrade fails, transfer the instructions to the local cache; retry when the system is idle; the retry interval is exponentially backed off from 200 milliseconds to 1.6 seconds; and the alarm light is triggered in a three-flash mode. The operation panel displays error code ERR_PC_7.
[0091] Instruction tracing and auditing: All sent instructions are recorded in binary logs; the logs contain the original data packet, converted instructions, sending time, and device response status; log files are archived by each shift; compressed and backed up off-site; the audit tool supports instruction playback; playback accuracy can be located to the millisecond level; audit trigger conditions are quality accident tracing or random inspections; playback verification content includes data packet integrity, protocol compliance, and execution timeliness.
[0092] Environmental adaptability design: Enable command redundancy in areas of strong electromagnetic interference (greater than 10V / m); send each command twice continuously; the receiver automatically filters duplicate commands; reduce the Ethernet rate to 10Mbps in high-temperature environments (>50°C); add temperature compensation delay (increase the delay by 1 microsecond per °C); and weight the data packet verification algorithm for humidity compensation; the weight coefficient is the humidity percentage / 100.
[0093] The calculations involved in the embodiments are all dimensionless numerical calculations, and the preset parameters and thresholds in the calculations are set by those skilled in the art according to actual conditions.
[0094] The above embodiments may be implemented in whole or in part through software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments may be implemented in whole or in part in the form of a computer program product.
[0095] Those skilled in the art will appreciate that the modules and algorithm steps of each example 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 performed in hardware or software depends on the specific application of the technical solution and the invention constraints. Professional and technical personnel 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.
[0096] In addition, each functional module in each embodiment of the present application may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.
[0097] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. In actual implementation, there may be other division methods, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0098] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
[0099] Finally: 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 in the scope of protection of the present invention.
Claims
1. A strip packaging sealing abnormality warning method based on OCR traceability is characterized by: The steps include: S1, synchronously collecting the sealing area image and OCR area image of the strip packaging bag; S2. Determine whether the sealing state meets the preset sealing shape standard based on the sealing area image, and if not, extract the abnormal position coordinates; S3. Convert the abnormal position coordinates into mapping coordinates in the OCR area coordinate system according to the physical size parameters of the strip packaging bag; S4, locating the target area corresponding to the mapping coordinates in the OCR area image, and identifying the batch coded character image in the target area; S5. Based on the successfully recognized batch code character image, aggregate the residue distribution data of the sealing area of all strip packaging bags corresponding to the batch code character image in the current production period to generate a spatial coordinate density distribution map; S6. When the density value of the spatial coordinate density distribution graph in the preset coordinate interval continues to increase for three consecutive production units, calculate the predicted value of the sealing failure probability of the corresponding batch; S7. Bind the abnormal position coordinates, the successfully recognized batch code character image, and the sealing failure probability prediction value to generate a graded warning instruction.
2. The OCR traceability-based strip packaging sealing abnormality early warning method according to claim 1 is characterized in that: Synchronously capture the sealing area image and OCR area image of the strip packaging bag, including: Control the industrial camera to capture images of strip 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 sealing area image and the OCR area image separately, and ensure that the sealing area image and the OCR area image have the same timestamp and spatial location label.
3. The OCR traceability-based strip packaging sealing abnormality early warning method according to claim 2, characterized in that: Based on the sealing area image, it is determined whether the sealing state meets the preset sealing shape standard. If not, the coordinates of the abnormal position are extracted, including: Check whether the continuity of the heat seal line in the sealing area image is complete and whether there is any breakage or virtual sealing; When there is a break or a virtual seal, analyze whether the texture corrugation direction of the sealing edge is within the preset angle range; When the texture ripple direction does not conform to the preset angle range, verify the grayscale consistency of the sealed area under non-uniform lighting compensation conditions; When the grayscale consistency verification fails, locate the coordinates of the abnormal position and convert them into the physical coordinate system coordinates with the lower left corner of the packaging bag as the origin.
4. The OCR traceability-based strip packaging sealing abnormality early warning method according to claim 3 is characterized in that: According to the physical size parameters of the strip packaging bag, the abnormal position coordinates are converted into mapping coordinates in the OCR area coordinate system, including: Obtain the physical length value of the strip packaging bag in the longitudinal direction and the physical width value in the width direction; Establish a two-dimensional coordinate system on the surface of the packaging bag based on the physical length value and the physical width value; Read the coordinate components of the abnormal position coordinates in the two-dimensional coordinate system; Based on the fixed position offset of the OCR area on the packaging bag surface, the mapping coordinate components of the abnormal position coordinates in the OCR area coordinate system are calculated; The mapped coordinate components are combined to generate the mapped coordinates.
5. The OCR traceability-based strip packaging sealing abnormality early warning method according to claim 4 is characterized in that: The two-dimensional coordinate system of the packaging bag surface takes the lower left corner as the origin, the length direction as the X axis, and the width direction as the Y axis.
6. The OCR traceability-based strip packaging sealing abnormality early warning method according to claim 4, characterized in that: Locating the target area corresponding to the mapping coordinates in the OCR area image and recognizing the batch coded character images in the target area, including: A rectangular identification frame is defined based on the mapping coordinates, and the length and width of the rectangular identification frame match the physical dimensions of the laser-coded characters on the surface of the strip packaging bag; Perform dynamic local binarization on the image area covered by the rectangular recognition frame to eliminate the grayscale distortion caused by the reflection of the aluminum foil; Extract the connected domain set from the binarized image and filter out the interference areas that do not meet the aspect ratio threshold of the batch-encoded character image; The connected component set is projected and segmented along the character arrangement direction, and separated batch encoded character images are output.
7. The OCR traceability-based strip packaging sealing abnormality early warning method according to claim 6, characterized in that: Based on the successfully recognized batch code character image, the residue distribution data of the sealing area of all strip packaging bags in the current production period corresponding to the batch code character image is aggregated to generate a spatial coordinate density distribution map, including: Extracting pixel coordinates of the edge contour of the residue in the sealing area image of the strip packaging bag associated with the batch code character image; Convert the pixel coordinates of the residue edge contour into the physical coordinate system coordinates with the lower left corner of the packaging bag as the origin; Accumulate the physical coordinates of the residues of all strip packaging bags corresponding to the coded character images of the same batch 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 residues to form a spatial coordinate density distribution map.
8. The OCR traceability-based strip packaging sealing abnormality early warning method according to claim 7, characterized in that: When the density value of the spatial coordinate density distribution graph in the preset coordinate interval continues to increase for three consecutive production units, the predicted value of the sealing failure probability of the corresponding batch is calculated, including: Obtain the spatial coordinate density distribution diagram of three consecutive production units within a preset coordinate interval; Calculate the average density value of the spatial coordinate density distribution map of each production unit and generate a density value sequence; Verify whether the density value sequence meets the monotonically increasing condition; When the monotonically increasing condition is met, the number of sealing failure records corresponding to the same density growth pattern in the historical batch database is retrieved; The predicted value of the sealing failure probability is calculated based on the ratio of the number of retrieved sealing failure records to the total number of historical batches.
9. The OCR traceability-based strip packaging sealing abnormality early warning method according to claim 8, characterized in that: Bind the abnormal location coordinates, the successfully recognized batch code character image, and the predicted value of the sealing failure probability to generate a graded warning instruction, including: The abnormal position coordinates and the successfully recognized batch coded character images are time stamped and synchronized; Matching a predefined instruction status code threshold interval according to the sealing failure probability prediction value; Generate data packets and convert them into hierarchical warning instruction formats that can be parsed by the production line control system.
10. The OCR traceability-based strip packaging sealing abnormality early warning method according to claim 9, characterized in that: The data packet includes timestamp data of the abnormal position coordinates, timestamp data of the successfully recognized batch coded character images, and a command status code.
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
Bottled oral liquid quality detection method and system based on image recognition
CN120219291A
Method and system for detecting and analyzing anomalies
US20210182873A1
Method and apparatus for inspecting a label attached to a food pack
US20210406571A1