On-site sample training off-line vision object presence / absence detection system, method and storage medium

CN123015415APending Publication Date: 2026-10-30卢利斌
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611129312.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-28
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

其一,训练端与推理端的预处理逻辑缺乏统一绑定机制,多数方案仅下发模型权重文件,设备端采图、缩放、归一化等预处理逻辑由固件固定,不同硬件批次的成像差异、固件版本差异都会导致特征分布出现域偏移,使得现场推理准确率明显低于实验室训练验证效果;其二,模型更新机制不完善,更新过程中断电、传输中断或数据错误易导致设备端模型损坏,甚至造成设备无法启动,需返厂重新烧录固件,大幅提升运维成本与产线停机风险;其三,多数方案依赖上位机实时运算或云端算力支持,无法完全脱离上位机离线独立运行,在网络受限、防爆要求及移动作业场景中应用受限;其四,补光、曝光等采图参数与模型参数相互独立配置,现场环境光变化时,需分别调整硬件参数与模型判定阈值,参数脱节易引发检测精度波动,增加现场维护难度;其五,模型数据缺乏授权保护机制,存在被篡改、非法复制到未授权设备的风险,且接口适配性不足,难以兼容多样的工业现场总线与交互方式

Benefits of technology

1.部署门槛低:普通现场人员仅需采集少量有物体、无物体两类现场图像,即可完成模型训练与配置,无需专业视觉知识与规则编写,大幅降低工业视觉检测的应用门槛。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123015415A_ABST
    Figure CN123015415A_ABST
Patent Text Reader

Abstract

The application discloses an on-site sample training offline visual object existence detection system and method and a storage medium, and belongs to the field of machine vision and industrial sensing technology. In view of the problems of traditional photoelectric sensors being susceptible to interference, high deployment cost of general visual systems, inconsistent training and reasoning parameters of low-cost devices, poor model updating reliability, no security authorization and inability to run offline, etc., the application collects two types of images on site through a host computer, trains a binary classification model after performing preprocessing consistent with the sensor end, encapsulates preprocessing rules, model parameters, thresholds, light supplement strategies, authorization information and output configurations into a running model package, atomically activates the running model package to the sensor after block transmission and double-partition verification, and completes detection output offline after the sensor is disconnected from the host computer, thereby supporting multiple industrial interfaces and fault protection. The application significantly reduces the deployment threshold, guarantees the consistency of training and reasoning and the safety of the model, improves the operation reliability, and is suitable for various industrial detection scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of machine vision, industrial sensors, and embedded model deployment technology, and in particular to an offline visual object presence / absence detection system, method, and storage medium for on-site sample training. Background Technology

[0002] With the rapid advancement of intelligent manufacturing and flexible production, the demand for object presence detection scenarios in industrial production lines, such as material arrival detection, workstation occupancy confirmation, parts loading identification, and finished product unloading counting, continues to grow. This demand is also showing new characteristics, including diversified detection objects, increased production changeover frequency, and the lack of specialized personnel involved in on-site deployment. The compatibility issues between traditional detection solutions and emerging vision solutions are becoming increasingly prominent, making it difficult to simultaneously meet the multiple industrial site requirements of low cost, easy deployment, high reliability, and offline operation.

[0003] Traditional inspection solutions often employ contact or non-contact sensing devices such as infrared sensors and photoelectric sensors. These devices have low hardware costs and fast response times, making them widely used in standardized production lines for single-specification workpieces. However, the inspection performance of these solutions is highly dependent on the physical properties of the object being measured and the installation conditions. For scenarios such as irregularly shaped workpieces, semi-transparent or highly reflective materials, and dark objects against a dark background, the false detection and false negative rates increase significantly. Furthermore, even minor changes in the installation angle, detection distance, and ambient light intensity can cause detection failures. When changing production lines, repeated manual adjustments to sensitivity and installation position are often required, resulting in long calibration cycles and making it difficult to adapt to the rapid changeover requirements of flexible production lines.

[0004] General-purpose industrial vision systems rely on high-performance processors and mature vision algorithm libraries to determine the presence or absence of complex targets through template matching, deep learning detection, and other methods, offering greater environmental adaptability. However, these systems typically require industrial control computers, dedicated vision software, and commercial licenses, resulting in overall hardware and deployment costs that are dozens of times higher than traditional sensors. Furthermore, the configuration process involves specialized operations such as region of interest annotation, feature parameter debugging, and algorithm logic writing, which must be performed by technical personnel with vision development experience. Ordinary field maintenance personnel cannot configure and maintain these systems independently. In small-batch production lines, long-tail workstations, and small and medium-sized enterprise scenarios, the deployment threshold and investment costs are too high, making large-scale promotion and application difficult.

[0005] In recent years, embedded vision solutions based on low-cost camera modules have gradually emerged, attempting to achieve a balance between cost and performance. However, several technical shortcomings still exist in practical industrial applications. Firstly, the preprocessing logic of the training and inference ends lacks a unified binding mechanism. Most solutions only distribute model weight files, while the device-side preprocessing logic, such as image acquisition, scaling, and normalization, is fixed by firmware. Differences in imaging from different hardware batches and firmware versions can lead to domain shifts in feature distribution, resulting in significantly lower inference accuracy in the field compared to laboratory training and validation. Secondly, the model update mechanism is imperfect. Power outages, transmission interruptions, or data errors during updates can easily damage the device-side model, even causing the device to fail to start, requiring it to be returned to the factory for firmware re-flashing, significantly increasing maintenance costs and production line downtime risks. Thirdly... Most solutions rely on real-time computing by a host computer or cloud computing power, and cannot operate independently offline without a host computer. Their application is limited in scenarios with restricted networks, explosion-proof requirements, and mobile operations. Fourth, the imaging parameters such as supplementary lighting and exposure are configured independently from the model parameters. When the ambient light changes, the hardware parameters and model judgment thresholds need to be adjusted separately. The disconnect between parameters can easily cause fluctuations in detection accuracy and increase the difficulty of on-site maintenance. Fifth, the model data lacks an authorization protection mechanism, which poses a risk of being tampered with or illegally copied to unauthorized devices. In addition, the interface adaptability is insufficient, making it difficult to be compatible with various industrial fieldbuses and interaction methods.

[0006] Therefore, there is an urgent need in this field for a low-cost offline visual object detection solution that has low deployment threshold, high operational reliability, strong consistency between training and inference, and a secure authorization mechanism. Summary of the Invention

[0007] The purpose of this invention is to overcome the shortcomings of the prior art and solve the following technical problems: 1. Traditional photoelectric / infrared sensors have weak anti-interference capabilities and are easily affected by the characteristics of the measured object and environmental factors; 2. General industrial vision systems have high deployment costs and complex configurations, and ordinary field personnel cannot operate them independently; 3. Inconsistent preprocessing and image acquisition parameters between the training and inference ends of low-cost vision devices lead to decreased accuracy after the model is distributed. 4. The model update process is prone to device failure due to power outages or transmission interruptions, and it cannot run independently offline without the host computer; 5. The model data lacks a secure authorization mechanism, making it easy to be tampered with or illegally copied, and its industrial interface adaptability is insufficient.

[0008] To achieve the above objectives, the present invention provides the following technical solution: On-site sample training of an offline visual object presence / absence detection system, including a host computer and visual sensors; The host computer is configured to: acquire a first image set containing the target object and a second image set not containing the target object, collected by the vision sensor in the target installation scene; perform deterministic preprocessing on the first image set and the second image set consistent with that on the vision sensor, extract features and train a binary classification model; encapsulate the preprocessing description, model parameters, judgment threshold and running configuration into a running model package with version identification and integrity verification, and send it to the vision sensor; The visual sensor includes an image acquisition unit, a supplementary lighting unit, a processor, a non-volatile memory, a communication interface, and a status output interface. The processor is configured to: receive and verify the running model package and store it in the non-volatile memory; in an offline state disconnected from the host computer, process the image to be tested according to the preprocessing description in the running model package, generate the presence or absence of an object based on model parameters and a judgment threshold, and synchronously output the detection results through the status output interface.

[0009] Furthermore, the operating configuration includes at least two of the following: fill light parameters, exposure parameters, working mode parameters, shaking parameters, and output polarity parameters; the fill light parameters and exposure parameters are recorded synchronously during the image acquisition process and executed by the visual sensor according to the parameters during offline inference to match the image acquisition conditions during the training phase.

[0010] Furthermore, the preprocessing description at least defines the input image size, color channel order, brightness calculation method, feature arrangement order, normalization method, ROI enabling state, ROI coordinates / size / transformation parameters, quantization parameters, and image cropping / scaling method, so that the host computer training end and the vision sensor inference end generate feature vectors with consistent dimensions and values ​​according to the same rules; when the new running model package does not enable ROI, the vision sensor automatically clears the historical ROI configuration or defaults to using the entire image region for detection.

[0011] Furthermore, the running model package has a built-in authorization verification field, which includes encrypted data segments, digital signature information, or device unique identifier binding information. When the visual sensor loads the running model package, it first performs signature verification, device binding matching verification, and encrypted decryption verification. If the verification fails, the model package is refused to be loaded to prevent the model parameters from being tampered with or copied to unauthorized devices for operation.

[0012] Furthermore, the non-volatile memory is divided into an active model area and an inactive model area; newly received running model packets are written to the inactive model area, and after passing length verification, integrity verification, format verification, dimension verification and version compatibility verification, the activation record is updated and the active model is atomically switched; when verification fails or transmission is interrupted, the model in the original active model area is kept running normally.

[0013] Furthermore, the running model package is transmitted in blocks as multiple model data blocks carrying sequence numbers and offset information; the vision sensor returns confirmation information for each data block, and the host computer retransmits the corresponding data block when a timeout occurs or a negative confirmation is received.

[0014] Furthermore, the vision sensor supports both a trigger-based operating mode and a continuous operating mode, with both modes sharing the same image acquisition, preprocessing, inference, and de-jitter pipeline. In the trigger-based mode, the sensor responds to external trigger signals or local button trigger signals to perform a predetermined number of detections, while in the continuous mode, the sensor repeats detections according to a set period. After de-jitter processing, the detection results are output through the communication interface as a message containing the status, confidence level, and inference time, and the I / O interface level is updated synchronously.

[0015] Training an offline visual object detection method using on-site samples includes the following steps: S1. In the target installation scenario, acquire a first image set containing the target object and a second image set not containing the target object, and simultaneously record the image acquisition and supplementary lighting parameters. S2. Perform deterministic preprocessing on the two types of images in the host computer, consistent with that at the sensor end, extract features and train a binary classification model, and determine the judgment threshold based on the training set, validation set, cross-validation results or a preset threshold strategy. S3. Encapsulate the preprocessing description, model parameters, decision threshold, supplementary lighting parameters, and output configuration into a runtime model package with integrity verification; S4. Write the running model package into blocks and write them into the inactive model area of ​​the vision sensor. After verification, switch to the active model. S5. After the visual sensor is separated from the host computer, it loads the active model package from the non-volatile memory, performs preprocessing and binary classification inference on the image to be tested in the same way as training, and outputs the detection result of whether the object is detected.

[0016] Furthermore, in step S4, if the model transmission is interrupted, the verification fails, or the version is incompatible, the original active model is retained and the device continues to work normally with the original model; the activation record is only updated and the model switching is completed after all verifications pass; when the vision sensor detects no valid model, abnormal image acquisition unit, or abnormal inference process, the output interface is set to the preset fault output state and the corresponding fault code is reported through the communication interface.

[0017] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the on-site sample training offline visual object presence / absence detection method described in any of the second aspects above.

[0018] Compared with the prior art, the present invention has the following beneficial effects: 1. Low deployment threshold: Ordinary field personnel only need to collect a small number of field images with and without objects to complete model training and configuration. No professional vision knowledge or rule writing is required, which greatly reduces the application threshold of industrial vision inspection.

[0019] 2. Strong consistency between training and inference: The ROI rules, preprocessing rules, supplementary lighting and exposure parameters, model weights, decision thresholds and output configurations are uniformly encapsulated into a running model package, ensuring that the parameters of image acquisition, cropping and scaling, feature extraction and inference are consistent between the training end and the device end, effectively reducing domain offset and ensuring the detection accuracy after the model is deployed; the ROI function can focus on the target area, compress the amount of computation and improve the inference speed.

[0020] 3. High reliability of model updates: The dual-model partitioning design is adopted. The new model is written to the inactive area and is atomically activated after multiple verifications. The original usable model will not be destroyed in the event of transmission interruption, power failure or verification failure. The equipment can continue to work normally and avoid production line downtime caused by update failure.

[0021] 4. Robust security authorization mechanism: The model package has built-in encryption, signature and device binding verification, which can effectively prevent model parameters from being tampered with or illegally copied, and improve the security of industrial field data and equipment.

[0022] 5. Offline independent operation and strong adaptability: The model and configuration are all stored in non-volatile memory. After the sensor is powered off and restarted, the model can be automatically loaded, and detection and output can be completed independently without the host computer. It supports multiple communication interfaces such as USB CDC, UART, Type-C, RS485, and CAN. It is compatible with button triggering and external signal triggering, and outputs messages and industrial IO levels synchronously. It is easy to connect to industrial control equipment such as PLCs and adapts to various industrial field scenarios. Attached Figure Description

[0023] Figure 1 is a block diagram of the system architecture described in this invention; Figure 2 is a schematic diagram of the on-site sample training and model distribution process described in this invention; Figure 3 is a schematic diagram of the data structure of the running model package described in this invention; Figure 4 is a schematic diagram of the process of downloading, verifying and activating the dual model region according to the present invention; Figure 5 is a schematic diagram of the state machine for the triggering mode and the continuous mode described in this invention; Figure 6 is a timing diagram of the supplementary lighting, exposure, inference, and output described in this invention. Detailed Implementation

[0024] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0025] In a first aspect, the present invention provides an offline visual object presence / absence detection system for on-site sample training, including a host computer and a visual sensor; The host computer is configured to: acquire a first image set containing the target object and a second image set not containing the target object, collected by the vision sensor in the target installation scene; perform deterministic preprocessing on the first image set and the second image set consistent with that on the vision sensor, extract features and train a binary classification model; encapsulate the preprocessing description, model parameters, judgment threshold and running configuration into a running model package with version identification and integrity verification, and send it to the vision sensor; The visual sensor includes an image acquisition unit, a supplementary lighting unit, a processor, a non-volatile memory, a communication interface, and a status output interface. The processor is configured to: receive and verify the running model package and store it in the non-volatile memory; in an offline state disconnected from the host computer, process the image to be tested according to the preprocessing description in the running model package, generate the presence or absence of an object based on model parameters and a judgment threshold, and synchronously output the detection results through the status output interface.

[0026] Furthermore, the operating configuration includes at least two of the following: fill light parameters, exposure parameters, working mode parameters, shaking parameters, and output polarity parameters; the fill light parameters and exposure parameters are recorded synchronously during the image acquisition process and executed by the visual sensor according to the parameters during offline inference to match the image acquisition conditions during the training phase.

[0027] Furthermore, the preprocessing description at least defines the input image size, color channel order, brightness calculation method, feature arrangement order, normalization method, ROI enabling state, ROI coordinates / size / transformation parameters, quantization parameters, and image cropping / scaling method, so that the host computer training end and the vision sensor inference end generate feature vectors with consistent dimensions and values ​​according to the same rules; when the new running model package does not enable ROI, the vision sensor automatically clears the historical ROI configuration or defaults to using the entire image region for detection.

[0028] Furthermore, the running model package has a built-in authorization verification field, which includes encrypted data segments, digital signature information, or device unique identifier binding information. When the visual sensor loads the running model package, it first performs signature verification, device binding matching verification, and encrypted decryption verification. If the verification fails, the model package is refused to be loaded to prevent the model parameters from being tampered with or copied to unauthorized devices for operation.

[0029] Furthermore, the non-volatile memory is divided into an active model area and an inactive model area; newly received running model packets are written into the inactive model area, and after passing length verification, integrity verification, format verification, dimension verification and version compatibility verification, the activation record is updated and the active model is atomically switched; when verification fails or transmission is interrupted, the model in the original active model area is kept running normally.

[0030] Furthermore, the running model package is transmitted in blocks as multiple model data blocks carrying sequence numbers and offset information; the vision sensor returns confirmation information for each data block, and the host computer retransmits the corresponding data block when a timeout occurs or a negative confirmation is received.

[0031] Furthermore, the vision sensor supports both a trigger-based operating mode and a continuous operating mode, with both modes sharing the same image acquisition, preprocessing, inference, and de-jitter pipeline. In the trigger mode, the sensor responds to external trigger signals or local button trigger signals to perform a predetermined number of detections, while in the continuous mode, the sensor repeats detections according to a set cycle. After de-jitter processing, the detection results are output through the communication interface as a message containing the status, confidence level, and inference time, and the IO interface level is updated synchronously.

[0032] Secondly, the present invention provides a method for offline visual object presence / absence detection using on-site sample training, comprising the following steps: S1. In the target installation scenario, acquire a first image set containing the target object and a second image set not containing the target object, and simultaneously record the image acquisition and supplementary lighting parameters. S2. Perform deterministic preprocessing on the two types of images in the host computer, consistent with that at the sensor end, extract features and train a binary classification model, and determine the judgment threshold based on the training set, validation set, cross-validation results or a preset threshold strategy. S3. Encapsulate the preprocessing description, model parameters, decision threshold, supplementary lighting parameters, and output configuration into a runtime model package with integrity verification; S4. Write the running model package into blocks and write them into the inactive model area of ​​the vision sensor. After verification, switch to the active model. S5. After the visual sensor is separated from the host computer, it loads the active model package from the non-volatile memory, performs preprocessing and binary classification inference on the image to be tested in the same way as training, and outputs the detection result of whether the object is detected.

[0033] Furthermore, in step S4, if the model transmission is interrupted, the verification fails, or the version is incompatible, the original active model is retained and the device continues to work normally with the original model; the activation record is only updated and the model switching is completed after all verifications pass; when the vision sensor detects no valid model, abnormal image acquisition unit, or abnormal inference process, the output interface is set to the preset fault output state and the corresponding fault code is reported through the communication interface.

[0034] Thirdly, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the on-site sample training offline visual object presence / absence detection method described in any of the second aspects above.

[0035] The present invention will be further described below with reference to the accompanying drawings and specific embodiments. The following embodiments are for illustrative purposes only and are not intended to limit the scope of protection of the present invention.

[0036] Example 1: As shown in Figure 1, this embodiment provides an offline visual object presence / absence detection system for on-site sample training, including a host computer 100 and a visual sensor 200, which are connected by a configured communication link 300; the output of the visual sensor 200 is connected to a control board or PLC 400 for outputting the detection status.

[0037] The host computer 100 has a built-in sample acquisition module 110, a model training module 120, and a model packaging module 130. The sample acquisition module 110 is used to control the vision sensor 200 to acquire two types of images according to predetermined rules; the model training module 120 is used to perform image preprocessing, ROI cropping, feature extraction, model training and verification; the model packaging module 130 is used to package all running parameters and authorization information into a standardized running model package 500.

[0038] The vision sensor 200 includes an image acquisition unit 210, a supplementary lighting unit 220, a processor 230, a non-volatile memory 240, and a status output interface 250. The image acquisition unit 210 can use a low-cost CMOS image sensor supporting DVP, MIPI, or parallel interfaces, such as GC2145, OV2640, or FD5640, to acquire images from the scene. The supplementary lighting unit 220 uses dual-channel white light supplementary lamps to provide stable illumination for image acquisition. The processor 230 uses an ESP32-S3 microcontroller to perform image preprocessing, model inference, and status control. The non-volatile memory 240 uses Flash storage, divided into an active model area 610 and an inactive model area 620, used to store running model packages and activation records 630. The status output interface 250 includes serial communication interfaces such as UART, USB CDC, Type-C, RS485, and CAN, as well as industrial I / O interfaces, supporting button-triggered input for synchronous output of detection results and reception of control signals.

[0039] As shown in Figure 2, the on-site sample training and model deployment process of this system is as follows: S101: Install the vision sensor 200 at the target workstation and lock the field of view, completing hardware fixation and wiring; S102: It can be triggered by the host computer command or local button to control the vision sensor 200 to collect images when the target object is placed, forming a first image set containing the target object. At least 10 images of each type are collected, preferably 30 to 50 images. S103: Remove the target object and control the vision sensor 200 to acquire images without the target object, forming a second image set that does not contain the target object; during the acquisition process, the acquisition parameters such as the brightness of the supplementary light and the exposure time are recorded simultaneously. If a ROI area is configured, the ROI coordinates and size information are recorded simultaneously. S104: The host computer 100 performs deterministic preprocessing and data augmentation on two types of images. The preprocessing logic is completely consistent with that of the sensor. First, the target area is cropped according to the ROI parameters. Then, the image is scaled to a specified size and divided into a set grid. The RGB three-channel values ​​and normalized brightness are extracted from each grid. After quantization, a fixed-dimensional feature vector is generated. Data augmentation uses up, down, left, and right translation transformations to expand the number of samples. S105: After feature extraction, train a logistic regression binary classifier with L2 regularization. Determine the optimal decision threshold based on the training set, validation set, cross-validation results, or a preset threshold strategy. After successful validation, use all samples to generate the final model. S106: Binding judgment threshold, fill light parameters, working mode parameters, shading parameters and output polarity and other operation configurations; S107: Encapsulate the preprocessing description, ROI configuration, normalization parameters, classifier parameters, threshold, runtime configuration, authorization encryption and signature information into a runtime model package 500 with version number, total length and integrity verification value; S108: The host computer 100 writes the running model package 500 into blocks into the inactive model area 620 of the vision sensor 200; S109: After the sensor completes the authorization verification and multi-format verification, it atomically activates the new model and enters the offline inference working state.

[0040] As shown in Figure 3, the runtime model package 500 adopts a structured design and includes the following fields: The header (510) stores the format identifier, model version, firmware compatibility version, and total length. The ROI and preprocessing fields (520) store the ROI enable status, coordinate / size parameters, input size, mesh generation rules, feature extraction method, cropping / scaling rules, and quantization parameters. The normalization and classification parameter fields (530) store the feature mean, standard deviation, classifier weights, and biases. The decision configuration field (540) stores the decision threshold, uncertainty interval, de-jitter time, and number of consecutive consistent occurrences. The output configuration field (550) stores the communication frame format, IO polarity, preset fault output state definition, and fault code mapping. The supplementary lighting field (560) stores the supplementary lighting brightness, exposure duration, and timing parameters. The authorization and security field (570) stores the encryption key identifier, digital signature, and device binding identifier. The integrity information field (580) stores the CRC or hash checksum. The running model package (500) can use a UTF-8 JSON format .zgm file, which can be converted to a fixed-length binary structure for mass production to improve loading efficiency.

[0041] As shown in Figure 4, the process of downloading, verifying, and atomically activating the model in the dual-model region is as follows: Initially, the active model area A 610 stores the currently available models, and the device operates normally; the inactive model area B 620 is in a pending write state. When the host computer sends the MODEL_BEGIN command, the sensor erases the inactive model area B 620, records the total model length and the expected verification value, and the active model area A 610 continues to operate normally and is unaffected.

[0042] The host computer sends model data in blocks using the MODEL_CHUNK command. Each data block carries a sequence number, offset, and segment verification value. The sensor writes the data block by block into the inactive model area B 620 and returns an ACK confirmation for each block. If a timeout or verification error occurs, the host computer retransmits the corresponding data block. After all data blocks have been transmitted, the host computer sends the MODEL_COMMIT command. The sensor then performs authorization verification, length verification, integrity verification, format verification, dimension verification, and firmware version compatibility verification on the complete model in the inactive model area B 620.

[0043] If the verification fails, the sensor reports an error message, and the active model area A610 is retained as the current operating model, and the device continues to operate normally.

[0044] If the verification is successful, the sensor updates the verified active record 630, and atomically switches the inactive model area B 620 to the new active model area; during the next model update, the original active model area A 610 becomes the inactive model area, and the two are used alternately in a cycle.

[0045] During the entire update process, any interruption in transmission or power failure at any stage will not damage the original activity model, and the device will always remain available.

[0046] As shown in Figure 5, the vision sensor 200 supports both trigger mode and continuous mode, with both modes sharing a unified inference pipeline 750.

[0047] After the device is powered on, it enters the initialization state 710, loads the activity model from the non-volatile memory 240 and performs authorization and integrity verification; after the verification is successful, it enters the standby state 720, waiting for external trigger signals, local button trigger signals or timer cycles.

[0048] When an external trigger signal or a button trigger signal is received, the system enters trigger mode 730 and executes the detection process once or a predetermined number of times. When the timer period arrives, the system enters continuous mode 740 and repeats the detection process according to the set period.

[0049] The unified inference pipeline 750 sequentially executes supplementary lighting control, image acquisition, ROI cropping, preprocessing, classification inference, threshold comparison, and jitter reduction. Jitter reduction is achieved by measuring the duration of detection results or the number of consecutive consistent occurrences to avoid false triggers. After inference is complete, it enters the synchronous output state 760, outputting a status frame containing the presence or absence of an object, confidence level, and inference time via communication interfaces such as UART / RS485 / CAN / USB, while simultaneously updating the level state of the IO interfaces. After outputting, the trigger mode returns to the standby state 720, while the continuous mode waits for the next cycle.

[0050] As shown in Figure 6, the timing sequence of illumination, exposure, inference, and output is as follows: Upon arrival of the external trigger signal TRIG or button trigger, the supplementary lighting unit 220 is first illuminated and maintained for a pre-brightness duration to stabilize the illumination. Then, the exposure EXPOSURE is initiated, and after exposure, the image frame FRAME READY is read. Once the image is ready, inference calculation of INFER is initiated. After inference is completed, the communication message and IO level output are updated synchronously, with the message including the inference time data. The supplementary lighting unit can employ a dual-path alternating illumination method, fusing the detection results of two frames to improve robustness.

[0051] When the vision sensor 200 detects faults such as no valid model, abnormal camera communication, incorrect inference parameters, or failed authorization verification, it automatically sets the IO output to the preset fault output state and reports the corresponding fault code through the communication interface to ensure equipment safety in the industrial field.

[0052] Example 2: This embodiment is an alternative implementation. The feature extraction method can be replaced by grayscale histogram, edge features, texture features, lightweight convolutional network features, or embedding vectors; the classifier can be replaced by linear support vector machine, Naive Bayes, nearest neighbor classifier, or small neural network.

[0053] The communication physical layer can use USB, RS-485, CAN, Ethernet or Bluetooth to replace the basic UART; the runtime model package can use CBOR, TLV or binary container format; the integrity verification algorithm can use CRC, hash or digital signature, and the authorization mechanism can be extended to online activation, time-limited authorization and other modes.

[0054] The supplementary lighting unit can use single or multiple white light or infrared light sources, and supports constant illumination before exposure, exposure-synchronized flash, or alternating illumination modes; the output interface can be in the form of open drain, relay, differential bus, or network message, and the detection status can be expanded to include multiple states such as presence, absence, uncertainty, and fault.

[0055] Image sensors can be selected from different models of DVP, MIPI, or parallel interface CMOS sensors, depending on cost and resolution requirements, to adapt to application scenarios with different fields of view and detection distances.

[0056] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. An offline visual object presence / absence detection system trained on-site samples, characterized in that, Including host computer and vision sensor; The host computer is configured to: acquire a first image set containing the target object and a second image set not containing the target object, collected by the vision sensor in the target installation scene; perform deterministic preprocessing on the first image set and the second image set consistent with that on the vision sensor, extract features and train a binary classification model; encapsulate the preprocessing description, model parameters, judgment threshold and running configuration into a running model package with version identification and integrity verification, and send it to the vision sensor; The vision sensor includes an image acquisition unit, a supplementary lighting unit, a processor, a non-volatile memory, a communication interface, and a status output interface; The processor is configured to receive and verify the running model package and then store it in a non-volatile memory; In offline mode, without the host computer, the image to be tested is processed according to the preprocessing description in the running model package. The presence or absence of objects is generated based on the model parameters and the judgment threshold, and the detection results are output synchronously through the state output interface.

2. The on-site sample training offline visual object presence / absence detection system according to claim 1, characterized in that, The operating configuration includes at least two of the following: fill light parameters, exposure parameters, working mode parameters, shaking parameters, and output polarity parameters; the fill light parameters and exposure parameters are recorded synchronously during the image acquisition process and executed by the vision sensor according to the parameters during offline inference to match the image acquisition conditions during the training phase.

3. The on-site sample training offline visual object presence / absence detection system according to claim 1, characterized in that, The preprocessing description at least defines the input image size, color channel order, brightness calculation method, feature arrangement order, normalization method, ROI enabling state, ROI coordinates / size / transformation parameters, quantization parameters, and image cropping / scaling method, so that the host computer training end and the vision sensor inference end generate feature vectors with consistent dimensions and values ​​according to the same rules; when the new running model package does not enable ROI, the vision sensor automatically clears the historical ROI configuration or defaults to using the entire image region for detection.

4. The on-site sample training offline visual object presence / absence detection system according to claim 1, characterized in that, The running model package has a built-in authorization verification field, which includes encrypted data segments, digital signature information, or device unique identifier binding information. When the vision sensor loads the running model package, it first performs signature verification, device binding matching verification, and encrypted decryption verification. If the verification fails, the model package is refused to be loaded to prevent the model parameters from being tampered with or copied to unauthorized devices for operation.

5. The on-site sample training offline visual object presence / absence detection system according to claim 1, characterized in that, The non-volatile memory is divided into an active model area and an inactive model area. Newly received running model packets are written to the inactive model area. After all length verification, integrity verification, format verification, dimension verification and version compatibility verification are passed, the activation record is updated and the active model is atomically switched. If the verification fails or the transmission is interrupted, the model in the original active model area is kept running normally.

6. The on-site sample training offline visual object presence / absence detection system according to claim 5, characterized in that, The running model package is transmitted in blocks, consisting of multiple model data blocks carrying sequence numbers and offset information. The vision sensor returns confirmation information for each data block, and the host computer retransmits the corresponding data block when a timeout occurs or a negative confirmation is received.

7. The on-site sample training offline visual object presence / absence detection system according to claim 1, characterized in that, The vision sensor supports both trigger-based and continuous operation modes. Both modes share the same image acquisition, preprocessing, inference, and de-shaking pipeline. In trigger mode, the sensor responds to external trigger signals or local button trigger signals to perform a predetermined number of detections. In continuous mode, the sensor repeats detections according to a set period. After the detection results are de-jittered, a message containing the status, confidence level, and inference time is output through the communication interface, and the IO interface level is updated synchronously.

8. A method for detecting the presence or absence of visual objects using on-site sample training, characterized in that: Includes the following steps: S1. In the target installation scenario, acquire a first image set containing the target object and a second image set not containing the target object, and simultaneously record the image acquisition and supplementary lighting parameters. S2. Perform deterministic preprocessing on the two types of images in the host computer, consistent with that at the sensor end, extract features and train a binary classification model, and determine the judgment threshold based on the training set, validation set, cross-validation results or a preset threshold strategy. S3. Encapsulate the preprocessing description, model parameters, decision threshold, supplementary lighting parameters, and output configuration into a runtime model package with integrity verification; S4. Write the running model package into blocks and write them into the inactive model area of ​​the vision sensor. After verification, switch to the active model. S5. After the visual sensor is separated from the host computer, it loads the active model package from the non-volatile memory, performs preprocessing and binary classification inference on the image to be tested in the same way as training, and outputs the detection result of whether the object is detected.

9. The method for offline visual object presence / absence detection using on-site sample training according to claim 8, characterized in that, In step S4, if the model transmission is interrupted, the verification fails, or the version is incompatible, the original active model is retained and the device continues to work normally with the original model. The activation record is only updated and the model switching is completed after all verifications pass. When the vision sensor detects that there is no valid model, the image acquisition unit is abnormal, or the inference process is abnormal, the output interface is set to the preset fault output state and the corresponding fault code is reported through the communication interface.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the on-site sample training offline visual object presence / absence detection method according to any one of claims 8 to 9.