Gas meter flashing light identification method and device based on visual self-adaption
The visually adaptive gas meter flashing light recognition method solves the problems of insufficient automatic positioning, adaptive judgment and anomaly handling capabilities in the existing technology, and realizes accurate counting and unattended operation in dynamic environments, meeting the traceability requirements in the field of metering.
Patent Information
- Application Number
- CN202511704941.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-20
- Publication Date
- 2026-01-27
AI Technical Summary
Existing gas meter flashing light recognition technology lacks the ability to automatically locate, adaptively decide, effectively suppress jitter, and handle anomalies in dynamic and changing industrial environments, resulting in frequent errors of omission or over-recording in the counting results.
A vision-adaptive gas meter flashing light recognition method is adopted. Through automatic ROI positioning and stability assessment, a decision model is established through autonomous learning. Combined with probability discrimination and state machine to filter noise, the flashing lights can be accurately counted, and parameters can be rolled back and alarms can be triggered in abnormal situations.
It significantly improves the accuracy of flashing light counting, reduces manual configuration time, achieves stable unattended operation, and meets the traceability requirements in the metrology field.
Smart Images

Figure CN121415052A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of industrial automation detection and metrology, and in particular to a visual self-adaptive gas meter flash light identification method and device. BACKGROUND
[0002] In the production, verification and calibration process of gas meters, it is usually necessary to verify the accuracy of the metrology pulse by reading the LED (Light Emitting Diode) flash light signal. The traditional detection method mainly relies on photoelectric sensors or photosensitive probes, which require precise mechanical alignment, and the fixed light intensity threshold is easily disturbed by factors such as environmental light changes, measured meter surface material reflection, LED light decay or individual differences, resulting in frequent "missed" or "overcounted" errors in the counting results.
[0003] To overcome the above-mentioned defects, a computer vision-based identification method is introduced. However, the existing visual scheme also faces many challenges: first, the positioning of the Region of Interest (ROI) depends on manual preset or simple template matching, and when the position, posture or model of the measured meter changes, the ROI is easily invalidated. Second, using a fixed brightness threshold for flash light state discrimination, it is still difficult to effectively deal with the brightness drift caused by factors such as camera auto-exposure adjustment, environmental light mutation or LED brightness nonlinearity. Third, for the brightness jitter of the flash light at the on-off state switching edge, the existing methods generally lack effective hysteresis and time domain consistency constraint mechanisms, resulting in a large number of repeated counts caused by noise near the decision boundary. Finally, most systems lack a complete online adaptive and abnormal state processing closed loop, and cannot quickly converge from the initial unknown state without human intervention, and cannot effectively roll back parameters and issue warnings when encountering LED sticking (constant on / off) or ROI failure.
[0004] In summary, the core problem of the existing technology in the identification of gas meter flash light is that in a dynamic and variable industrial environment, there is a lack of a robust identification mechanism that can automatically locate, adaptively judge, effectively suppress jitter and has abnormal processing capability. SUMMARY
[0005] The present application aims to overcome the deficiencies of the prior art and provide a visual self-adaptive gas meter flash light identification method and device to solve at least one of the above problems.
[0006] To achieve the above-mentioned purposes, the technical solutions adopted by the present application are as follows: In a first aspect, the present application provides a visual self-adaptive gas meter flash light identification method, which comprises: Initialization and self-checking; performing image acquisition and exposure control strategy to provide image data; performing ROI auto-localization and stability evaluation operation on the image data, if the ROI is unstable, updating the candidate image data and continuing to evaluate whether the ROI is stable, if the ROI is stable, entering fast adaptive initialization, learning and establishing a decision model for the current target by analyzing the previous two flashes; for each new image, extracting features and performing probability discrimination; filtering out noise and confirming the effective count of flashes through a state machine; each effective count is recorded, traced back, and used for online adjustment of the decision model; outputting the recognition result of the number of flashes.
[0007] Optionally, the ROI auto-localization comprises: finding the area where the brightness in the image changes over time through time domain fluctuation analysis, calculating the inter-frame brightness variance of each pixel block in the image by maintaining an image sequence cache with a length of W, and generating multiple preliminary candidate ROIs by adaptively thresholding the inter-frame brightness variance heat map; performing frequency domain energy analysis on the multiple preliminary candidate ROIs, performing Fourier transform on the brightness time series of each candidate ROI, and calculating the normalized frequency band energy ratio of each candidate ROI in the preset flash frequency band; selecting the candidate ROIs using morphological prior analysis, calculating a candidate confidence score for each candidate ROI, and confirming the effective ROIs according to the candidate confidence scores.
[0008] Optionally, in the process of learning and establishing a decision model for the current target by analyzing the previous two flashes: waiting for and completely capturing the previous two effective flash pulses in the ROI, calculating μ_on, σ_on, μ_off, σ_off and the separability index SI by analyzing the brightness feature distribution during the on and off states of the two pulses, and calculating the separability index SI, which is defined as SI=(μ_on-μ_off) / sqrt(σ_on^2+σ_off^2), only when SI is greater than a preset threshold, the statistical parameters obtained will be directly used for the decision model, μ_on, σ_on, μ_off, and σ_off respectively refer to the mean and standard deviation of the brightness features of the light-emitting diode in the on and off states obtained by online statistics.
[0009] Optionally, in the step of extracting features and making probability discrimination for each new image frame: for each new image frame, a multidimensional feature vector φ(x) is extracted from the ROI and input into the decision model, and the probability P(on) of the LED being on in the current frame is output. The probability P(on) is used for subsequent model decisions.
[0010] Optionally, in the process of filtering noise and confirming the valid count of the flashing light through the state machine, two different preset thresholds T_on and T_off are used to determine the rising and falling edges of the state, with T_on > T_off, forming a hysteresis interval for de-jittering. The flashing light is only confirmed as a valid pulse when the bright state lasts for more than the preset minimum effective pulse width t_min, thereby filtering out instantaneous noise. After each successful count, the state machine enters a refractory period of t_ref, during which all new rising edge signals are blocked to avoid repeated counting.
[0011] Optionally, the method further includes: continuously monitoring the stability of the ROI and the drift of the brightness statistics parameters; once an anomaly is detected, immediately freezing the online learning; and taking measures such as parameter rollback or ROI relocation according to the type of anomaly.
[0012] In a second aspect, the present invention also provides a vision-adaptive gas meter flashing light recognition device, the device being used to implement the vision-adaptive gas meter flashing light recognition method according to the first aspect, the device comprising: The image acquisition module is used to capture real-time video data streams including the gas meter, and the data streams enter the central processing module via a high-speed bus. The central processing module is used to perform the identification operation in the gas meter flashing light identification method; The storage module includes non-volatile memory and DDR memory. Temporary data required by the central processing module during operation is stored in DDR memory, while firmware, self-learning parameter library and calibration log are permanently stored in non-volatile memory. The output and interface module includes a network module, a general-purpose I / O module, a clock output module, and a peripheral interface module. The identification results and system status are reported to the host system via the network module in HTTP or JSON format. The general-purpose I / O module is linked with the PLC device in real time via DI / DO signals. The clock output module provides 1PPS and 32.768kHz time and frequency signals that can be externally verified. The peripheral interface module provides expansion capabilities for the gas meter flashing light identification device.
[0013] The beneficial effects of this invention include: The visually adaptive gas meter flashing light recognition method provided by this invention includes: initialization and self-test; execution of image acquisition and exposure control strategies to provide image data; automatic ROI location and stability evaluation of the image data; if the ROI is unstable, updating candidate image data and continuing to evaluate ROI stability; if the ROI is stable, entering rapid adaptive initialization; autonomously learning and establishing a decision model for the current target by analyzing the first two flashes; extracting features and performing probabilistic discrimination for each new image frame; filtering noise and confirming the valid count of flashes through a state machine; recording and tracing each valid count and using it for online adjustment of the decision model; and outputting the recognition result of the number of flashes. This invention significantly improves the accuracy of flashing light counting through multi-evidence fusion ROI location, probabilistic decision-making, and a precise hysteresis and temporal anti-shake state machine. The "two flashes" rapid initialization mechanism allows the system to quickly enter a stable working state after power-on or replacement of the tested object, greatly reducing manual configuration and debugging time. Online learning and anomaly rollback closed loop ensure that the device can autonomously adapt to slow environmental changes and recover from anomalies, achieving true unattended operation. Detailed calibration logs record all metadata for each count, providing a solid basis for quality analysis and troubleshooting. The output of standard time and frequency signals such as 1PPS and 32.768kHz allows the device's timing accuracy to be verified by authoritative institutions, meeting the stringent traceability requirements of the metrology field. Standardized hardware interfaces (Ethernet, DI / DO, USB, RS232) and software protocols (HTTP / JSON) enable easy integration into existing automated production lines and seamless interoperability with PLC, MES, and other systems, reducing the complexity and cost of engineering implementation. Attached Figure Description
[0014] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0015] Figure 1 The diagram shows a structural block diagram of a vision-adaptive gas meter flashing light identification device provided in an embodiment of the present invention. Figure 2 A flowchart illustrating the vision-adaptive gas meter flashing light recognition method provided in an embodiment of the present invention is shown. Figure 3 A schematic diagram of the ROI positioning and parameter adaptation process provided in an embodiment of the present invention is shown; Figure 4 A schematic diagram of the flashing light decision state machine provided in an embodiment of the present invention is shown; Figure 5 A schematic diagram of the data reporting and linkage timing provided in an embodiment of the present invention is shown; Figure 6 A schematic diagram of the anomaly detection and rollback process provided in an embodiment of the present invention is shown. Detailed Implementation
[0016] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0017] The core problem with existing technologies for identifying flashing lights on gas meters is the lack of a robust identification mechanism that can automatically locate, make adaptive decisions, effectively suppress jitter, and handle anomalies in dynamic and changing industrial environments.
[0018] Therefore, this invention aims to solve at least one of the following technical problems: 1) Automation and robustness of ROI positioning: How to automatically and accurately locate the flashing ROI without manual intervention, and resist changes in viewing angle, lighting, and background texture; 2) Adaptability of decision threshold: How to establish a decision model that can dynamically adapt to individual LED differences, lighting changes, and camera exposure adjustments, replacing the rigid brightness threshold; 3) Accuracy of counting results: How to design a mechanism to effectively filter out signal jitter and instantaneous noise at the edge of the on / off state switching, fundamentally eliminating "overcounting" errors; 4) Autonomy and reliability of the system: How to achieve rapid parameter initialization (convergence) after the device is powered on, and autonomous detection, parameter rollback, and alarm for abnormal operating conditions (such as ROI drift and LED adhesion) during operation, ensuring long-term operational stability; 5) Engineering integration and verifiability: How to provide standardized interfaces and timings to facilitate integration with production line control systems (such as MES), and support external verification of the timing accuracy of the device itself.
[0019] The following will combine Figures 1 to 6The specific embodiments of this invention are described in detail. First, the key terms and symbols used in this application are uniformly defined: ROI (Region of Interest): refers to the rectangular area in the image containing the LED flashing light to be identified. P(on): refers to the probability calculated by the model that the LED is in the "on" state within the current frame ROI, with a value range of [0,1]. T_on / T_off: refer to the probability thresholds used to determine whether the LED state changes from "off" to "on" (rising edge) and from "on" to "off" (falling edge), respectively, and T_on>T_off. t_min: refers to the shortest duration that a valid "on" state must last, used to filter out excessively short noise pulses. t_ref: refers to the "refractory period" during which the system does not respond to new rising edge decisions for a period of time after a valid count is completed, used to prevent duplicate counting. μ_on, σ_on / μ_off, σ_off: refer to the mean and standard deviation of the brightness characteristics of the LED in the on and off states obtained through online statistics, respectively. φ(x): refers to the multidimensional feature vector extracted from the ROI and used for probability discrimination.
[0020] First, this invention provides a vision-adaptive gas meter flashing light recognition device, referring to... Figure 1 The device includes: The image acquisition module 110 is used to capture real-time video data streams including the gas meter, and the data streams enter the central processing module 100 via a high-speed bus. The central processing module 100 coordinates the various modules of the gas meter flashing light identification device. The central processing module 100 is used to execute the identification operation in the gas meter flashing light identification method (i.e., the core identification algorithm in the gas meter flashing light identification method). Storage module 120 includes non-volatile memory and DDR memory 121. Temporary data required by the central processing module 100 during algorithm execution is stored in DDR memory 121. Firmware, self-learning parameter library and calibration log are permanently stored in non-volatile memory, including Flash / eMMC 122. The output and interface module includes a network module 130, a general-purpose I / O module 140, a clock output module 150, and a peripheral interface module 160. The identification results and system status are reported to the upper system via the network module 130 in HTTP or JSON format. The general-purpose I / O module 140 is linked with the production line PLC equipment in real time via DI / DO signals. To meet the strict accuracy requirements in the metrology field, the clock output module 150 provides high-precision 1PPS and 32.768kHz time and frequency signals that can be externally verified. In addition, the peripheral interface module 160 provides rich expansion capabilities for the gas meter flashing light identification device.
[0021] The aforementioned vision-adaptive gas meter flashing light recognition device is used to implement the following vision-adaptive gas meter flashing light recognition method.
[0022] like Figure 2 As shown, the vision-adaptive gas meter flashing light recognition method provided in this embodiment of the invention includes the following steps: S201. Initialization and self-test ensure the hardware system is in normal working condition.
[0023] S202. Execute image acquisition and exposure control strategies to provide image data, providing a stable and high-quality visual foundation for subsequent image analysis.
[0024] S203: Perform automatic ROI localization and stability assessment on the image data. This step frees the device from reliance on manual calibration. If the ROI is unstable, proceed to S203b to update candidate image data and continue evaluating the ROI's stability. If the ROI is stable, proceed to S203a for rapid adaptive initialization, where the device autonomously learns and establishes a decision model for the current target by analyzing the first two flashes.
[0025] S204. For each new image frame, extract features and perform probability discrimination.
[0026] S205. Filter out noise using a state machine and confirm the valid pulse count of the flashing light.
[0027] S206. Each valid count is recorded, traced, and used for online adjustment of the decision model.
[0028] S207. Output the recognition result of the number of flashing lights. The result is output through multiple interfaces to complete a complete recognition-counting-reporting cycle.
[0029] Automatic ROI localization includes: identifying regions in an image whose brightness changes over time through temporal fluctuation analysis; maintaining an image sequence buffer of length W; calculating the inter-frame brightness variance for each pixel block in the image; generating multiple preliminary candidate ROIs by adaptive thresholding the inter-frame brightness variance heatmap; performing frequency domain energy analysis on the multiple preliminary candidate ROIs; performing Fourier transform on the brightness time series of each candidate ROI to calculate its normalized frequency band energy ratio within a preset flashing frequency band; selecting candidate ROIs using morphological prior analysis; calculating a candidate confidence score for each candidate ROI; and confirming valid ROIs based on the candidate confidence scores.
[0030] Specifically, in the ROI auto-localization phase of S203, in order to accurately "discover" the target in a complex context, the device employs a multi-evidence fusion strategy, the internal logic of which is as follows: Figure 3 As shown. First, the device uses temporal fluctuation analysis to find regions in the image whose brightness changes over time. Specifically, the device maintains an image sequence buffer of length W (e.g., 90 frames). For each pixel block P in the image, its "inter-frame luminance variance" (ILV) is calculated: ILV(P) = Var(I(P,t)), where I(P,t) is the average brightness of pixel block P at time t. A real flashing area will have an ILV value much higher than the static background. The device generates a batch of preliminary candidate ROIs by adaptively thresholding the ILV heatmap. Next, to exclude non-periodic brightness changes (such as the occasional flicker of reflective points), the device performs frequency domain energy analysis on these candidate ROIs. The brightness time series of each candidate ROI is Fourier transformed to calculate its "normalized bandgap energy ratio" (NBER) within a preset flashing frequency band (e.g., 0.1Hz-15Hz). Only candidates with an NBER value higher than a certain threshold (e.g., R>0.4) are considered reliable. Finally, the device refines the candidates using morphological prior analysis, calculating their shape parameters such as roundness and aspect ratio, and eliminating irregularly shaped interference objects. The device calculates a comprehensive "Candidate Confidence Score" (CCS) for each candidate ROI, which is a weighted sum of the scores from the three analyses mentioned above. Only a candidate with a stable spatial location across consecutive frames and a consistently high CCS is ultimately confirmed as a valid ROI.
[0031] Once the ROI is successfully locked, the device enters the rapid adaptive initialization phase S203a. This is a crucial "autonomous learning" process. During the process of autonomously learning and establishing a decision model for the current target by analyzing the first two flashes: The device waits for and fully captures the first two valid flash pulses within the ROI. By analyzing the brightness characteristic distribution during the on and off states of these two pulses, μ_on, σ_on, and μ_off, σ_off are calculated online. To ensure the reliability of the model, the device calculates a "separability index" (SI), defined as: SI = (μ_on - μ_off) / sqrt(σ_on^2 + σ_off^2). Only when SI is greater than a preset threshold (e.g., SI > 3.0), indicating sufficient distinguishability between the on and off states in the feature space, is the initialization considered successful. The statistical parameters obtained at this time are directly used in the decision model. As mentioned earlier, μ_on, σ_on, μ_off, and σ_off refer to the mean and standard deviation of the brightness characteristics of the LED in the on and off states, respectively, obtained through online statistics.
[0032] In S204, in the step of extracting features and making probability discrimination for each new image frame: for each new image frame, a multidimensional feature vector φ(x) is extracted from the ROI and input into the decision model (e.g., logistic regression), and the probability P(on) of the light-emitting diode (LED) being on in the current frame is output. The probability P(on) is used for subsequent model decisions.
[0033] However, the original P(on) sequence may exhibit jitter at the edges of state transitions. To achieve accurate counting, the system employs a method such as... in S205. Figure 4 The finite state machine shown is used to introduce hysteresis and time-domain debouncing mechanisms. In the process of filtering noise and confirming valid counts of the flashing lights using the state machine, two different preset thresholds, T_on and T_off, are used to determine the rising and falling edges of the state, with T_on > T_off, forming a hysteresis interval for debouncing. A valid pulse is only confirmed when the lit state lasts for more than a preset minimum effective pulse width, t_min, thus filtering out instantaneous noise. After each successful count, the state machine enters a refractory period of t_ref, during which all new rising edge signals are blocked to avoid duplicate counting.
[0034] In S207, each valid count confirmed by the state machine, along with its high-precision timestamp and other metadata, is reported in HTTP / JSON format via the network interface module 130. Simultaneously, the device's operating status and potential anomalies are fed back to the production line in real time via the DO signal of the general-purpose I / O module 140. For example... Figure 5 As shown, the interaction between the entire device and the external world is clear, orderly, and real-time.
[0035] Finally, to ensure long-term operational stability, a parallel anomaly detection and rollback module continuously operates in the background, such as... Figure 6 As shown, key indicators such as the stability of ROI and the drift of brightness statistics parameters are continuously monitored. Once an anomaly is detected, online learning is immediately frozen, and measures such as parameter rollback or ROI relocation are taken according to the type of anomaly to ensure that the system can recover autonomously from the fault.
[0036] To enable those skilled in the art to implement the invention without doubt, two detailed embodiments are provided below, corresponding to a standard industrial environment and a challenging, complex environment, respectively. Example 1: Standard Automated Production Line Operating Conditions
[0037] This embodiment aims to illustrate the specific implementation process of the present invention in an ideal and typical automated verification line. This scenario is characterized by a stable environment and high consistency in the position of the tested object.
[0038] First, the scene and hardware are configured. The calibration station is set up next to a conveyor belt running at a constant speed. The gas meter is precisely fixed on a customized tray, and its positional error in the image does not exceed ±5 mm each time it arrives at the calibration station. A flicker-free LED surface light source is used above the station to provide uniform illumination of approximately 800 lux. In the device of this invention, the image acquisition module 110 uses a USB 3.0 industrial camera with a global shutter, a resolution set to 1280x720 pixels, and a constant frame rate of 60 frames / second to ensure that it can capture LED pulses as short as 20 milliseconds. The camera lens is a fixed-focus lens with a focal length of 8 mm, and the working distance is adjusted to 15 cm to obtain a clear and complete image of the gas meter dial. The central processing module 100 uses an embedded computing platform with a Loongson 2K0300 processor and runs an embedded Linux operating system. The core recognition algorithm is implemented in C++ and uses the OpenCV library for low-level image processing operations.
[0039] The operating procedures of the device strictly follow the aforementioned Figure 2 The logic is as follows. When the production line PLC sends a rising edge signal through the DI interface of the general-purpose I / O module (140), indicating that a new gas meter has arrived and is ready to begin verification, the S201 initialization process is triggered. The device loads the default configuration file matching the current gas meter model. Then, in S202, the device executes an automatic exposure program for 1.5 seconds, the goal of which is to adjust the camera's exposure time and digital gain so that the 8-bit grayscale average value of the entire image is stabilized within the range of 128±10. Once this stable state is reached, all exposure parameters are locked to avoid brightness baseline drift due to slight changes in illumination during subsequent recognition.
[0040] Next, we proceed to the crucial S203 ROI auto-location stage. The device first downsamples the original 1280x720 image to 640x360 to improve processing speed. The sliding window W for the temporal ILV analysis is set to 90 frames (corresponding to 1.5 seconds) to cover at least one complete flashing cycle. The target frequency band for the frequency domain NBER analysis is set to [0.2Hz, 10Hz], which covers the pulse frequencies of most gas meters. In the morphological prior analysis, the kernel standard deviation of the Gaussian difference operator is set to σ1=1.5, σ2=3.0 to highlight spots with diameters of approximately 5-15 pixels, while requiring the roundness of candidate regions to be greater than 0.75. The formula for calculating the Comprehensive Confidence Score (CCS) is set as follows: CCS=0.5*Score_ILV+0.3*Score_NBER+0.2*Score_Morph.
[0041] The stability voting mechanism requires that, within a continuous 30-frame evaluation period, there must be a candidate ROI whose positional drift is less than 5 pixels and whose mean CCS value is consistently greater than 0.85. Under this standard configuration, the device can typically successfully lock onto the ROI within 2 seconds.
[0042] After the ROI is locked, the S203a fast adaptive initialization process begins. The device waits for and fully captures two flash pulses. For each pulse's on and off states, the device samples 8 frames of images and calculates the mean and standard deviation of each component in the aforementioned φ(x) feature vector to obtain μ_on, σ_on, μ_off, and σ_off. Subsequently, the separability index SI is calculated, and its value must be greater than 3.5. If this requirement is not met, the device outputs an alarm signal through the DO interface and attempts to fine-tune the exposure (±1 / 8 EV) before re-executing S203a.
[0043] After successful parameter initialization, the device enters a continuous identification and counting loop S204-S205. The probabilistic decision model uses logistic regression, and its parameters have been initialized by S203a. The state machine parameters are set as follows: T_on=0.85, T_off=0.25, N_confirm=2 frames, t_min=40ms (this value is set to be slightly longer than 1.5 times the shortest pulse width in the target gas meter specification), t_ref=80ms.
[0044] During phases S206-S207, whenever the state machine is in... Figure 4 Once the Counted status confirms a valid count, the device immediately updates its internal count value and sends a JSON object containing a high-precision timestamp, pulse width, ROI coordinates, and current count value to the MES server in real time via an HTTP POST request through the network interface module 130. When the verification task is completed and the DI signal goes low, the device stops counting and saves the complete log of this verification (containing detailed metadata of all pulses) to the Flash / eMMC 122 for traceability. Example 2: High reflectivity and complex background conditions
[0045] This embodiment aims to demonstrate the implementation of the invention in a challenging industrial environment characterized by dynamically changing specular reflections caused by a glossy shell and fixed background distractions.
[0046] First, the scene and hardware are configured. The calibration station is a semi-automatic workbench where the operator manually places the gas meter. The gas meter's casing is made of high-gloss plastic, and under the illumination of the station's overhead light, it produces specular reflections on its surface that constantly change in brightness, size, and position with the operator's slight movements and breathing. Simultaneously, there are constantly lit power indicator lights from other devices and edge reflections from the metal bracket in the background. The hardware configuration is basically the same as in Example 1, but to physically suppress the main specular reflections, a high-quality linear polarizing filter is additionally installed in front of the camera lens. Before the software is started, the operator needs to manually rotate the polarizing filter to an angle that minimizes the main reflected light, based on the real-time preview image.
[0047] The operating procedure of the device also follows Figure 2 While it follows the logic, its internal algorithm parameters and coping strategies have been specially adjusted for this complex scenario.
[0048] During the S201-S202 phase, after the device starts up, it loads a set of parameter configuration files specifically for "high reflectivity" scenes. In addition to locking the exposure value, the exposure strategy also enables the "highlight suppression" or "digital wide dynamic range" function built into the camera firmware to avoid large-area overexposure caused by reflected light spots, thereby preserving details in other areas of the image.
[0049] In the S203 ROI auto-location phase, the core challenge is distinguishing between a real, fixed-position LED flash and a specular reflection point that may be similar in brightness and size but whose position and intensity dynamically change. The solution presented in this invention is multi-layered. First, the formula for calculating the Comprehensive Confidence Score (CCS) is adjusted to: CCS=0.3*Score_ILV+0.4*Score_NBER+0.3*Score_Morph.
[0050] The aim of this adjustment is to reduce reliance on simple brightness variation (ILV) while increasing consideration of periodicity (NBER) and shape stability (Morph).
[0051] During the algorithm's internal processing, the following decision-making process can be observed: In the initial few seconds of the verification, a bright reflective spot appears on the gas meter casing due to a slight movement by the operator. At this time, the device's internal candidate ROI list may simultaneously contain two high-scoring items: C1 (representing the actual LED) and C2 (representing the reflective spot). In the subsequent stability voting phase (in this scenario, the evaluation window N_stable is extended to 45 frames), the device continuously tracks and evaluates these two candidates. The algorithm finds that the position coordinates of candidate C1 remain almost unchanged (drift < 2 pixels) over 45 consecutive frames, and its brightness changes exhibit obvious periodicity, thus its NBER score remains stable at around 0.8. However, the position of candidate C2 drifts by more than 15 pixels within 45 frames, and its brightness changes are random and non-periodic, causing its NBER score to consistently fall below 0.2. Therefore, although C2 may have a high ILV score in some frames, its Overall Confidence Score (CCS) will rapidly decrease due to its unstable position and extremely low NBER score. Ultimately, after the 45-frame evaluation window ended, C2 was pruned from the candidate list by the algorithm because it did not meet the stability requirements, and only C1 was retained and finally confirmed as a valid ROI.
[0052] In the S203a stage, due to the robustness of the ROI localization in the early stage, the bright and extinguished state samples collected in this step are very pure, and the SI index can usually easily exceed 3.5.
[0053] In phases S204-S205, to further suppress any transient noise pulses caused by residual reflected light that might penetrate the ROI positioning phase, the state machine parameters are set more conservatively: T_on=0.90, T_off=0.30, N_confirm=3 frames, t_min=50ms, t_ref=100ms. This set of stricter parameters aims to build a higher "trigger barrier," ensuring that only very clear signals with a sufficiently long duration can be recognized as valid pulses.
[0054] In stages S206-S207, the process is the same as in Example 1, but an additional field is added to the reported JSON object to identify the current parameter configuration as "high reflectivity mode," facilitating subsequent data analysis and offline algorithm optimization. Through this combination of hardware and software, the present invention can achieve stable and reliable flash light recognition and counting in such challenging environments.
[0055] In summary, this invention, through multi-evidence fusion-based ROI positioning, probabilistic decision-making, and a sophisticated hysteresis and time-domain stabilization state machine, significantly improves counting accuracy in complex industrial environments by controlling both missed and overcount rates to extremely low levels (e.g., <0.1%) compared to traditional methods. The "two-flash" rapid initialization mechanism allows the system to quickly enter a stable working state after power-on or replacement of the measured object, greatly reducing manual configuration and debugging time. Online learning and anomaly rollback closed-loop ensure that the device can autonomously adapt to slow environmental changes and recover from anomalies, achieving true unattended operation. Detailed calibration logs record all metadata for each count, providing a solid basis for quality analysis and problem troubleshooting. The output of standard time and frequency signals such as 1PPS and 32.768kHz allows the device's timing accuracy to be verified by authoritative institutions, meeting the stringent traceability requirements of the metrology field. Standardized hardware interfaces (Ethernet, DI / DO, USB, RS232) and software protocols (HTTP / JSON) enable this device to be easily embedded into existing automated production lines and seamlessly integrated with PLC, MES and other systems, reducing the complexity and cost of engineering implementation.
[0056] The above embodiments are only for illustrating the technical concept and features of the present invention, and are intended to enable those skilled in the art to understand the content of the present invention and implement it. They should not be used to limit the scope of protection of the present invention. All equivalent changes or modifications made in accordance with the spirit and essence of the present invention should be covered within the scope of protection of the present invention.
Claims
1. A method for identifying the flashing light of a gas meter based on visual adaptation, characterized in that, The method includes: Initialization and self-test; Execute image acquisition and exposure control strategies to provide image data; Automatic ROI localization and stability evaluation are performed on the image data. If the ROI is unstable, the candidate image data is updated and the ROI stability is evaluated again. If the ROI is stable, the fast adaptive initialization is entered. By analyzing the first two flashes, the system learns autonomously and establishes a decision model for the current target. For each new image frame, features are extracted and probability discrimination is performed; Noise is filtered out using a state machine, and the valid count of the flashing lights is confirmed. Each valid count is recorded, traced, and used for online adjustment of the decision model; Output the recognition result of the number of flashing lights.
2. The method for identifying flashing lights of a gas meter based on visual adaptation according to claim 1, characterized in that, The automatic ROI location includes: By analyzing temporal fluctuations, regions in the image whose brightness changes over time are identified. By maintaining an image sequence buffer of length W, the inter-frame brightness variance of each pixel block in the image is calculated. Multiple preliminary candidate ROIs are generated by adaptive thresholding of the inter-frame brightness variance heatmap. Frequency domain energy analysis is performed on the multiple preliminary candidate ROIs. Fourier transform is performed on the brightness time series of each candidate ROI to calculate its normalized frequency band energy ratio within the preset flashing frequency band. Candidate ROIs are selected using morphological prior analysis, a candidate confidence score is calculated for each candidate ROI, and the effective ROI is confirmed based on the candidate confidence score.
3. The vision-adaptive gas meter flashing light recognition method according to claim 2, characterized in that, In the process of autonomously learning and establishing a decision model for the current target by analyzing the first two flashes: waiting for and fully capturing the first two valid flash pulses within the ROI, analyzing the brightness characteristic distribution during the on and off states of these two pulses, calculating μ_on, σ_on, μ_off, and σ_off online, and calculating the separability index SI, which is defined as SI=(μ_on-μ_off) / sqrt(σ_on^2+σ_off^2). Only when SI is greater than a preset threshold will the obtained statistical parameters be directly used in the decision model. μ_on, σ_on, μ_off, and σ_off refer to the mean and standard deviation of the brightness characteristics of the light-emitting diode in the on and off states obtained through online statistics, respectively.
4. The vision-adaptive gas meter flashing light recognition method according to claim 3, characterized in that, In the process of extracting features and making probability judgments for each new image frame: for each new image frame, a multidimensional feature vector φ(x) is extracted from the ROI and input into the decision model, and the probability P(on) of the LED being on in the current frame is output. The probability P(on) is used for subsequent model decisions.
5. The vision-adaptive gas meter flashing light recognition method according to claim 3, characterized in that, In the process of filtering noise and confirming the valid count of the flashing light through the state machine, two different preset thresholds T_on and T_off are used to determine the rising and falling edges of the state. T_on>T_off forms a hysteresis interval for de-jittering. The flashing light is only confirmed as a valid pulse when the bright state lasts for more than the preset minimum effective pulse width t_min, thereby filtering out instantaneous noise. After each successful count, the state machine enters a refractory period of t_ref, during which all new rising edge signals are blocked to avoid repeated counting.
6. The method for identifying flashing lights of a gas meter based on visual adaptation according to claim 1, characterized in that, The method also includes: continuously monitoring the stability of the ROI and the drift of the brightness statistics parameters; once an anomaly is detected, immediately freezing online learning; and taking measures such as parameter rollback or ROI relocation according to the type of anomaly.
7. A vision-adaptive gas meter flashing light recognition device, characterized in that, The apparatus is used to implement the vision-adaptive gas meter flashing light recognition method according to any one of claims 1 to 6, the apparatus comprising: The image acquisition module is used to capture real-time video data streams including the gas meter, and the data streams enter the central processing module via a high-speed bus. The central processing module is used to perform the identification operation in the gas meter flashing light identification method; The storage module includes non-volatile memory and DDR memory. Temporary data required by the central processing module during operation is stored in DDR memory, while firmware, self-learning parameter library and calibration log are permanently stored in non-volatile memory. The output and interface module includes a network module, a general-purpose I / O module, a clock output module, and a peripheral interface module. The identification results and system status are reported to the host system via the network module in HTTP or JSON format. The general-purpose I / O module is linked with the PLC device in real time via DI / DO signals. The clock output module provides 1PPS and 32.768kHz time and frequency signals that can be externally verified. The peripheral interface module provides expansion capabilities for the gas meter flashing light identification device.
