Inner package section sorting system and method based on OpenCV logic control

Through the OpenCV-based inner package segment sorting system, combined with fuzzy pattern matching and contour analysis algorithms, automated inspection of food production lines and efficient rejection of unqualified products are achieved, solving the problems of insufficient inspection accuracy and high labor costs in existing technologies, and improving inspection efficiency and accuracy.

CN120644388APending Publication Date: 2025-09-16SHANGHAI MCVOLF FOOD CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511038927.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-28
Publication Date
2025-09-16

AI Technical Summary

Technical Problem

The existing food production lines lack detection accuracy, have a high rate of missed detections during manual quality inspections, are difficult to match the pace of modern high-speed production lines, have high labor costs, and are subject to subjective judgment differences.

Method used

The inner package segment sorting system based on OpenCV logic control is adopted, including image acquisition module, screening module, relay control module and pneumatic execution module, combined with fuzzy pattern matching algorithm and contour analysis algorithm to realize automatic detection and rejection of unqualified products.

Benefits of technology

It improves detection accuracy, reduces missed detection rate and false recognition rate, increases production line speed, saves labor costs, reduces quality disputes and customer complaints, and realizes full-process automation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120644388A_ABST
    Figure CN120644388A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of food detection, and provides an inner package section sorting system and method based on OpenCV logic control, and the system comprises an image collection module which is used for collecting a product package image; the screening module comprises a quality screening sub-module and a visual screening sub-module, the quality screening sub-module is used for detecting quality parameters of products, and an OpenCV algorithm unit is arranged in the visual screening sub-module and used for detecting visual parameters of product packages; the relay control module comprises at least two relays which are connected in parallel, are respectively connected with the quality screening sub-module and the visual screening sub-module, and respectively trigger a switch to act according to screening results of the quality screening sub-module and the visual screening sub-module; and the pneumatic execution module comprises a gas injection valve and is driven by a relay to blow the unqualified products away from the conveying line. The packaging omission rate and the date false identification rate are reduced, the original independent relay controls the high-pressure air valve mechanism to achieve millisecond-level response, an existing production line is compatible, and front equipment does not need to be transformed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of food detection technology, and in particular to an inner package segment sorting system and method based on OpenCV logic control. Background Art

[0002] Current food production lines generally use a combination of manual visual inspection and basic mechanical screening, which has the following drawbacks: First, inspection accuracy is insufficient: manual quality inspections have a high rate of missed detection of 20%-30%, and are particularly weak in identifying defects such as minor white spots and blurred production dates. Furthermore, manual inspection speeds are capped at 15-20 pieces per minute, making it difficult to keep up with the pace of modern high-speed production lines. Furthermore, each production line requires three to four dedicated quality inspectors, resulting in high annual labor costs and the risk of quality disputes caused by subjective judgment. Summary of the Invention

[0003] In order to help solve the above technical problems, the present application provides an inner package segment sorting system and method based on OpenCV logic control.

[0004] In the first aspect, the present application provides an inner package segment sorting system based on OpenCV logic control, which adopts the following technical solutions: An inner package segment sorting system based on OpenCV logic control, which includes: Image acquisition module, used to acquire product packaging images; The screening module includes a quality screening submodule and a visual screening submodule. The quality screening submodule is used to detect product quality parameters, including product weight. The visual screening submodule is equipped with an OpenCV algorithm unit to detect visual parameters of product packaging, including the quality of the production date inkjet coding. a relay control module, comprising at least two relays connected in parallel, connected to the quality screening submodule and the visual screening submodule respectively, and triggering a switch action according to the screening results of the quality screening submodule and the visual screening submodule respectively; when a product passes both the quality screening and the visual screening, it is identified as a qualified product; otherwise, it is identified as an unqualified product; The pneumatic execution module includes a gas injection valve, which is driven by a relay to blow the unqualified products away from the conveying line.

[0005] Preferably, a pre-processing module is also included, which includes a metal detection unit and a weighing unit, which are used to detect whether there are metal foreign objects in the product and weigh the product.

[0006] Preferably, the quality parameters include product packaging heat seal strength, product weight, and packaging integrity, and the visual parameters include the presence, accuracy, and clarity of the production date inkjet coding.

[0007] Preferably, an ESP32 chip is provided in the screening module, and the real-time image collected by the image acquisition module is compared with the pre-stored standard packaging template and defect template through the OpenCV algorithm unit based on the fuzzy pattern matching algorithm and the contour analysis algorithm to detect the visual parameters.

[0008] Preferably, the pneumatic execution module further includes an air compressor, which is connected to the relay and the gas injection valve and is used to control the opening and closing of the gas injection valve according to the opening and closing drive of the relay.

[0009] In the second aspect, the present application provides a method for sorting inner package segments based on OpenCV logic control, which adopts the following technical solutions: A method for sorting inner package segments based on OpenCV logic control, wherein, based on any inner package segment sorting system based on OpenCV logic control as described in the first aspect, the method comprises the following steps: Capturing product packaging images through the image acquisition module; The screening module performs a two-stage screening, including: Quality screening, testing product quality parameters, including product weight, Visual screening, using OpenCV algorithms to detect visual parameters of the packaging, including the quality of the production date inkjet coding; The relay control module controls the relay operation. When a product passes both the quality screening and the visual screening, it is determined to be a qualified product and the relay is kept disconnected. When a product fails any of the screenings, it is determined to be an unqualified product and the switching operation of at least two parallel relays is triggered. The pneumatic actuator is driven by the pneumatic actuator unit, and the gas injection valve is turned on through the relay to blow the unqualified products away from the conveyor line.

[0010] Preferably, the method further comprises: performing a preprocessing operation by the preprocessing module: Use the metal detection unit to detect whether there are metal foreign objects in the product; Obtain product weight data through weighing unit.

[0011] Preferably, when a product passes the quality screening, the image of the product packaging is captured by the image acquisition module, and the visual screening is performed by the visual screening submodule.

[0012] In summary, this application uses embedded edge AI technology to achieve simultaneous and accurate detection of packaging defects and production dates of finished food products, reducing the packaging missed detection rate and date error recognition rate. The original independent relay-controlled high-pressure gas valve mechanism achieves millisecond-level response, is compatible with existing production lines, and does not require modification of front-end equipment. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 This is a flow chart of an inner package segment sorting method based on OpenCV logic control in this application; Figure 2 This is a schematic diagram of the workflow of the visual screening submodule of this application; Figure 3 This is a partial code diagram of the algorithm unit of this application. DETAILED DESCRIPTION

[0014] The present invention will be further described below with reference to the accompanying drawings. The structure and principle of the present invention will be very clear to those skilled in the art. It should be understood that the specific embodiments described herein are only intended to explain the present invention and are not intended to limit the present invention.

[0015] Figure 1 This is a flow chart of an inner package segment sorting method based on OpenCV logic control in this application. Figure 2 This is a schematic diagram of the workflow of the visual screening submodule of this application. Figure 3 This is a partial code diagram of the algorithm unit of this application.

[0016] Combine Figure 1 、 Figure 2 and Figure 3 It can be understood that the system of this application includes: Image acquisition module, used to acquire product packaging images; The screening module includes a quality screening submodule and a visual screening submodule. The quality screening submodule is used to detect product quality parameters, including product weight. The visual screening submodule is equipped with an OpenCV algorithm unit to detect visual parameters of product packaging, including the quality of the production date inkjet coding. a relay control module, comprising at least two relays connected in parallel, connected to the quality screening submodule and the visual screening submodule respectively, and triggering a switch action according to the screening results of the quality screening submodule and the visual screening submodule respectively; when a product passes both the quality screening and the visual screening, it is identified as a qualified product; otherwise, it is identified as an unqualified product; The pneumatic execution module includes a gas injection valve, which is driven by a relay to blow the unqualified products away from the conveying line.

[0017] The pre-processing module includes a metal detection unit and a weighing unit, which are used to detect whether there are metal foreign objects in the product and weigh the product.

[0018] It should be noted that quality parameters include product packaging heat seal strength, product weight, and packaging integrity. Visual parameters include the presence, accuracy, and clarity of the production date inkjet coding. The screening module, equipped with an ESP32 chip, uses an OpenCV algorithm based on fuzzy pattern matching and contour analysis to compare real-time images captured by the image acquisition module with pre-stored standard packaging templates and defect templates to detect visual parameters.

[0019] The pneumatic execution module further includes an air compressor, which is connected to the relay and the gas injection valve and is used to control the opening and closing of the gas injection valve according to the opening and closing drive of the relay.

[0020] The present application also provides an inner package segment sorting method based on OpenCV logic control, based on the above-mentioned inner package segment sorting system based on OpenCV logic control, comprising the following steps: Capturing product packaging images through the image acquisition module; The screening module performs two-stage screening, including: quality screening, detecting product quality parameters, such as product weight; visual screening, detecting visual parameters of the packaging using OpenCV algorithms, such as the quality of the production date inkjet coding; The relay control module controls the relay operation. When a product passes both the quality screening and the visual screening, it is determined to be a qualified product and the relay is kept disconnected. When a product fails any of the screenings, it is determined to be an unqualified product and the switching operation of at least two parallel relays is triggered. The pneumatic actuator is driven by the pneumatic actuator unit, and the gas injection valve is turned on through the relay to blow the unqualified products away from the conveyor line.

[0021] The preprocessing module performs the following preprocessing operations: Use the metal detection unit to detect whether there are metal foreign objects in the product; Obtain product weight data through weighing unit.

[0022] When the product passes the quality screening, the image of the product packaging is captured by the image acquisition module, and the visual screening submodule performs visual screening.

[0023] Specifically, this application, based on machine vision and real-time feedback technology, is designed specifically for finished food products. It aims to automatically detect the quality of their outer packaging (e.g., inadequate packaging or damage) and production date information (including its presence, content accuracy, and printing clarity), and achieve efficient screening. The system's core workflow begins with the image acquisition module. After the finished product undergoes metal detection and weighing, a high-speed industrial camera is triggered to capture high-resolution images of key areas on the finished product's surface. The acquired image data is transmitted in real time to the core processor unit (ESP32 chip).

[0024] The intelligent analysis module then processes the data. This module, based on the ESP32 chip as its core hardware platform, has been tested on actual production lines and proven to have sufficient data processing capabilities to analyze images of approximately 2-3 finished products per second. The analysis primarily utilizes a fuzzy pattern matching algorithm combined with a contour analysis algorithm to accurately compare the real-time captured images with a pre-stored database of standard packaging templates (without defects) and typical defect templates (such as those containing white spots on the centerline). The module also identifies and verifies the production date information located on the centerline of the finished product in the image, ensuring its presence, accuracy, and legibility. If the analysis results indicate a packaging defect or production date issue, the system will generate and output an abnormal status signal in real time.

[0025] Ultimately, the control execution module responds and performs the screening action. This module receives abnormality signals from the intelligent analysis module and controls the opening and closing of the high-pressure gas injection valve through an independently configured relay. When receiving an abnormality signal, the relay instantly activates, driving the high-pressure gas valve to open, generating a directional high-speed airflow that precisely blows the corresponding unqualified finished products away from the main conveyor line and into the designated scrap recycling bin. This control execution module uses an independent relay design to ensure that its screening function does not interfere with other quality control modules that may be present on the production line (such as quality identification devices in previous processes). While achieving automated and efficient elimination, it effectively reduces the overall system modification cost.

[0026] This application's intelligent analysis core utilizes enterprise-grade model distillation and embedded deployment technologies to achieve highly robust edge AI in industrial scenarios. The specific process involves training a high-precision neural network model (such as ResNet-34) on the server side. Key discriminative features are extracted using structured model distillation technology to generate a highly streamlined inference engine. This engine, along with preprocessing configuration parameters, is binary-encoded and stored on a TF card, forming an AI task module that can be run offline.

[0027] During deployment, insert the TF card into the ESP32 chip expansion slot, and the system will automatically load the model into the memory. Triple optimization is implemented for edge hardware characteristics: Operator hardware acceleration: Leveraging the ESP32's built-in RISC-V processor to extend the instruction set, the convolutional layer calculation process is restructured, increasing image processing speed by 30%. Dynamic memory allocation: pre-allocates the model inference memory pool to avoid latency jitter caused by frequent memory recycling on edge devices; Power consumption adaptive scheduling: automatically switches to sleep mode when no finished products pass through, reducing power consumption to below 15mA.

[0028] The model update mechanism employs an industrial-grade dual-backup strategy: production line operators can upgrade the model simply by replacing a TF card, while the system retains a backup version in SPI flash memory to ensure rapid recovery in the event of a power outage. This solution eliminates cloud-based reliance, enabling fully offline AI testing in food factories without a network connection, and meets the closed-system requirements of ISO / TS 22002 food safety certification.

[0029] Sorting workflow Step 1: Preprocessing and image acquisition The products go through the pre-process in sequence: The metal detection unit detects foreign metal objects, and products exceeding the standard are rejected in real time by an independent agency; The weighing unit obtains weight data and transmits it to ESP32; Image acquisition: The weighing completion signal triggers the industrial camera to capture images of the top and side centerline areas of the product under set lighting conditions.

[0030] Step 2: Two-stage parallel screening Quality screening submodule (running on ESP32): Receives real-time weighing data, determines whether it is within a preset threshold range (e.g., 100g ± 2g), and verifies the metal detection result. Outputs a binary quality signal (0 for pass, 1 for fail).

[0031] Visual screening submodule (integrated OpenCV algorithm): Perform dual-algorithm collaborative detection: Contour analysis algorithm: Adaptively binarize the cropped centerline area (300 pixels wide) to extract contour features. If an abnormal area larger than 100 pixels and with an aspect ratio exceeding 5 is detected, it is determined to be a damaged or white defect. Fuzzy pattern matching algorithm: Extracts the production date inkjet print in a designated area and compares it to a pre-stored standard template for similarity. If the match score falls below a threshold of 0.85, the date is deemed missing, incorrect, or ambiguous. The final output is a binary visual signal (0 / 1).

[0032] Step 3: Relay Coordinated Control Relay K1 receives the quality screening signal, and K2 receives the visual screening signal; Qualified product: The relay remains disconnected only when K1 and K2 are both 0 (i.e. both quality and visual quality are qualified); Unqualified products: When any relay receives a signal "1" (such as quality exceeds the standard or the date is abnormal), the circuit is immediately closed (response time <15ms), triggering pneumatic execution.

[0033] Step 4: Pneumatic sorting execution High-pressure gas (0.6MPa) is ejected from a nozzle via a solenoid valve for 100ms, creating a directional airflow that precisely blows rejected products into a side-mounted waste bin. The measured rejection position error is ≤5mm.

[0034] Quality: It completely replaces manual visual inspection, increasing defect identification accuracy to 99.8% and reducing missed detection rates to below 0.2%. Efficiency: Production line speed increased by 40%, reducing changeover and commissioning time to under 30 minutes. Cost savings: Customer complaints due to white spots on packaging decreased by 80%, and complaints regarding production date issues decreased by 90%. Each production line eliminates two dedicated quality inspectors, reducing annual overall costs by approximately RMB 500,000 (based on a single line). Furthermore, quality data is synchronized to the MES system in real time, facilitating full-chain quality traceability.

[0035] The next step will be to introduce high-performance edge computing chips (such as the NVIDIA Jetson Nano) to replace the ESP32, enabling complex defect detection at over 10 finished products per second. Digital twin technology will be integrated to build a virtual production line model, enabling remote parameter tuning and fault prediction. The vision system will be expanded to include multi-angle inspection, covering 3D packaging seams and bottom inkjet printing. Ultimately, a comprehensive ecosystem traceability chain will be established, linking finished product packaging data with end-user consumer information through blockchain technology to create a closed-loop anti-counterfeiting and quality control platform.

[0036] In summary, this invention possesses significant technical advantages and innovations, exemplified by the following key aspects. The system innovatively utilizes the ESP32 chip as its core edge computing unit, which has been verified to be capable of efficiently processing image data at production line speeds (approximately 2-3 finished products per second). This significantly reduces hardware costs while ensuring real-time detection performance, enabling cost-effective edge intelligence deployment. At the detection algorithm level, the system creatively integrates a fuzzy pattern matching algorithm with a contour analysis algorithm. Working together, these two algorithms can efficiently and accurately identify complex packaging defects (such as white spots and damage) as well as various anomalies in production dates (missing, incorrect, and ambiguous), significantly improving detection coverage and accuracy.

[0037] Particularly critical is the original design of the screening execution mechanism. The system uses a completely independent relay to control the high-pressure gas injection valve, achieving a rapid response and rejection action in milliseconds. The core advantage of this design lies in its excellent compatibility and low cost: independent relay control ensures that the present invention can be seamlessly integrated into the existing production line and operates completely independently without the need for any changes to the existing quality identification or control equipment in the previous process; at the same time, the relay combined with the pneumatic rejection solution has much lower hardware cost and maintenance complexity than solutions such as robot or servo sorting, providing enterprises with a cost-effective and efficient automated screening solution and ensuring operational reliability in high-speed food production line environments.

[0038] Furthermore, the entire system has been integrated and validated in a real production line environment, demonstrating high stability and reliability, enabling stable, automated operation of the entire process, from image acquisition and intelligent analysis to precise rejection. (Specific measured data is recommended, such as a missed detection rate below X% and a false rejection rate below Y%). The system utilizes a modular architecture with standard sensor interfaces (such as Type-C and DB9, universal debugging serial ports) reserved for easy integration into the factory's Manufacturing Execution System (MES) for quality data tracking. It also facilitates rapid deployment and expansion to other production lines producing similar finished products.

[0039] This system utilizes a cascaded hybrid neural network architecture (a lightweight CNN + graph neural network) efficiently deployed on the ESP32 edge chip to simultaneously and accurately detect packaging defects and production date information for finished food products. Compared to the high missed detection rate of 20%-30% and the lack of date verification capabilities of traditional manual inspection, the system reduces the missed detection rate of packaging defects to below 0.5%. It also comprehensively verifies the presence, accuracy, and clarity of production dates (with a false positive rate of ≤0.1%). The millisecond-level response (<15ms) of the independent relay-controlled high-pressure gas valve and dynamic memory allocation technology ensure the system can stably handle peak production line throughput of 45-75 packages per minute. Dual TF card redundancy and a wide operating temperature range (-20°C to 85°C) guarantee 10,000 hours of continuous, trouble-free operation, completely breaking through the accuracy and reliability bottlenecks of traditional manual inspection.

[0040] The system replaces one dedicated quality inspector per production line with automated intelligent testing, saving 750,000 yuan in annual labor costs across five production lines. It also significantly reduces quality losses: the average annual customer complaint compensation due to packaging defects has dropped from an estimated 500,000 yuan to 10,000 yuan (an 83% decrease), and customer complaints regarding production date issues have essentially been eliminated, with an estimated loss avoidance of over 450,000 yuan in the first year. Regarding operations and maintenance, the TF card's 45-second physical die swap technology improves efficiency by 97% compared to traditional OTA upgrades, reducing annual production downtime by 230,000 yuan. Power consumption optimization eliminates energy costs, creating a three-pronged cost reduction system for labor, quality, and operations.

[0041] Full quality data is transmitted to the MES system via a dedicated serial port (without using ESP32 computing power), reducing production line quality traceability from hours of manual aggregation to 10 minutes, a sixfold increase in efficiency. The open binary model architecture supports seamless migration to high-performance platforms like Jetson, scaling inspection speeds to 120 packages per minute (1.6 times the current speed). The system's accumulated library of over 200,000 annotated samples and real-time feedback provide the core data engine for digital twin factories and federated learning-driven self-optimization systems, driving the transformation of food packaging inspection from single-function equipment to an intelligent, evolving ecosystem.

Claims

1. An inner package segment sorting system based on OpenCV logic control, characterized in that: include: Image acquisition module, used to acquire product packaging images; The screening module includes a quality screening submodule and a visual screening submodule. The quality screening submodule is used to detect product quality parameters, including product weight. The visual screening submodule is equipped with an OpenCV algorithm unit to detect visual parameters of product packaging, including the quality of the production date inkjet coding. a relay control module, comprising at least two relays connected in parallel, connected to the quality screening submodule and the visual screening submodule respectively, and triggering a switch action according to the screening results of the quality screening submodule and the visual screening submodule respectively; when a product passes both the quality screening and the visual screening, it is identified as a qualified product; otherwise, it is identified as an unqualified product; The pneumatic execution module includes a gas injection valve, which is driven by a relay to blow the unqualified products away from the conveying line.

2. The inner package segment sorting system based on OpenCV logic control according to claim 1 is characterized in that: It also includes a pre-processing module, which includes a metal detection unit and a weighing unit, which are used to detect whether there are metal foreign objects in the product and weigh the product.

3. The inner package segment sorting system based on OpenCV logic control according to claim 1 is characterized in that: The quality parameters include product packaging heat seal strength, product weight, and packaging integrity; the visual parameters include the presence, accuracy, and clarity of the production date inkjet coding.

4. The inner package segment sorting system based on OpenCV logic control according to claim 1 is characterized in that: The screening module is equipped with an ESP32 chip. Through the OpenCV algorithm unit based on the fuzzy pattern matching algorithm and contour analysis algorithm, the real-time image collected by the image acquisition module is compared with the pre-stored standard packaging template and defect template to detect visual parameters.

5. The inner package segment sorting system based on OpenCV logic control according to claim 1 is characterized in that: The pneumatic execution module further includes an air compressor, which is connected to the relay and the gas injection valve and is used to control the opening and closing of the gas injection valve according to the opening and closing drive of the relay.

6. A method for sorting inner package segments based on OpenCV logic control, characterized in that: The inner package segment sorting system based on OpenCV logic control according to any one of claims 1 to 5 comprises the following steps: Capturing product packaging images through the image acquisition module; The screening module performs a two-stage screening, including: Quality screening: testing product quality parameters, including product weight; Visual screening: using OpenCV algorithms to detect visual parameters of packaging, including the quality of the production date inkjet coding; The relay control module controls the relay operation. When a product passes both the quality screening and the visual screening, it is determined to be a qualified product and the relay is kept disconnected. When a product fails any of the screenings, it is determined to be an unqualified product and the switching operation of at least two parallel relays is triggered. The pneumatic actuator is driven by the pneumatic actuator unit, and the gas injection valve is turned on through the relay to blow the unqualified products away from the conveyor line.

7. The inner package segment sorting method based on OpenCV logic control according to claim 6 is characterized in that: Also includes: The preprocessing module performs the following preprocessing operations: Use the metal detection unit to detect whether there are metal foreign objects in the product; Obtain product weight data through weighing unit.

8. The inner package segment sorting method based on OpenCV logic control according to claim 6 is characterized in that: When the product passes the quality screening, the image of the product packaging is captured by the image acquisition module, and the visual screening submodule performs visual screening.