A ranging data processing method and device, electronic equipment and storage medium

CN122883149APending Publication Date: 2026-10-09XINGGANWEI (NANJING) TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611288628.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-24
Publication Date
2026-10-09

AI Technical Summary

Technical Problem

但在实际应用场景中,如环境光干扰、被测物体表面反射不均匀、设备轻微震动、电路噪声等,输出的测距数据往往存在抖动、波动,甚至出现异常跳变值,导致测距结果不稳定,影响后续数据处理和用户体验

Benefits of technology

本申请方法包括对测距传感器采集当前帧的原始测距数据进行无效值过滤;对通过无效值过滤的有效测距数据进行多维度异常值剔除,得到待滤波数据;其中,所述多维度至少包括基于置信度与自适应阈值的判定、基于数据分布的校验;将所述待滤波数据存入数据缓存数组,经缓存容错校验后,基于历史场景识别结果更新当前的滤波参数,并依据更新后的滤波参数以及所述数据缓存数组中数据的分布特征选择对应的滤波策略,对所述数据缓存数组中的有效数据进行滤波处理,得到当前帧的平滑测距值;当满足预设补全条件时,根据历史平滑值或历史平滑值的变化趋势生成目标测距数据;否则,将所述当前帧的平滑测距值作为目标测距数据;将所述目标测距数据发送至上位机。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122883149A_ABST
    Figure CN122883149A_ABST
Patent Text Reader

Abstract

The application provides a ranging data processing method and device, electronic equipment and storage medium. The method comprises: filtering invalid values from original ranging data; removing multi-dimensional outliers from the valid ranging data; storing the obtained to-be-filtered data in a cache array; updating filtering parameters based on historical scene recognition results after cache fault tolerance verification; selecting a filtering strategy based on data distribution characteristics to perform filtering processing to obtain smooth ranging values; generating target ranging data according to historical smooth values or their change trends when the completion condition is met, otherwise, taking the smooth ranging values as the target ranging data and outputting. The application can effectively suppress ranging data jitter and outlier interference, balance smoothness and response speed, and ensure continuous and stable data output in extreme scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of distance measurement data processing technology, and more specifically, to a method, apparatus, electronic device, and storage medium for distance measurement data processing. Background Technology

[0002] When a dToF (direct Time of Flight) ranging system is working, it collects photon signals and calculates the time of flight using a dToF chip, then outputs distance data. However, in real-world applications, factors such as ambient light interference, uneven reflection from the surface of the object being measured, slight equipment vibration, and circuit noise can cause the output ranging data to fluctuate, become jittery, or even exhibit abnormal jumps, leading to unstable ranging results that affect subsequent data processing and user experience.

[0003] Currently, existing technologies mainly address the jitter and anomaly issues in dToF ranging data, often employing a single filtering algorithm combined with a fixed threshold for outlier screening. This approach has several significant drawbacks: First, outlier handling and filtering are disconnected; relying solely on a fixed threshold for outlier screening fails to adapt to varying ranging distances, leading to misjudgments at close range and missed detections at long range. Second, the filtering effect is limited; a single filtering algorithm cannot simultaneously address both sudden outlier interference and continuous small-amplitude jitter. Over-filtering results in response delays, while insufficient filtering leads to poor anti-shake performance. Third, there is a lack of fault tolerance and completion mechanisms; the filtering algorithm fails when sufficient effective data is available, and data output interruptions are likely to occur in extreme scenarios. Fourth, scene adaptability is poor; fixed parameters cannot be adaptively adjusted based on static or dynamic ranging scenarios. Summary of the Invention

[0004] In view of this, the purpose of this application is to provide a method, apparatus, electronic device and storage medium for ranging data processing to overcome the problems in the prior art.

[0005] In a first aspect, embodiments of this application provide a method for processing ranging data, applied to a processing unit, the method comprising: Filter out invalid values ​​from the raw ranging data of the current frame acquired by the ranging sensor; The valid ranging data filtered by invalid values ​​is subjected to multi-dimensional outlier removal to obtain the data to be filtered; wherein, the multi-dimensional removal includes at least a judgment based on confidence and adaptive threshold, and a verification based on data distribution. The data to be filtered is stored in a data cache array. After cache fault tolerance verification, the current filtering parameters are updated based on the historical scene recognition results. The corresponding filtering strategy is selected according to the updated filtering parameters and the distribution characteristics of the data in the data cache array. The effective data in the data cache array is filtered to obtain the smooth ranging value of the current frame. When the preset completion conditions are met, target ranging data is generated based on historical smoothing values ​​or the changing trend of historical smoothing values; otherwise, the smoothed ranging value of the current frame is used as the target ranging data; the target ranging data is sent to the host computer.

[0006] In some technical solutions of this application, the above-mentioned determination based on confidence level and adaptive threshold includes: When the current frame is not the first frame, obtain the ranging confidence level corresponding to the valid ranging data; The adaptive outlier determination threshold is calculated based on the reference distance determined by historical smoothing values ​​and the preset base ratio. The effective ranging data are determined based on the ranging confidence level and the adaptive outlier determination threshold.

[0007] In some technical solutions of this application, the above-mentioned data distribution-based verification includes: When the current frame is not the first frame, calculate the mean and variance of the historical valid data in the data cache array; If the deviation between the effective ranging data and the mean exceeds the variance by a preset multiple, the effective ranging data is marked as suspicious data and the suspicious count is accumulated. When the number of suspicious cases reaches a preset number, the valid ranging data is restored to valid data and used as the data to be filtered.

[0008] In some technical solutions of this application, the aforementioned historical scene recognition results are obtained through the following methods: If the current frame is the first frame, the scene corresponding to the preset initial scene parameter group is used as the historical scene recognition result; If the current frame is not the first frame, the difference between adjacent frames of the smoothed ranging values ​​of multiple consecutive frames is counted. Based on the difference between adjacent frames, the current ranging scene is identified as a static scene, a weakly dynamic scene, or a strongly dynamic scene. The identification result is used as the historical scene identification result. Among the preset scene parameter groups corresponding to different ranging scenes, at least one of the following is different: the moving average window length, the median filter window length, the outlier determination base ratio, and the dynamic weight coefficient.

[0009] In some technical solutions of this application, the filtering strategy is selected in the following manner: Calculate the variance of the valid data in the data cache array; When the variance is greater than a preset variance threshold, a combination strategy of median filtering and moving average filtering is selected. When the variance is less than or equal to the preset variance threshold, the strategy of only moving average filtering is selected.

[0010] In some technical solutions of this application, after obtaining the smoothed ranging value of the current frame, the method further includes: Calculate the difference between the smoothed ranging value of the current frame and the reference distance used for outlier detection; When the difference exceeds a preset threshold, the reference distance is updated using a weighted gradual change method. When the difference does not exceed the preset threshold, the smoothed ranging value of the current frame is directly used as the updated reference distance; wherein, the updated reference distance is used for the determination based on confidence and adaptive threshold in subsequent frames.

[0011] In some technical solutions of this application, the above-mentioned conditions for satisfying preset completion include: The number of outlier removals is counted, and when the number of outlier removals reaches a preset completion trigger threshold, it is determined that the preset completion condition is met. The process of generating target ranging data based on the changing trend of historical smoothing values ​​includes: When the change in the historical smoothed value is less than the preset magnitude threshold, the most recent historical smoothed value is used as the supplementary data; when the change in the historical smoothed value is greater than or equal to the preset magnitude threshold, supplementary data is generated according to the change trend prediction.

[0012] Secondly, embodiments of this application provide a ranging data processing apparatus residing in a processing unit, the apparatus comprising: The acquisition and filtering module is used to filter invalid values ​​from the raw ranging data of the current frame acquired by the ranging sensor; The outlier removal module is used to remove outliers from valid ranging data that has passed the invalid value filtering through multiple dimensions, so as to obtain the data to be filtered; wherein, the multiple dimensions include at least the determination based on confidence and adaptive threshold, and the verification based on data distribution; The filtering module is used to store the data to be filtered into a data cache array. After cache fault tolerance verification, it updates the current filtering parameters based on the historical scene recognition results, and selects the corresponding filtering strategy according to the updated filtering parameters and the distribution characteristics of the data in the data cache array. It then filters the effective data in the data cache array to obtain the smooth ranging value of the current frame. The output module is used to generate target ranging data based on historical smoothing values ​​or the changing trend of historical smoothing values ​​when the preset completion conditions are met; otherwise, the smoothed ranging value of the current frame is used as the target ranging data and the target ranging data is sent to the host computer.

[0013] Thirdly, embodiments of this application provide an electronic device, a processor, a memory, and a bus. The memory stores machine instructions executed by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine instructions are executed by the processor, the steps of the above-described ranging data processing method are performed.

[0014] Fourthly, embodiments of this application provide a computer storage medium storing a computer program, which, when run by a processor, executes the steps of the above-described ranging data processing method.

[0015] The technical solutions provided by the embodiments of this application may include the following beneficial effects: The method of this application includes filtering invalid values ​​from the raw ranging data of the current frame acquired by the ranging sensor; removing outliers from the valid ranging data that has passed the invalid value filtering through multiple dimensions to obtain data to be filtered; wherein, the multiple dimensions include at least a judgment based on confidence and an adaptive threshold, and a verification based on data distribution; storing the data to be filtered in a data cache array, updating the current filtering parameters based on historical scene recognition results after cache fault tolerance verification, and selecting a corresponding filtering strategy based on the updated filtering parameters and the distribution characteristics of the data in the data cache array to filter the valid data in the data cache array to obtain the smoothed ranging value of the current frame; when a preset completion condition is met, generating target ranging data based on historical smoothed values ​​or the changing trend of historical smoothed values; otherwise, using the smoothed ranging value of the current frame as the target ranging data; and sending the target ranging data to a host computer.

[0016] This application effectively identifies and removes various abrupt changes in data by filtering invalid values ​​from the original ranging data and employing multi-dimensional outlier removal methods, including judgment based on confidence level and adaptive threshold, and verification based on data distribution. This reduces the false positive and false negative rates. By updating the current filtering parameters based on historical scene recognition results and selecting the corresponding filtering strategy based on the distribution characteristics of the data in the data cache array, the filtering method can be adaptively adjusted according to the ranging scene and data characteristics, balancing the smoothness and stability of ranging data in static scenes with the response speed in dynamic scenes. Through a cache fault tolerance verification mechanism and the generation of target ranging data based on historical smooth values ​​or the changing trends of historical smooth values ​​when preset completion conditions are met, the continuous and stable output of target ranging data can be ensured when there is insufficient effective data due to cache data anomalies or continuous outlier removal, avoiding data interruption and improving the robustness and reliability of the system under extreme conditions.

[0017] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0018] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 A flowchart illustrating a ranging data processing method provided in an embodiment of this application is shown; Figure 2 This illustration shows a schematic diagram of a hardware device provided in an embodiment of this application; Figure 3 A specific flowchart provided in an embodiment of this application is shown; Figure 4 A schematic diagram of a ranging data processing apparatus provided in an embodiment of this application is shown; Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.

[0021] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0022] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.

[0023] When a dToF (direct Time of Flight) ranging system is working, it collects photon signals and calculates the time of flight using a dToF chip, then outputs distance data. However, in real-world applications, factors such as ambient light interference, uneven reflection from the surface of the object being measured, slight equipment vibration, and circuit noise can cause the output ranging data to fluctuate, become jittery, or even exhibit abnormal jumps, leading to unstable ranging results that affect subsequent data processing and user experience.

[0024] Currently, existing technologies mainly address the jitter and anomaly issues in dToF ranging data, often employing a single filtering algorithm combined with a fixed threshold for outlier screening. This approach has several significant drawbacks: First, outlier handling and filtering are disconnected; relying solely on a fixed threshold for outlier screening fails to adapt to varying ranging distances, leading to misjudgments at close range and missed detections at long range. Second, the filtering effect is limited; a single filtering algorithm cannot simultaneously address both sudden outlier interference and continuous small-amplitude jitter. Over-filtering results in response delays, while insufficient filtering leads to poor anti-shake performance. Third, there is a lack of fault tolerance and completion mechanisms; the filtering algorithm fails when sufficient effective data is available, and data output interruptions are likely to occur in extreme scenarios. Fourth, scene adaptability is poor; fixed parameters cannot be adaptively adjusted based on static or dynamic ranging scenarios.

[0025] Based on this, embodiments of this application provide a method, apparatus, electronic device, and storage medium for ranging data processing, which are described below through embodiments.

[0026] Figure 1 The diagram illustrates a flowchart of a ranging data processing method provided in an embodiment of this application, wherein the method includes steps S101-S104; specifically: S101. Filter invalid values ​​from the raw ranging data of the current frame acquired by the ranging sensor; S102. Perform multi-dimensional outlier removal on the valid ranging data filtered by invalid values ​​to obtain the data to be filtered; wherein, the multi-dimensional removal includes at least a determination based on confidence level and adaptive threshold, and a verification based on data distribution. S103. Store the data to be filtered into a data cache array. After cache fault tolerance verification, update the current filtering parameters based on the historical scene recognition results. Select the corresponding filtering strategy according to the updated filtering parameters and the distribution characteristics of the data in the data cache array. Filter the effective data in the data cache array to obtain the smooth ranging value of the current frame. S104. When the preset completion conditions are met, target ranging data is generated based on historical smoothing values ​​or the changing trend of historical smoothing values; otherwise, the smoothed ranging value of the current frame is used as target ranging data; the target ranging data is sent to the host computer.

[0027] This application effectively identifies and removes various abrupt changes in data by filtering invalid values ​​from the original ranging data and employing multi-dimensional outlier removal methods, including judgment based on confidence level and adaptive threshold, and verification based on data distribution. This reduces the false positive and false negative rates. By updating the current filtering parameters based on historical scene recognition results and selecting the corresponding filtering strategy based on the distribution characteristics of the data in the data cache array, the filtering method can be adaptively adjusted according to the ranging scene and data characteristics, balancing the smoothness and stability of ranging data in static scenes with the response speed in dynamic scenes. Through a cache fault tolerance verification mechanism and the generation of target ranging data based on historical smooth values ​​or the changing trends of historical smooth values ​​when preset completion conditions are met, the continuous and stable output of target ranging data can be ensured when there is insufficient effective data due to cache data anomalies or continuous outlier removal, avoiding data interruption and improving the robustness and reliability of the system under extreme conditions.

[0028] The following describes some embodiments of this application in detail. Unless otherwise specified, the following embodiments and features can be combined with each other.

[0029] The execution system of the ranging data processing method in this application includes a processing unit, a ranging sensor, and a host computer. The processing unit is a microcontroller (MCU) with computation and control capabilities. It integrates random access memory (RAM) as the storage medium for the data cache array and implements functional modules such as invalid value filtering, multi-dimensional outlier removal, cache fault tolerance verification, filtering strategy selection and execution, scene recognition and parameter updating, and data completion determination through programming. The ranging sensor is a dToF chip used to emit light pulses, receive reflected light, and calculate and generate raw ranging data and corresponding ranging confidence levels based on photon time-of-flight. The host computer is a terminal device that receives, displays, or further processes the target ranging data, such as a PC or subsequent data processing equipment.

[0030] In terms of hardware connectivity, such as Figure 2As shown, the serial communication interface (such as I2C or SPI interface) of the processing unit is connected to the serial communication interface of the ranging sensor to read the raw ranging data and ranging confidence level from the ranging sensor. The serial communication interface (such as UART or USART interface) of the processing unit is connected to the host computer to send the final determined target ranging data to the host computer. The ranging sensor is configured to continuous ranging mode, periodically outputting raw ranging data at a preset ranging frequency (e.g., 30Hz). The processing unit synchronously triggers data acquisition through timer interrupts, reading and processing data frame by frame according to the time interval determined by the reciprocal of the ranging frequency (e.g., approximately 33.3ms), thus forming a real-time processing closed loop from raw data acquisition, multi-stage processing to target data output.

[0031] Before executing this method, the processing unit needs to be initialized. For example, after the MCU is powered on, the system clock, I2C / SPI interface, and UART / USART interface are initialized first; the ranging parameters of the dToF chip are configured, setting it to continuous ranging mode, and the ranging frequency F can be set to 30Hz, i.e., the acquisition period T=1 / F≈33.3ms. At the same time, the basic filtering parameters are set: moving average window length N=5, median filter window length M=3, outlier determination base ratio β=0.05, dynamic weight coefficient α=0.7; the outlier determination confidence threshold is set to 50%, the variance determination threshold is 2cm², the data completion trigger threshold is 5 times, and the gradual update threshold is related to the adaptive threshold K. Three sets of scenario-based parameter groups are preset: parameters corresponding to static scenarios (N=8, M=5, β=0.08, α=0.8), parameters corresponding to weak dynamic scenarios (N=5, M=3, β=0.09, α=0.7), and parameters corresponding to strong dynamic scenarios (N=3, M=3, β=0.10, α=0.6). The data cache array buf[5] is initialized with a length of 5, each element in the array is set to zero, and the cache data verification bit is configured; the reference distance D_last=0, the outlier elimination count err_cnt=0, the fluctuation statistics count wave_cnt=0, the scene flag scene=0 (where 0 represents static scenarios, 1 represents weak dynamic scenarios, and 2 represents strong dynamic scenarios), the suspicious data flag susp_flag=0, and the suspicious data counter susp_cnt=0.

[0032] After initialization, invalid values ​​are filtered from the raw ranging data acquired by the ranging sensor in the current frame. Specifically, after the processing unit (MCU) reads the raw ranging data D_raw through a serial communication interface (such as I2C or SPI), it first determines whether the data is within the preset valid range. This valid range is determined by the hardware parameters of the ranging sensor and the actual application scenario. For example, in an application with a ranging range of 0 to 500cm, if D_raw is less than 0cm or greater than 500cm, it indicates that the data exceeds the normal operating range of the sensor and is obviously invalid data caused by communication errors or extreme environmental interference. For such invalid data, the processing unit discards it directly, updates the outlier rejection count err_cnt (i.e., increments err_cnt by 1), and ends the processing flow of the current frame, returning to wait for the acquisition of the next frame of data. If D_raw is within the valid range, it is treated as valid ranging data, retained, and sent to the subsequent multi-dimensional outlier rejection stage for further verification. This basic invalid value filtering step can quickly eliminate obviously abnormal data with very low computational overhead, preventing it from interfering with subsequent processing steps.

[0033] After filtering out invalid values, multi-dimensional outlier removal is performed on the valid ranging data that passed the filtering. Different processing paths are needed depending on whether the current frame is the first frame of data collected.

[0034] If the current frame is the first frame, meaning there is no valid data in the data buffer array buf, subsequent confidence and adaptive threshold determinations and data distribution verification cannot be performed due to the lack of a reference distance as a judgment benchmark and historical data statistical features for data distribution verification. In this case, the current valid ranging data is directly used as the data to be filtered, stored in buf, and the reference distance D_last is updated.

[0035] If the current frame is not the first frame, the multi-dimensional outlier removal includes at least a judgment dimension based on confidence and adaptive threshold, and a verification dimension based on data distribution. The two dimensions are executed in sequence to identify and remove abnormal jump data from different perspectives to obtain the data to be filtered.

[0036] The determination based on confidence level and adaptive threshold is to make a preliminary judgment on the reliability of the current effective ranging data by using the confidence level parameter provided by the ranging sensor itself and the adaptive threshold dynamically calculated based on the reference distance.

[0037] Specifically, the ranging confidence level conf (with a value range of, for example, 0 to 100%) corresponding to the valid ranging data is obtained. Simultaneously, using the reference distance D_last determined based on historical smoothing values ​​as a benchmark, it is multiplied by a preset outlier determination base ratio β to calculate the adaptive outlier determination threshold K, i.e., K = D_last × β. If the ranging confidence level is lower than the preset confidence threshold (e.g., 50%), or if the absolute value of the difference between the valid ranging data and the reference distance ΔD = |D_raw - D_last| exceeds the adaptive outlier determination threshold K, then the data is determined to be an outlier, removed, and the outlier removal count err_cnt is updated. Conversely, if the confidence level is not lower than the threshold and ΔD does not exceed K, the data is retained and sent to the next dimension of the verification process.

[0038] Data distribution-based verification utilizes the statistical characteristics of existing historical valid data in the data cache array `buf` to further screen data that has passed the confidence level and threshold criteria. It requires calculating the mean and variance `var` of all historical valid data in `buf`. If the deviation of the current valid ranging data from the mean, |D_raw-mean|, exceeds a preset multiple of the variance (e.g., 2 times the variance, i.e., 2×var), it indicates that the data significantly deviates from the normal distribution. In this case, the suspicious data flag `susp_flag` is set to 1, and the suspicious count `susp_cnt` is accumulated. When the suspicious count reaches a preset number (e.g., 2 times), it indicates that the data is not an occasional jump but represents a change in the true ranging trend, and it is restored to valid data and used as data to be filtered. If the suspicious count does not reach the preset number, the data is discarded. If the deviation does not exceed a preset multiple of the variance, it is directly determined as valid data, the suspicious flag `susp_flag` and the suspicious count `susp_cnt` are cleared, and it is used as data to be filtered.

[0039] By employing the aforementioned multi-dimensional outlier removal mechanism, which integrates confidence screening, distance adaptive threshold determination, and data distribution verification, the probability of near-distance misjudgment and far-distance missed judgment can be significantly reduced. This mechanism effectively identifies and removes various abnormal jump values ​​while avoiding misinterpreting real distance changes as abnormal data.

[0040] Next, the data to be filtered, after multi-dimensional outlier removal, is stored in the data cache array buf. During storage, the array content is updated according to the first-in, first-out principle; that is, the earliest stored data set is deleted, and the current data to be filtered is stored at the end of the array, ensuring that buf always contains the most recent N valid ranging data.

[0041] After storage, the data to be filtered undergoes a buffer fault tolerance check. This check verifies the newly stored data in the current frame to ensure that no errors or abnormal transitions occurred during transmission or storage. If the check fails, the data is deemed invalid, discarded, and re-acquired. If the check passes, the data is retained as valid data in the buffer (buf) and can participate in subsequent processing. Simultaneously, the amount of valid data in the buffer is counted. If the amount of valid data is below a preset threshold (e.g., less than half the length of the moving average window), the filtering window parameters are temporarily switched to the preset minimum window parameters to ensure the filtering algorithm can still operate normally when data is insufficient. Once the amount of valid data recovers to above the threshold, the filtering window parameters are automatically switched back to the preset value corresponding to the current scene.

[0042] After cache fault tolerance verification is completed, the current filtering parameters are updated based on the historical scene recognition results. The historical scene recognition results are the ranging scene markers (scene) determined and stored at the end of the previous frame processing based on the fluctuation characteristics of the smoothed ranging values ​​of multiple consecutive frames. If the current frame is the first frame and there are no historical scene recognition results yet, the initial scene parameter set preset during initialization (e.g., the static scene parameter set) is used as the current filtering parameters. If the current frame is not the first frame, the differences between adjacent frames of the smoothed ranging value D_smooth of multiple consecutive frames are counted. Based on the difference range of the adjacent frame differences, the current ranging scene is identified as a static scene, a weakly dynamic scene, or a strongly dynamic scene, and the identification result is used as the historical scene recognition result.

[0043] Specifically, a fluctuation statistics counter wave_cnt can be set. After each frame of smooth ranging value is calculated, the difference between the current frame's smooth ranging value and the previous frame's smooth ranging value is calculated, and wave_cnt is incremented by 1. When wave_cnt reaches a preset statistical threshold (e.g., 10 frames), the difference between the most recent consecutive frames is determined: if the difference between adjacent frames in consecutive frames is within the first difference range (e.g., difference ≤ 0.5cm), it indicates that the ranging data fluctuates very little and the measured object and the sensor are in a relatively static state, then the current ranging scene is identified as a static scene, and the scene is marked scene=0; if the difference between adjacent frames in consecutive frames is within the second difference range (e.g., difference between 0.5cm and 2cm), it indicates that the ranging data fluctuates slightly and the measured object may be in a state of slight movement or environmental disturbance, then the current ranging scene is identified as a weak dynamic scene, and the scene is marked scene=1; if the difference between adjacent frames in consecutive frames is within the third difference range (e.g., difference > 2cm), it indicates that the ranging data has changed significantly and rapidly and the measured object is moving rapidly, then the current ranging scene is identified as a strong dynamic scene, and the scene is marked scene=2. After the determination is completed, wave_cnt is cleared to zero, and the updated scene value is stored as the historical scene recognition result for use in the next frame processing.

[0044] In the preset scenario parameter groups corresponding to different ranging scenarios, at least one of the following parameters differs: the moving average window length N, the median filter window length M, the outlier judgment base ratio β, and the dynamic weight coefficient α. For example, in static scenarios, a larger moving average window length (e.g., N=8) and a median filter window length (e.g., M=5), as well as a larger dynamic weight coefficient (e.g., α=0.8), can be configured to enhance the smoothing effect and make the ranging output in a stationary state more stable. In highly dynamic scenarios, a smaller moving average window length (e.g., N=3) and a median filter window length (e.g., M=3), as well as a smaller dynamic weight coefficient (e.g., α=0.6), can be configured to improve the response speed and enable the ranging output in a fast-moving state to track the real distance change in a timely manner. The parameter values ​​for weakly dynamic scenarios can be between those of static and highly dynamic scenarios (e.g., N=5, M=3, α=0.7). Through the above-mentioned scenario recognition and parameter linkage adjustment mechanism, the optimal filtering configuration can be automatically switched according to the actual ranging conditions, providing stronger data smoothing capabilities in static scenarios and faster distance change response capabilities in dynamic scenarios.

[0045] After the parameters are updated, based on the updated filtering base parameters and / or filtering window parameters, as well as the distribution characteristics of the valid data in the data buffer array, the corresponding filtering strategy is selected for filtering to obtain the smooth ranging value of the current frame.

[0046] Specifically, the variance var of the valid data in the buffer (buf) is calculated, and the fluctuation characteristics of the data are judged based on the magnitude of the variance. When var is greater than the preset variance threshold, it indicates that there are many sudden abnormal fluctuations in the data. A combination strategy of median filtering and moving average filtering is selected: first, the valid data in the buffer is sorted in ascending order, and the median value is taken to obtain the median filtering result D_med; at the same time, the arithmetic mean of all valid data in the buffer is calculated to obtain the moving average filtering result D_avg; then, the two are weighted and fused according to the dynamic weight coefficient α to obtain the smoothed ranging value of the current frame D_smooth=α×D_med+(1-α)×D_avg. When var is less than or equal to the preset variance threshold, it indicates that the data is mainly continuous small-amplitude jitter. A strategy of moving average filtering only is selected: the arithmetic mean D_avg of the valid data in the buffer is calculated, and it is also used as D_med and substituted into the above fusion formula to obtain D_smooth. By dynamically selecting filtering strategies based on data distribution characteristics, this approach can effectively suppress pulse interference when the proportion of sudden outliers is high, maintain sufficient smoothness during continuous small fluctuations, and avoid unnecessary filtering computation overhead.

[0047] After obtaining the smoothed ranging value D_smooth for the current frame, it is determined whether the preset completion condition is met. This preset completion condition is determined by counting the number of outlier removals. Specifically, when the outlier removal count err_cnt reaches the preset completion trigger threshold (e.g., 5 times), it indicates that multiple consecutive acquisitions have failed to obtain valid data, and the current ranging environment may have extreme interference such as strong light or severe occlusion. At this time, the intelligent data completion mechanism is activated.

[0048] Specifically, when the preset completion conditions are met, target ranging data is generated based on historical smoothed values ​​or the changing trends of historical smoothed values. If the change amplitude of the historical smoothed value is less than the preset amplitude threshold, i.e., it does not show a clear upward or downward trend, the most recent historical smoothed value is used as the completion data; if the change amplitude of the historical smoothed value reaches or exceeds the preset amplitude threshold, i.e., it shows a continuous directional change trend, the completion data is generated according to this change trend. For example, if the previous data showed a slow change trend of increasing by 0.5cm each time, the completion data of the current frame is generated recursively according to this trend. When the preset completion conditions are not met, i.e., err_cnt does not reach the preset completion trigger threshold, the smoothed ranging value D_smooth of the current frame is directly used as the target ranging data.

[0049] Subsequently, when the processing unit collects new valid ranging data and successfully stores it into the data cache array, it automatically exits the data completion mechanism, resumes normal filtering result output, and clears the outlier elimination count err_cnt to zero.

[0050] Finally, the processing unit sends the determined target ranging data to the host computer in a specified format via a serial communication interface (such as UART or USART) for subsequent measurement, navigation, monitoring and other applications.

[0051] In an optional implementation, after obtaining the smoothed ranging value D_smooth of the current frame, the reference distance D_last used for outlier determination is progressively updated so that the reference distance can smoothly follow the changes in the actual ranging value, avoiding sudden changes in the reference distance due to fluctuations in single-frame data, which in turn affects the stability of outlier determination in subsequent frames.

[0052] Specifically, the absolute value of the difference between the smoothed ranging value D_smooth of the current frame and the current reference distance D_last is first calculated as diff = |D_smooth - D_last|. This difference reflects the degree of deviation between the current filtering result and the previous reference.

[0053] When the difference exceeds a preset threshold, it indicates a significant change in the smoothed distance measurement value. This change may stem from the actual movement of the measured object or from occasional interference. To avoid directly using the significantly changed value as the new reference benchmark, which could lead to drastic fluctuations in subsequent judgment thresholds, a weighted gradual change method is used to update the reference distance. The specific formula is, for example: new D_last = 0.8 × old D_last + 0.2 × D_smooth, meaning 80% of the old reference information is retained, and only 20% of the new distance measurement value information is integrated. This process can be executed continuously for multiple rounds (e.g., 3 rounds) to gradually bring the reference distance closer to the new smoothed value, achieving a gradual transition.

[0054] When the difference does not exceed the preset threshold, it indicates that the difference between the smoothed ranging value and the reference distance is small, and the data changes smoothly. At this time, the smoothed ranging value D_smooth of the current frame is directly used as the updated reference distance D_last, so that the reference distance can quickly keep up with small distance changes.

[0055] The updated reference distance D_last will be stored and used in subsequent frame processing to calculate the adaptive outlier threshold K = D_last × β, supporting the judgment process based on confidence level and adaptive threshold. This gradual update mechanism effectively avoids the problem of unreliable reference standards caused by abrupt changes in a single frame or sudden changes in filtering results, further improving the stability and accuracy of the entire ranging data processing system.

[0056] In an optional implementation, when specifically implementing the method of this application, it can be done according to... Figure 3 Perform as shown.

[0057] Figure 4This invention provides a schematic diagram of a ranging data processing apparatus according to an embodiment of the present application. The apparatus includes: The acquisition and filtering module is used to filter invalid values ​​from the raw ranging data of the current frame acquired by the ranging sensor; The outlier removal module is used to remove outliers from valid ranging data that has passed the invalid value filtering through multiple dimensions, so as to obtain the data to be filtered; wherein, the multiple dimensions include at least the determination based on confidence and adaptive threshold, and the verification based on data distribution; The filtering module is used to store the data to be filtered into a data cache array. After cache fault tolerance verification, it updates the current filtering parameters based on the historical scene recognition results, and selects the corresponding filtering strategy according to the updated filtering parameters and the distribution characteristics of the data in the data cache array. It then filters the effective data in the data cache array to obtain the smooth ranging value of the current frame. The output module is used to generate target ranging data based on historical smoothing values ​​or the changing trend of historical smoothing values ​​when the preset completion conditions are met; otherwise, the smoothed ranging value of the current frame is used as the target ranging data and the target ranging data is sent to the host computer.

[0058] The determination based on confidence level and adaptive threshold includes: When the current frame is not the first frame, obtain the ranging confidence level corresponding to the valid ranging data; The adaptive outlier determination threshold is calculated based on the reference distance determined by historical smoothing values ​​and the preset base ratio. The effective ranging data are determined based on the ranging confidence level and the adaptive outlier determination threshold.

[0059] The data distribution-based verification includes: When the current frame is not the first frame, calculate the mean and variance of the historical valid data in the data cache array; If the deviation between the effective ranging data and the mean exceeds the variance by a preset multiple, the effective ranging data is marked as suspicious data and the suspicious count is accumulated. When the number of suspicious cases reaches a preset number, the valid ranging data is restored to valid data and used as the data to be filtered.

[0060] The historical scene recognition results were obtained through the following methods: If the current frame is the first frame, the scene corresponding to the preset initial scene parameter group is used as the historical scene recognition result; If the current frame is not the first frame, the difference between adjacent frames of the smoothed ranging values ​​of multiple consecutive frames is counted. Based on the difference between adjacent frames, the current ranging scene is identified as a static scene, a weakly dynamic scene, or a strongly dynamic scene. The identification result is used as the historical scene identification result. Among the preset scene parameter groups corresponding to different ranging scenes, at least one of the following is different: the moving average window length, the median filter window length, the outlier determination base ratio, and the dynamic weight coefficient.

[0061] The filtering strategy can be selected in the following ways: Calculate the variance of the valid data in the data cache array; When the variance is greater than a preset variance threshold, a combination strategy of median filtering and moving average filtering is selected. When the variance is less than or equal to the preset variance threshold, the strategy of only moving average filtering is selected.

[0062] After obtaining the smoothed ranging value of the current frame, the method further includes: Calculate the difference between the smoothed ranging value of the current frame and the reference distance used for outlier detection; When the difference exceeds a preset threshold, the reference distance is updated using a weighted gradual change method. When the difference does not exceed the preset threshold, the smoothed ranging value of the current frame is directly used as the updated reference distance; wherein, the updated reference distance is used for the determination based on confidence and adaptive threshold in subsequent frames.

[0063] The conditions for satisfying the preset completion criteria include: The number of outlier removals is counted, and when the number of outlier removals reaches a preset completion trigger threshold, it is determined that the preset completion condition is met. The process of generating target ranging data based on the changing trend of historical smoothing values ​​includes: When the change in the historical smoothed value is less than the preset magnitude threshold, the most recent historical smoothed value is used as the supplementary data; when the change in the historical smoothed value is greater than or equal to the preset magnitude threshold, supplementary data is generated according to the change trend prediction.

[0064] like Figure 5 As shown, this application provides an electronic device for executing the ranging data processing method described in this application. The device includes a memory, a processor, a bus, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the ranging data processing method described above.

[0065] Specifically, the aforementioned memory and processor can be general-purpose memory and processor, without any specific limitations. When the processor runs the computer program stored in the memory, it can execute the aforementioned method for processing ranging data.

[0066] Corresponding to the ranging data processing method in this application, this application embodiment also provides a computer storage medium storing a computer program, which is executed by a processor to perform the steps of the above-described ranging data processing method.

[0067] Specifically, the storage medium can be a general-purpose storage medium, such as a removable disk or hard disk, and when the computer program on the storage medium is run, it can execute the above-mentioned ranging data processing method.

[0068] In the embodiments provided in this application, it should be understood that the disclosed systems and methods can be implemented in other ways. The system embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and there may be other division methods in actual implementation. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the coupling or direct coupling or communication connection shown or discussed may be through some communication interface; the indirect coupling or communication connection between systems or units may be electrical, mechanical, or other forms.

[0069] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.

[0070] In addition, the functional units in the embodiments provided in this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0071] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0072] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0073] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The protection scope of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application. All should be covered within the protection scope of this application. Therefore, the protection scope of this application should be determined by the protection scope of the claims.

Claims

1. A method for processing ranging data, characterized in that, The method, applied to a processing unit, includes: Filter out invalid values ​​from the raw ranging data of the current frame acquired by the ranging sensor; The valid ranging data filtered by invalid values ​​is subjected to multi-dimensional outlier removal to obtain the data to be filtered; wherein, the multi-dimensional removal includes at least a judgment based on confidence and adaptive threshold, and a verification based on data distribution. The data to be filtered is stored in a data cache array. After cache fault tolerance verification, the current filtering parameters are updated based on the historical scene recognition results. The corresponding filtering strategy is selected according to the updated filtering parameters and the distribution characteristics of the data in the data cache array. The effective data in the data cache array is filtered to obtain the smooth ranging value of the current frame. When the preset completion conditions are met, target ranging data is generated based on historical smoothing values ​​or the changing trend of historical smoothing values; otherwise, the smoothed ranging value of the current frame is used as the target ranging data; the target ranging data is sent to the host computer.

2. The method according to claim 1, characterized in that, The determination based on confidence level and adaptive threshold includes: When the current frame is not the first frame, obtain the ranging confidence level corresponding to the valid ranging data; The adaptive outlier determination threshold is calculated based on the reference distance determined by historical smoothing values ​​and the preset base ratio. The valid ranging data are determined based on the ranging confidence level and the adaptive outlier determination threshold.

3. The method according to claim 1, characterized in that, The data distribution-based verification includes: When the current frame is not the first frame, calculate the mean and variance of the historical valid data in the data cache array; If the deviation between the effective ranging data and the mean exceeds the variance by a preset multiple, the effective ranging data is marked as suspicious data and the suspicious count is accumulated. When the number of suspicious cases reaches a preset number, the valid ranging data is restored to valid data and used as the data to be filtered.

4. The method according to claim 1, characterized in that, The historical scene recognition results are obtained through the following methods: If the current frame is the first frame, the scene corresponding to the preset initial scene parameter group is used as the historical scene recognition result; If the current frame is not the first frame, the difference between adjacent frames of the smoothed ranging values ​​of multiple consecutive frames is counted. Based on the difference between adjacent frames, the current ranging scene is identified as a static scene, a weakly dynamic scene, or a strongly dynamic scene. The identification result is used as the historical scene identification result. Among the preset scene parameter groups corresponding to different ranging scenes, at least one of the following is different: the moving average window length, the median filter window length, the outlier determination base ratio, and the dynamic weight coefficient.

5. The method according to claim 1, characterized in that, The filtering strategy can be selected in the following ways: Calculate the variance of the valid data in the data cache array; When the variance is greater than a preset variance threshold, a combination strategy of median filtering and moving average filtering is selected. When the variance is less than or equal to the preset variance threshold, the strategy of only moving average filtering is selected.

6. The method according to claim 1, characterized in that, After obtaining the smoothed ranging value of the current frame, the method further includes: Calculate the difference between the smoothed ranging value of the current frame and the reference distance used for outlier detection; When the difference exceeds a preset threshold, the reference distance is updated using a weighted gradual change method. When the difference does not exceed the preset threshold, the smoothed ranging value of the current frame is directly used as the updated reference distance; wherein, the updated reference distance is used for the determination based on confidence and adaptive threshold in subsequent frames.

7. The method according to claim 1, characterized in that, The conditions for satisfying the preset completion criteria include: The number of outlier removals is counted, and when the number of outlier removals reaches a preset completion trigger threshold, it is determined that the preset completion condition is met. The process of generating target ranging data based on the changing trend of historical smoothing values ​​includes: When the change in the historical smoothed value is less than the preset magnitude threshold, the most recent historical smoothed value is used as the supplementary data; when the change in the historical smoothed value is greater than or equal to the preset magnitude threshold, supplementary data is generated according to the change trend prediction.

8. A device for processing ranging data, characterized in that, Residing in the processing unit, the device includes: The acquisition and filtering module is used to filter invalid values ​​from the raw ranging data of the current frame acquired by the ranging sensor; The outlier removal module is used to remove outliers from valid ranging data that has passed the invalid value filtering through multiple dimensions, so as to obtain the data to be filtered; wherein, the multiple dimensions include at least the determination based on confidence and adaptive threshold, and the verification based on data distribution; The filtering module is used to store the data to be filtered into a data cache array. After cache fault tolerance verification, it updates the current filtering parameters based on the historical scene recognition results, and selects the corresponding filtering strategy according to the updated filtering parameters and the distribution characteristics of the data in the data cache array. It then filters the effective data in the data cache array to obtain the smooth ranging value of the current frame. The output module is used to generate target ranging data based on historical smoothing values ​​or the changing trend of historical smoothing values ​​when the preset completion conditions are met; otherwise, the smoothed ranging value of the current frame is used as the target ranging data and the target ranging data is sent to the host computer.

9. An electronic device, characterized in that, include: The device includes a processor, a memory, and a bus. The memory stores machine instructions that the processor executes. When the electronic device is running, the processor communicates with the memory via the bus. When the machine instructions are executed by the processor, they perform the steps of the ranging data processing method as described in any one of claims 1 to 7.

10. A computer storage medium, characterized in that, The computer storage medium stores a computer program that, when executed by a processor, performs the steps of the ranging data processing method as described in any one of claims 1 to 7.