Lens identification method and device and lens

By directly acquiring the lens focal length encoder signal and applying Hilbert transform and envelope detection technology, the time delay and external interference problems of traditional detection methods are solved, and real-time and accurate identification and control of the lens zoom state are achieved.

CN120711286AInactive Publication Date: 2025-09-26SHENZHEN YONGTAI PHOTOELECTRIC CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510917153.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-03
Publication Date
2025-09-26
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional zoom switching detection methods rely on image frame difference analysis, which has time delays and cannot meet the precise control requirements of high-speed zoom operations. In multi-stage zoom optical lens systems, it is difficult to accurately identify the mechanical switching state inside the lens and is easily interfered by external factors such as lighting changes and target object movement.

Method used

By directly collecting the A-phase and B-phase signals of the lens focal length encoder, using Hilbert transform and envelope detection technology, dynamic time warping distance calculation of the envelope first-order derivative and encoder pulse timing characteristic sequence is performed, combined with a five-state encoder recognition controller, direct detection and accurate recognition of the zoom state can be achieved.

Benefits of technology

The real-time performance of detection has been significantly improved. It can accurately distinguish between continuous zoom, step zoom and fine focus modes, accurately locate the moment of zoom state switching, eliminate the interference of lighting changes and target object movement, and adapt to signal timing changes under different zoom speeds.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120711286A_ABST
    Figure CN120711286A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of lens recognition, and discloses a lens recognition method and device and a lens, and the method comprises the steps: carrying out the signal collection of a lens focal length encoder, and obtaining a first encoder signal and a second encoder signal; envelope detection and pulse detection are carried out to obtain an envelope first-order derivative sequence and an encoder pulse time sequence characteristic sequence; performing dynamic time warping distance calculation on the encoder pulse time sequence characteristic sequence to obtain a mode classification result of the current zooming operation; state switching judgment is carried out according to the envelope first-order derivative sequence and the pattern classification result, and a zoom state switching moment mark is obtained; the phase difference track matching degree is calculated, and a zoom switching completion confirmation signal is generated according to the zoom state switching moment mark. The interference of external factors such as illumination change and target object movement is eliminated, the method can adapt to signal time sequence change at different zoom speeds, and stable detection performance is kept in a complex electromagnetic environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of lens recognition technology, and in particular to a lens recognition method, device and lens. Background Art

[0002] Traditional zoom switch detection methods rely primarily on image frame difference analysis and optical feature change detection, determining zoom state changes by comparing pixel differences or optical parameter changes between consecutive image frames. However, this image processing-based detection method suffers from significant time delays, requiring the complete acquisition and processing of image frames before making a judgment. This results in poor real-time zoom switch recognition and is unable to meet the precise control requirements of high-speed zoom operations.

[0003] Existing technologies face even more severe challenges when dealing with multi-stage zoom optical lens systems. In particular, traditional detection methods struggle to accurately identify the mechanical switching state within the lens due to the influence of encoder signal phase drift and quantization errors. Image frame difference detection is inherently an indirect detection method that cannot directly obtain mechanical motion information from the lens' internal encoder. It is susceptible to interference from external factors such as lighting changes, target object motion, and image noise, leading to frequent false detections and missed detections. Summary of the Invention

[0004] The present invention provides a lens recognition method, device, and lens. The present invention eliminates external interference caused by illumination changes and target object motion, can adapt to signal timing changes at different zoom speeds, and maintain stable detection performance in complex electromagnetic environments.

[0005] A first aspect of the present invention provides a lens recognition method, the lens recognition method comprising:

[0006] Acquire signals from a lens focal length encoder to obtain a first encoder signal and a second encoder signal;

[0007] Performing envelope detection and pulse detection on the first encoder signal and the second encoder signal to obtain an envelope first-order derivative sequence and an encoder pulse timing characteristic sequence;

[0008] Performing dynamic time warping distance calculation on the encoder pulse timing feature sequence to obtain a mode classification result of the current zoom operation;

[0009] Performing state switching determination based on the envelope first-order derivative sequence and the pattern classification result to obtain a zoom state switching moment mark;

[0010] The phase difference track matching degree is calculated and a zoom switching completion confirmation signal is generated according to the zoom state switching moment mark.

[0011] In combination with the first aspect, in a first implementation of the first aspect of the present invention, acquiring signals from a lens focal length encoder to obtain a first encoder signal and a second encoder signal includes:

[0012] The A-phase TTL level signal and the B-phase TTL level signal output by the lens focal length encoder are synchronously sampled and analog-to-digital converted to obtain the A-phase encoder signal and the B-phase encoder signal;

[0013] Inputting the A-phase encoder signal and the B-phase encoder signal into a 4th-order Butterworth low-pass filter for filtering, respectively, to obtain a filtered A-phase encoder signal and a filtered B-phase encoder signal;

[0014] The filtered A-phase encoder signal is standardized to obtain a first encoder signal, and the filtered B-phase encoder signal is standardized to obtain a second encoder signal.

[0015] In combination with the first aspect, in a second implementation of the first aspect of the present invention, performing envelope detection and pulse detection on the first encoder signal and the second encoder signal to obtain an envelope first-order derivative sequence and an encoder pulse timing feature sequence includes:

[0016] Performing Hilbert transform calculations on the first encoder signal and the second encoder signal respectively to obtain a first Hilbert transform result and a second Hilbert transform result;

[0017] constructing a first analytical signal based on the first encoder signal and the first Hilbert transform result, and constructing a second analytical signal based on the second encoder signal and the second Hilbert transform result;

[0018] Performing modulus calculation on the first analytical signal and the second analytical signal respectively to obtain a first encoder instantaneous envelope and a second encoder instantaneous envelope;

[0019] Performing amplitude-weighted fusion on the instantaneous envelope of the first encoder and the instantaneous envelope of the second encoder to obtain an encoder signal envelope, and performing a time-domain differential operation on the encoder signal envelope to obtain an envelope first-order derivative sequence;

[0020] Focus step pulse edge detection and pulse duration extraction are performed based on the encoder signal envelope to obtain an encoder pulse timing feature sequence.

[0021] In combination with the first aspect, in a third implementation of the first aspect of the present invention, performing focus step pulse edge detection and pulse duration extraction based on the encoder signal envelope to obtain an encoder pulse timing feature sequence includes:

[0022] Performing baseline mean calculation and noise variance analysis on the encoder signal envelope to obtain an envelope baseline reference value, and setting a pulse start detection threshold and a pulse stop detection threshold based on the envelope baseline reference value;

[0023] Performing rising edge detection on the encoder signal envelope based on the pulse start detection threshold, marking the pulse start time when the envelope amplitude rises and exceeds the pulse start detection threshold, and obtaining a pulse start time sequence;

[0024] Performing falling edge detection on the encoder signal envelope based on the pulse stop detection threshold, marking the pulse end time when the envelope amplitude drops below the pulse stop detection threshold, and obtaining a pulse end time sequence;

[0025] A time difference is calculated based on the pulse start time sequence and the pulse end time sequence to obtain a duration value of each pulse, and an encoder pulse timing feature sequence is generated based on the duration value of each pulse.

[0026] In combination with the first aspect, in a fourth implementation of the first aspect of the present invention, performing dynamic time warping distance calculation on the encoder pulse timing feature sequence to obtain a mode classification result of the current zoom operation includes:

[0027] Extracting the continuous zoom pulse timing template, the step zoom pulse timing template, and the fine focus pulse timing template from the preset zoom mode library, respectively, to obtain the pulse duration reference sequences of the three standard zoom modes;

[0028] Performing dynamic time warping path search and Euclidean distance accumulation calculation on the encoder pulse timing feature sequence and the pulse duration reference sequences of the three standard zoom modes, respectively, to obtain a first cumulative distance value corresponding to the continuous zoom mode, a second cumulative distance value corresponding to the step zoom mode, and a third cumulative distance value corresponding to the fine focus mode;

[0029] performing a minimum comparison on the first cumulative distance value, the second cumulative distance value, and the third cumulative distance value, selecting the zoom mode with the smallest cumulative distance value as the initial classification result, and calculating a ratio of the smallest cumulative distance value to the second smallest cumulative distance value to obtain a pattern recognition confidence coefficient;

[0030] A threshold determination is performed based on the pattern recognition confidence coefficient, and when the pattern recognition confidence coefficient is less than a preset confidence threshold, the initial classification result is confirmed to be a valid classification, thereby obtaining a pattern classification result of the current zoom operation.

[0031] In combination with the first aspect, in a fifth implementation of the first aspect of the present invention, performing state switching determination based on the envelope first-order derivative sequence and the pattern classification result to obtain the zoom state switching moment mark includes:

[0032] Performing continuous pulse interval calculation and second-order difference operation on the envelope first-order derivative sequence to obtain an encoder pulse interval sequence and a corresponding second-order difference change rate sequence;

[0033] Selecting corresponding zoom type threshold parameters from a preset parameter library according to the pattern classification result, setting an acceleration determination threshold, a constant speed determination threshold, and a deceleration determination threshold respectively, to obtain a state switching threshold combination for the current zoom operation;

[0034] The second-order difference change rate sequence is combined with the state switching threshold for point-by-point comparison and state transition logic determination. When the second-order difference change rate is greater than the acceleration determination threshold, it is determined to be an accelerated zoom state; when the second-order difference change rate is within the constant speed determination threshold, it is determined to be a constant speed zoom state; when the second-order difference change rate is less than the deceleration determination threshold, it is determined to be a deceleration stop state, thereby obtaining a zoom state sequence;

[0035] The zoom state sequence is subjected to state jump detection and moment marking. When a jump from the static state to the pre-zoom state, a jump from the pre-zoom state to the accelerated zoom state, a jump from the accelerated zoom state to the constant-speed zoom state, a jump from the constant-speed zoom state to the decelerated stop state, and a jump from the decelerated stop state to the static state is detected, the corresponding timestamps are recorded to obtain a zoom state switching moment mark.

[0036] In combination with the first aspect, in a sixth implementation of the first aspect of the present invention, performing continuous pulse interval calculation and second-order difference operation on the envelope first-order derivative sequence to obtain an encoder pulse interval sequence and a corresponding second-order difference change rate sequence includes:

[0037] Performing extreme value detection and peak screening on the first-order derivative sequence of the envelope, marking the moment when the amplitude change rate of the first-order derivative of the envelope exceeds a preset fluctuation threshold as a pulse peak moment, and obtaining a pulse peak moment sequence;

[0038] According to the pulse peak time sequence, subtract the i-th pulse peak time from the i+1-th pulse peak time to obtain the i-th pulse interval value, and sequentially calculate the difference between all adjacent pulse peak times based on the pulse interval value to obtain the encoder pulse interval sequence;

[0039] According to the encoder pulse interval sequence, the difference between adjacent pulse intervals is calculated to obtain a first-order difference sequence, and then the difference between adjacent elements of the first-order difference sequence is calculated to obtain a second-order difference sequence;

[0040] An element-by-element division operation is performed on the second-order difference sequence and the encoder pulse interval sequence to obtain a second-order difference change rate sequence.

[0041] In combination with the first aspect, in a seventh implementation of the first aspect of the present invention, calculating the phase difference trajectory matching degree and generating a zoom switching completion confirmation signal according to the zoom state switching moment mark includes:

[0042] Performing a time domain sliding window cross-correlation calculation on the first encoder signal and the second encoder signal to obtain a cross-correlation calculation result;

[0043] Performing peak detection and time delay positioning based on the cross-correlation operation result to obtain a real-time phase difference sequence, and performing time sequence arrangement and trajectory reconstruction on the real-time phase difference sequence to obtain an encoder phase difference trajectory;

[0044] The encoder phase difference trajectory is subjected to curve fitting and similarity calculation with the pre-stored continuous zoom phase standard trajectory, step zoom phase standard trajectory and fine focus phase standard trajectory respectively, to obtain the trajectory fitting coefficients corresponding to the three modes, and the maximum value of the trajectory fitting coefficient is selected as the phase difference trajectory matching degree;

[0045] The state jump from the deceleration stop state to the static state is monitored according to the zoom state switching moment mark, and when the state jump is detected to occur and the phase difference trajectory matching degree is greater than a preset matching threshold, a zoom switching completion confirmation signal is generated.

[0046] A second aspect of the present invention provides a lens recognition device, the lens recognition device comprising:

[0047] A signal acquisition module is used to acquire signals from a lens focal length encoder to obtain a first encoder signal and a second encoder signal;

[0048] a detection module, configured to perform envelope detection and pulse detection on the first encoder signal and the second encoder signal to obtain an envelope first-order derivative sequence and an encoder pulse timing characteristic sequence;

[0049] a calculation module, configured to perform dynamic time warping distance calculation on the encoder pulse timing feature sequence to obtain a mode classification result of the current zoom operation;

[0050] a determination module, configured to perform state switching determination based on the envelope first-order derivative sequence and the pattern classification result, and obtain a zoom state switching moment mark;

[0051] A generation module is used to calculate the phase difference trajectory matching degree and generate a zoom switching completion confirmation signal according to the zoom state switching moment mark.

[0052] A third aspect of the present invention provides a lens, which executes the above-mentioned lens recognition method.

[0053] Compared with the existing technology, the present invention has the following beneficial effects: by directly collecting and processing the A-phase and B-phase signals of the lens focal length encoder, it bypasses the indirectness problem of traditional image frame difference detection, directly obtains the zoom state information from the mechanical level inside the lens, and eliminates the interference of external factors such as illumination changes and target object movement. The Hilbert transform envelope detection technology is used to shorten the detection response time from the frame-level delay to the millisecond level, significantly improving the real-time performance. Through dynamic time warping distance calculation and five-state encoder identification controller, it can accurately distinguish between the three modes of continuous zoom, step zoom and fine focus, and accurately locate the switching moments of static state, pre-zoom state, accelerated zoom state, constant speed zoom state and deceleration stop state. The dual-channel cross-validation mechanism uses the phase correlation analysis of the first encoder signal and the second encoder signal to effectively eliminate false detections caused by electromagnetic interference and mechanical jitter. The adaptive characteristics of the dynamic time warping algorithm can adapt to the signal timing changes at different zoom speeds and maintain stable detection performance in complex electromagnetic environments. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0055] The structures, proportions, sizes, etc. depicted in the drawings of this specification are only used to match the contents disclosed in the specification so as to facilitate understanding and reading by persons familiar with this technology. They are not intended to limit the conditions under which the present invention can be implemented and therefore have no substantive technical significance. Any structural modifications, changes in proportional relationships, or adjustments in size should still fall within the scope of the technical contents disclosed in the present invention without affecting the effects and objectives that can be achieved by the present invention.

[0056] Figure 1 1 is a flow chart of a lens identification method provided by an embodiment of the present invention;

[0057] Figure 2 This is a schematic block diagram of the structure of a lens recognition device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0058] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0059] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, combined, or partially merged, so the actual execution order may vary depending on the actual situation.

[0060] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the present invention. As used in the specification and appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms unless the context clearly indicates otherwise.

[0061] It should be further understood that the term "and / or" used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations. Figure 1 An embodiment of a lens recognition method in an embodiment of the present invention includes:

[0062] Step 100: Collect signals from a lens focal length encoder to obtain a first encoder signal and a second encoder signal;

[0063] It is understandable that the execution subject of the present invention may be a lens recognition device, or a terminal or a server, which is not limited here. The embodiment of the present invention is described by taking the server as the execution subject as an example.

[0064] Specifically, the lens focal length encoder outputs dual-channel TTL-level signals for phases A and B. These two signals represent the rotation direction and incremental displacement information, respectively, with a 90° phase difference. Therefore, they are sampled simultaneously to ensure accurate zoom direction identification. To achieve high-timing signal acquisition, the system uses a synchronous sampling mechanism, configuring dual high-speed acquisition channels within the controller and setting the sampling frequency to 100kHz to ensure that the encoder pulses under rapid zoom action can be fully recorded. After completing synchronous sampling, the acquired phase A TTL-level signal and phase B TTL-level signal are respectively input into a 12-bit analog-to-digital converter. Through the analog-to-digital conversion process, the analog voltage value (in the range of 0 to 5V) is mapped into a discrete digital sequence (in the range of 0 to 4095), obtaining the initial digital form of the phase A encoder signal and the phase B encoder signal. Due to the presence of high-frequency noise interference in actual application environments, such as motor electromagnetic radiation, line parasitic oscillations, or system jitter signals, the initial digital signal is filtered to improve the signal-to-noise ratio. The Phase A and Phase B encoder signals are each fed into a fourth-order Butterworth low-pass filter. This filter offers unity gain, a maximally flat amplitude-frequency response, and good roll-off characteristics, balancing signal edge preservation with high-frequency interference suppression. The filter cutoff frequency is set to 50 kHz, effectively suppressing noise components with frequencies above this frequency without compromising the primary signal content. The filtering process outputs the processed Phase A and Phase B encoder signals, which exhibit enhanced waveform stability and continuity. To eliminate amplitude variations between encoder output levels, the filtered encoder signals are normalized, mapping the original signal amplitudes to a standard interval of [-1, 1]. After this normalization process, the filtered Phase A encoder signal is converted into the first encoder signal, while the filtered Phase B encoder signal is converted into the second encoder signal.

[0065] Step 200: Perform envelope detection and pulse detection on the first encoder signal and the second encoder signal to obtain an envelope first-order derivative sequence and an encoder pulse timing characteristic sequence;

[0066] Specifically, the first and second encoder signals are Hilbert transformed separately. Leveraging the orthogonality and phase-preserving properties of the Hilbert transform, each real signal is mapped to the imaginary component of its corresponding complex analytic signal, yielding the first and second Hilbert transform results, respectively. These two transform results correspond to orthogonal, symmetric forms of the original signal and are instantaneous orthogonal mappings of the signal itself on the complex plane. Based on these transform results, the first encoder signal and its Hilbert transform result are combined to form a first complex analytic signal, with the original signal as the real component and the Hilbert transform as the imaginary component to construct a composite signal. Similarly, the second encoder signal is combined with the second Hilbert transform result to generate a second analytic signal. These two analytic signals represent the complex vector evolution of the primary and secondary encoder signals, respectively. Complex modulus calculations are performed on these two analytic signals. By calculating the modulus length of the complex signal at each sampling point (i.e., the modulus value is equal to the square root of the sum of the squares of the real and imaginary components), the instantaneous envelopes of the first and second encoders are obtained. These two instantaneous envelope signals, respectively, reflect the motor drive power and mechanical load fluctuations corresponding to the primary and secondary encoders during physical motion, exhibiting excellent time-domain continuity and dynamic response characteristics. The instantaneous envelopes of the first and second encoders are amplitude-weightedly fused to achieve structural integration of multi-channel encoder information. This fusion process is accomplished through equal-weighted averaging or adaptive weighting coefficients based on the signal-to-noise ratio. The fused encoder signal envelopes uniformly represent the comprehensive operating status of the current zoom motor. A time-domain differential operation is performed on the fused encoder signal envelopes to calculate their first-order derivative sequence, extracting the signal's rate of change in the time dimension. The resulting first-order derivative sequence represents the transition speed of the power output during the zoom process. Edge detection of the focus step pulse is performed based on this encoder signal envelope. The specific method is to set a dynamic threshold function, identify the rising and falling inflection points of the envelope signal, and determine the pulse start and end points based on the change in the derivative sign, thereby demarcating the pulse time segments corresponding to each focus step. After identifying each complete pulse, the duration, interval period and time series index of the pulse are extracted, and finally a set of encoder pulse timing feature sequences are formed.

[0067] Step 300: Perform dynamic time warping distance calculation on the encoder pulse timing feature sequence to obtain a mode classification result of the current zoom operation;

[0068] Specifically, three types of pulse timing reference templates are extracted from an internally stored library of standard zoom patterns. These templates represent three typical zoom behaviors: continuous zoom, step zoom, and fine focus. Each template is fitted from multiple historical samples through normalization and clustering methods. They contain the duration, start and end rhythm, and overall duration trend of each pulse during the zoom operation, forming a structurally stable reference sequence. The encoder pulse timing feature sequence and the three standard reference sequences are input into the dynamic time warping matching module. This module constructs a time alignment cost matrix and performs nonlinear time axis scaling matching between the current pulse sequence and each reference template. This module searches for the minimum cost path while allowing for rhythm fluctuations and time drift. During the path search, the Euclidean distance is used as the matching cost function for each pulse duration point pair. The sum of the squared absolute differences is calculated and accumulated along the path direction to obtain a first cumulative distance value for the continuous zoom mode, a second cumulative distance value for the step zoom mode, and a third cumulative distance value for the fine focus mode. Each distance value represents the overall morphological matching cost between the current real-time zoom pulse and the corresponding standard template. The smaller the distance, the higher the similarity. The first cumulative distance value, the second cumulative distance value, and the third cumulative distance value are judged as the minimum value. By comparing the size relationship between the minimum distance value and the other two distance values, a preliminary judgment is made as to which type of standard pattern the current zoom behavior is closest to, and the pattern category corresponding to the minimum value is used as the initial classification result. At the same time, in order to avoid blurred boundaries or misclassification, the ratio between the minimum distance value and the second smallest distance value is calculated, that is, the pattern recognition confidence coefficient. The smaller the value, the higher the discrimination and credibility of the current classification. The judgment logic is executed according to the confidence coefficient. When the coefficient is less than the preset confidence threshold (such as 0.7), the initial classification result is confirmed to be a valid classification, and the final pattern classification result of the current zoom operation is output.

[0069] Step 400: Perform state switching determination based on the envelope first-order derivative sequence and the pattern classification result to obtain a zoom state switching moment mark;

[0070] Specifically, based on the first-order derivative sequence of the envelope, the time intervals between consecutive pulses are calculated to construct an encoder pulse interval sequence. This sequence reflects the time span between each pair of adjacent pulses. This sequence is then used to perform a second-order difference operation to obtain a second-order difference rate of change sequence. This sequence measures the dynamic transition trend of the current zoom behavior in the form of time acceleration and is an important basis for judging acceleration, constant speed, and deceleration. At the same time, combined with the current zoom operation type identified by the DTW algorithm, a set of state switching judgment thresholds corresponding to the zoom type are extracted from the preset parameter library, including an acceleration judgment threshold, a constant speed judgment threshold interval, and a deceleration judgment threshold. These thresholds are obtained by fitting a large amount of experimental data and are set based on the typical differences in the second-order dynamic response of the encoder for different zoom modes. They can effectively characterize the state transition behavior during specific operations. After obtaining the state threshold combination corresponding to the current operation, the second-order difference rate of change sequence is compared with this threshold combination point by point. The state segment is determined based on the acceleration level at the current time point: when the second-order difference value at a certain moment is greater than the acceleration judgment threshold, the zoom motor enters the acceleration phase, marked as the accelerated zoom state. When the second-order difference value is stable within the range defined by the constant speed judgment threshold interval, that is, the value fluctuates between the upper and lower limits of the constant speed threshold, it is marked as the constant speed zoom state. When the difference value is less than the deceleration judgment threshold and the derivative changes tend to decline, it is determined to enter the deceleration stop state. The state transition detection logic is constructed based on the zoom state sequence obtained in continuous time. The key behavioral moments are determined by identifying the transition relationship between adjacent states. The five core states defined by the state machine are the static state, the pre-zoom state, the accelerated zoom state, the constant speed zoom state, and the deceleration stop state. The transitions between these states follow the dynamic sequence of physical processes. Therefore, if a transition from the static state to the pre-zoom state is detected in the state sequence, it means that the motor has begun to respond to the zoom command; if the pre-zoom state then jumps to the accelerated zoom state, it indicates that the system is entering the main zoom process; when the accelerated state transitions to the constant speed state, it reflects that the motor has stabilized at the set speed; if the constant speed transitions to the decelerated state, it means that the zoom operation is about to end; and when the decelerated state transitions to the static state, the current zoom behavior is complete. The system will timestamp the corresponding time point when each valid state transition occurs, recording the moment of the zoom state change.

[0071] Step 500: Calculate the phase difference trajectory matching degree and generate a zoom switching completion confirmation signal according to the zoom state switching moment mark.

[0072] Specifically, a time-domain sliding window cross-correlation calculation is performed on the first and second encoder signals. The cross-correlation operation can be viewed as the product integral of the two signals at different time offsets, reflecting the degree of similarity between the two signals within each sliding time window. By appropriately setting the sliding window length (for example, to 10ms or 20ms) to accommodate the lens zoom rhythm, a cross-correlation integration operation is performed within each window, forming a sequence of cross-correlation results consisting of a series of time offset-correlation strength data points. Peak detection and delay location operations are performed based on the cross-correlation sequence. By searching for the maximum position of the cross-correlation function within each sliding window, the maximum alignment offset of the two encoder signals within that window is determined. The maximum alignment offset value calculated for each window is converted together with the encoder sampling frequency into a phase difference value, constructing a continuously updated real-time phase difference sequence. This sequence, with time as the horizontal axis and phase difference as the vertical axis, can characterize the relative rotational position change trend between the primary and secondary encoders due to zoom drive. To enhance the comparability and continuity of the trajectory, the real-time phase difference sequence is rearranged in chronological order, discontinuities are filled, and smooth interpolation is performed to obtain a continuous encoder phase difference trajectory curve. The constructed phase difference trajectory is compared with three pre-stored standard zoom mode trajectories in the system. These standard trajectories include those for continuous zoom mode, step zoom mode, and fine focus mode. Each trajectory is fitted from historical sample data through multiple zoom experiments and exhibits high morphological stability and pattern feature clarity. Using a curve fitting algorithm, such as the least squares method or normalized similarity metric, a point-by-point fit is performed between the real-time phase trajectory and each standard trajectory. The corresponding trajectory fitting coefficient for each mode is calculated. A coefficient closer to 1 indicates a higher degree of fit. The largest of the three fitting coefficients is used as the optimal match for the current trajectory, i.e., the phase difference trajectory matching degree, to assess whether the current zoom operation is consistent with the standard mechanical behavior. To ensure that the zoom switch confirmation signal has sufficient logical closure, the zoom state transition information previously determined based on the derivative sequence is combined with monitoring, particularly the transition from deceleration stop to stationary state. When the system detects the occurrence of the above-mentioned transition event in a continuous state sequence, and the corresponding phase difference trajectory matching degree exceeds the preset matching threshold (for example, 0.85), it is determined that the current zoom behavior has been fully executed as expected and the mechanical response is true and reliable, thereby triggering the generation of a zoom switching completion confirmation signal.

[0073] In a specific embodiment, the process of executing step 100 may specifically include the following steps:

[0074] The A-phase TTL level signal and the B-phase TTL level signal output by the lens focal length encoder are synchronously sampled and analog-to-digital converted to obtain the A-phase encoder signal and the B-phase encoder signal;

[0075] The A-phase encoder signal and the B-phase encoder signal are respectively input into a 4th-order Butterworth low-pass filter for filtering to obtain a filtered A-phase encoder signal and a filtered B-phase encoder signal;

[0076] The filtered A-phase encoder signal is standardized to obtain a first encoder signal, and the filtered B-phase encoder signal is standardized to obtain a second encoder signal.

[0077] Specifically, the lens focal length encoder is a rotary incremental detection device. Its A and B phases output TTL-level pulse signals with a 90-degree electrical phase difference, representing the rotational direction and incremental displacement, respectively. Because the lens zoom operation requires determining focal length changes at varying speeds, travel distances, and multiple start-stop conditions, the encoder signals must be captured with strict time synchronization and amplitude stability. In system implementation, a synchronous sampling module supporting dual-channel input is constructed, and a unified clock source is configured to maintain equal sampling cycles for both channels. This module is integrated into a microcontroller or FPGA platform. A high-precision clock frequency (e.g., 100kHz) is set to ensure that TTL pulse edge variations are fully reproduced even during high-speed motor zoom operation. The sampled A and B phase signals are typical TTL digital level signals with a 0-5V amplitude. The system is equipped with a high-resolution analog-to-digital converter (ADC) that converts the analog voltage values ​​into 12-bit digital quantities in the A / D channel, uniformly mapping the voltage range of 0-5V to integers ranging from 0 to 4095, forming a discrete sequence. The converted Phase A and Phase B encoder signals retain the timing rhythm and amplitude structure of the original waveforms. Because encoder signals are susceptible to high-frequency interference in real-world environments, such as motor electromagnetic interference, power supply ripple, switching noise, and signal mutual inductance, both signals undergo high-frequency noise reduction processing after sampling. A fourth-order Butterworth low-pass filter is used to digitally filter the Phase A and Phase B encoder signals. The Butterworth filter offers ideal unity-gain response and maximum flatness, providing uniform amplification without ripple within the passband. It also exhibits a smooth, steep roll-off after the cutoff frequency, preventing distortion caused by edge effects. The cutoff frequency is set to 50kHz to effectively filter out high-frequency interference signals above the encoder signal's eigenfrequency while preserving the pulse's main zoom rhythm. The filter is constructed in software or implemented in hardware using a DSP digital filter module using a cascaded approach. The filter response is calculated point by point on the sample sequence, outputting smooth waveforms after removing high-frequency noise: the filtered Phase A and Phase B encoder signals. The filtered signal is processed in the unified amplitude domain to eliminate the impact of amplitude bias on amplitude-sensitive algorithms, ensuring that the zoom state recognition algorithm is device-independent in the amplitude dimension. Normalization maps the signal to a unified standard amplitude range without changing its relative structure. The filtered signal is extracted and linearly transformed to bring its amplitude into the normalized range of [-1, 1]. After this normalization process, the filtered A-phase signal is identified as the first encoder signal, and the filtered B-phase signal is identified as the second encoder signal.

[0078] In a specific embodiment, the process of executing step 200 may specifically include the following steps:

[0079] Performing Hilbert transform calculations on the first encoder signal and the second encoder signal respectively to obtain a first Hilbert transform result and a second Hilbert transform result;

[0080] constructing a first analytical signal based on the first encoder signal and the first Hilbert transform result, and constructing a second analytical signal based on the second encoder signal and the second Hilbert transform result;

[0081] Performing modulus calculations on the first analytical signal and the second analytical signal respectively to obtain a first encoder instantaneous envelope and a second encoder instantaneous envelope;

[0082] Performing amplitude-weighted fusion on the instantaneous envelope of the first encoder and the instantaneous envelope of the second encoder to obtain an encoder signal envelope, and performing a time-domain differential operation on the encoder signal envelope to obtain an envelope first-order derivative sequence;

[0083] Focus step pulse edge detection and pulse duration extraction are performed based on the encoder signal envelope to obtain the encoder pulse timing feature sequence.

[0084] Specifically, a Hilbert transform is applied to the first and second encoder signals, respectively. As a linear time-domain transform, the Hilbert transform essentially attenuates the negative frequency portion of a signal in the frequency domain and multiplies the positive frequency portion by a pure imaginary number j, thereby mapping the real signal into a complex analytic form that maintains amplitude and phase. This operation produces a first Hilbert transform result from the first encoder signal and a second Hilbert transform result from the second encoder signal, representing the orthogonal imaginary components of the two real signals at time point t. Each real signal is combined with its corresponding Hilbert transform to construct a complex analytic signal, using the real signal as the real part and the Hilbert transform as the imaginary part, generating the first and second analytic signals. Each analytic signal is considered a rotational trajectory of the encoder signal in the complex plane, with its modulus reflecting the instantaneous amplitude and its angle reflecting the instantaneous phase. It provides a complete digital abstraction of the power fluctuations, acceleration changes, and rhythm switching during mechanical zoom. This form avoids the instability of directly extracting the pulse envelope from the jump signal, ensuring temporal continuity and structural consistency in signal analysis. Modulus calculation is performed on the first and second analytical signals, respectively. For each complex sample, the square root of the sum of the squares of its real and imaginary parts is calculated to obtain the instantaneous envelopes of the first and second encoders. These envelopes represent the power output responses of the primary and secondary encoders to the zoom drive process at the current moment. To enhance signal robustness, the two envelope signals are amplitude-weighted and fused to construct a unified encoder signal envelope. Weighting can be performed using a fixed ratio, such as 0.5:0.5, or dynamically based on the previous signal-to-noise ratio or stability index. This enhances the dominance of the primary signal or offsets deviations from the secondary signal, ensuring that the fused envelope curve more accurately reflects the current motor load and motion trends. In the time domain, the encoder signal envelope appears as a continuous curve with smooth transitions and clear ups and downs. It exhibits typical sharp rises, plateaus, and steep falls during zooming. To extract the envelope's rate of change and acceleration trend, the fused encoder signal envelope is first-order differentiated to construct a sequence of first-order derivatives. This sequence is highly sensitive to the rise rate, peak sharpness, and downward trend of the envelope waveform, making it suitable for detecting the starting and stopping points and steady-state sections of zoom operations. For example, at the steep rising edge of the envelope, its derivative value exhibits a positive peak; during the stable section, the derivative value is near zero; and during the downward slope before stopping, it exhibits a negative peak. Based on the encoder signal envelope, an edge detection algorithm is used to identify the start and end boundaries of the focal length step pulse. The specific method is to set dynamic thresholds (such as 1.5 times the baseline mean as the rising edge trigger threshold and 0.8 times the baseline mean as the falling edge decay threshold). Combined with the derivative's positive and negative zero-crossing discrimination strategy, the algorithm searches for steep rise and fall inflection points in the envelope waveform, marks the start and end points of each complete pulse, and calculates its duration.The start and end time points of all pulses and their corresponding durations constitute the encoder pulse timing feature sequence, forming a set of time structure feature data reflecting the zoom rhythm, mode category and motor control characteristics.

[0085] In a specific embodiment, the execution step performs focus step pulse edge detection and pulse duration extraction based on the encoder signal envelope to obtain the encoder pulse timing feature sequence, which may specifically include the following steps:

[0086] Perform baseline mean calculation and noise variance analysis on the encoder signal envelope to obtain an envelope baseline reference value, and set the pulse start detection threshold and pulse stop detection threshold based on the envelope baseline reference value;

[0087] Perform rising edge detection on the encoder signal envelope based on the pulse start detection threshold, mark the pulse start time when the envelope amplitude rises and exceeds the pulse start detection threshold, and obtain the pulse start time sequence;

[0088] The falling edge of the encoder signal envelope is detected based on the pulse stop detection threshold. When the envelope amplitude drops below the pulse stop detection threshold, the pulse end time is marked to obtain the pulse end time sequence;

[0089] The time difference is calculated based on the pulse start time sequence and the pulse end time sequence to obtain the duration value of each pulse, and the encoder pulse timing feature sequence is generated based on the duration value of each pulse.

[0090] Specifically, based on the encoder envelope sequence, the stable section in the absence of zoom operation is statistically calculated to establish an envelope baseline reference model. The envelope baseline reference value contains two core statistical parameters: the global mean μ of the envelope amplitude, which is obtained by sampling the amplitude values ​​of multiple time windows and averaging them when the lens is stationary, reflecting the envelope stability level of the current system under no mechanical activity conditions; the variance σ of the amplitude samples 2The variance is calculated by calculating the mean of the squared deviations of each sample value from the mean within the same static window. It describes the typical fluctuation range of system noise in a static state. These two statistical values ​​constitute the envelope baseline reference value, which is used to identify abnormal jumps in the envelope signal caused by real motor activity. Based on this baseline reference value, the system sets a pair of dynamic thresholds for pulse edge detection: the pulse start detection threshold T1 and the pulse stop detection threshold T2. To effectively suppress false triggering from static noise, the pulse start threshold T1 is defined as μ + N1 × σ, where N1 is an empirical weighting factor ranging from 2 to 5. This ensures that only envelope signal jumps significantly greater than the static disturbance upper limit are considered motor start signals. The pulse stop detection threshold T2 is defined as μ + N2 × σ, where N2 is less than N1 and ranges from 1 to 2. This allows the system to promptly detect the end of zoom behavior when the envelope drops close to the baseline. After the thresholds are set, the system enters the pulse start and end point identification phase. To detect pulse start points, the system traverses the encoder envelope sequence and uses time as an index to determine the signal amplitude point by point. When the envelope amplitude at a sampling point suddenly jumps from below T1 to above T1 and remains above T1 for several consecutive points, the jump is identified as a valid edge. The jump point is timestamped as the start of the pulse and recorded in the start time sequence. This mechanism combines the dual criteria of amplitude transition threshold triggering and continuous stability to avoid false triggering caused by transient glitches. To detect pulse end points, the system uses the opposite logic for falling edge detection: when the envelope amplitude at a sampling point drops from above T2 to below T2 and remains below this level for multiple subsequent points, it is considered a valid falling edge. The corresponding timestamp marks the end of the pulse and is added to the end time sequence. After completing this identification operation, the system performs a difference calculation on each pair of start and end times to calculate the duration of the i-th pulse in milliseconds or sampling periods. To ensure the accuracy of time difference calculations, the consistency of the start and end sequence lengths is verified during the calculation process, and outlier pairs (such as intervals that are too short or too long) are excluded to maintain the rationality of the pulse time distribution. All calculated pulse duration values ​​are arranged in chronological order to form a characteristic sequence of encoder pulse timing, where each point corresponds to an independent zoom step event, and this sequence has significant differences in duration structure under different zoom operation types. For example, under continuous zoom, the pulse duration sequence is relatively dense and uniform; while under step zoom or fine focus, it exhibits irregular rhythms and large duration variations.

[0091] In a specific embodiment, the process of executing step 300 may specifically include the following steps:

[0092] Extracting the continuous zoom pulse timing template, the step zoom pulse timing template, and the fine focus pulse timing template from the preset zoom mode library, respectively, to obtain the pulse duration reference sequences of the three standard zoom modes;

[0093] The encoder pulse timing feature sequence and the pulse duration reference sequence of the three standard zoom modes are respectively subjected to dynamic time warping path search and Euclidean distance accumulation calculation to obtain the first cumulative distance value corresponding to the continuous zoom mode, the second cumulative distance value corresponding to the step zoom mode, and the third cumulative distance value corresponding to the fine focus mode;

[0094] Comparing the first cumulative distance value, the second cumulative distance value, and the third cumulative distance value for minimum values, selecting the zoom mode with the minimum cumulative distance value as the initial classification result, and calculating the ratio of the minimum cumulative distance value to the second minimum cumulative distance value to obtain a pattern recognition confidence coefficient;

[0095] A threshold determination is performed based on the pattern recognition confidence coefficient. When the pattern recognition confidence coefficient is less than a preset confidence threshold, the initial classification result is confirmed to be a valid classification, and the pattern classification result of the current zoom operation is obtained.

[0096] Specifically, pulse duration reference sequences representing three typical zoom behaviors are extracted from a pre-set zoom pattern library within the system. This library, derived from a large amount of sample data collected experimentally and analyzed offline, contains the feature extraction and normalization results for encoder pulse duration sequences under different operating conditions for three zoom types: continuous zoom, step zoom, and fine focus. The continuous zoom template sequence features stable pulse spacing, minimal duration fluctuation, and uniform total duration; the step zoom template sequence exhibits regular periodic fluctuations, a clear stepping rhythm, and a fixed interval structure; and the fine focus template consists of a small number of short pulses with short sequence lengths, extremely small durations, and a sparse distribution. Extracting these three sets of standard templates from the library creates three types of known time series reference data, denoted as Tc (continuous zoom template), Ts (step zoom template), and Tf (fine focus template). The system then obtains the real-time pulse timing feature sequence Tq calculated from the current encoder data. This sequence consists of the durations of multiple pulses in the order in which the zoom is executed. To determine which standard behavior Tq most closely matches, Tq is matched with Tc, Ts, and Tf using dynamic time warping. Dynamic time warping is a timing algorithm that handles the matching of sequences of unequal lengths. By constructing a distance matrix, it allows for nonlinear scaling in the time dimension and seeks the global minimum cost path to obtain the optimal alignment path between the two sequences. The system uses Tq as the test sequence and inputs it, along with Tc, Ts, and Tf as target templates, into the DTW computation engine, performing path search and local Euclidean distance accumulation. Each matching process outputs a total path distance value, denoted as Dc (the distance between Tq and Tc), Ds (the distance between Tq and Ts), and Df (the distance between Tq and Tf). The smaller these distance values, the closer the test sequence is to the corresponding template in terms of temporal structure. The path cost is calculated by pairing test pulses with template pulses in pairs during the registration process and calculating the square of the difference in their durations as the cost. The system then searches the entire cost matrix for a registration path with the lowest total cost, outputting this path cost as the cumulative distance for the match. After calculating the path distances for the three patterns, the system enters the distance comparison and initial classification stage. Dc, Ds, and Df are compared for their minimum values, and the pattern corresponding to the smallest value is selected as the initial recognition result. For example, if Dc is the minimum, the current operation is initially judged as continuous zoom; if Ds is the minimum, it is initially judged as step zoom; and if Df is the minimum, it is initially judged as fine focus. To prevent misclassification caused by blurred boundaries between patterns, the pattern recognition confidence coefficient R is calculated. This coefficient is defined as the ratio of the current minimum distance value to the next minimum distance value. A closer value to 1 indicates that the current test sequence is close to multiple templates simultaneously, resulting in higher recognition uncertainty. A smaller value indicates that the test sequence closely matches a template and differs significantly from others, resulting in higher recognition confidence.The system performs a threshold judgment on the confidence coefficient R to determine whether it meets the valid classification criteria. Set the system's internal confidence threshold (for example, set it to 0.7). If the current R value is less than the threshold, it means that there is a sufficiently large difference between the optimal matching result and the suboptimal result, and the recognition result is considered statistically significant. At this time, the initial classification is confirmed to be valid, and the mode is output as the final classification result of the current zoom operation; if the R value is greater than or close to the threshold, it means that there is a lack of sufficient distinction between the minimum distance and the second minimum distance. The system determines that the initial classification is an unreliable result and triggers resampling or delays the classification process when necessary to avoid erroneous control caused by template misjudgment.

[0097] In a specific embodiment, the process of executing step 400 may specifically include the following steps:

[0098] Perform continuous pulse interval calculation and second-order difference operation on the envelope first-order derivative sequence to obtain the encoder pulse interval sequence and the corresponding second-order difference change rate sequence;

[0099] Selecting the corresponding zoom type threshold parameters from the preset parameter library according to the pattern classification results, setting the acceleration determination threshold, constant speed determination threshold, and deceleration determination threshold respectively, and obtaining the state switching threshold combination of the current zoom operation;

[0100] The second-order difference change rate sequence is combined with the state switching threshold for point-by-point comparison and state transition logic judgment. When the second-order difference change rate is greater than the acceleration judgment threshold, it is determined to be an accelerated zoom state. When the second-order difference change rate is within the constant speed judgment threshold, it is determined to be a constant speed zoom state. When the second-order difference change rate is less than the deceleration judgment threshold, it is determined to be a deceleration stop state, thereby obtaining a zoom state sequence.

[0101] The zoom state sequence is subjected to state jump detection and moment marking. When a jump from the static state to the pre-zoom state, from the pre-zoom state to the accelerated zoom state, from the accelerated zoom state to the constant-speed zoom state, from the constant-speed zoom state to the decelerated stop state, and from the decelerated stop state to the static state is detected, the corresponding timestamps are recorded to obtain the zoom state switching moment mark.

[0102] Specifically, the first-order derivative sequence of the envelope can reveal the rising, stabilizing, and declining rhythms of the envelope during zooming. To extract the rhythmic patterns of speed changes, continuous derivative change cycles are analyzed, specifically by extracting a sequence of time intervals of pulse events. This time interval refers to the sampling interval between two adjacent extreme points (e.g., from a positive peak to a negative peak, or from a negative peak to a positive peak) or edge transition points in the derivative sequence. By setting a derivative threshold, the system identifies the sampling index position of each significant abrupt change event and calculates the sampling difference between each two abrupt changes, forming a sequence of pulse intervals that increase in time. A second-order difference operation is performed on the resulting interval sequence to assess the changing trend of the time interval, that is, the "acceleration" property of speed change. This second-order difference rate of change sequence constitutes the core dynamic criterion for reflecting the speed change stage of the current zoom operation in the time dimension. Positive values ​​indicate a slowing of the interval expansion trend, values ​​near zero indicate a stabilizing speed, and negative values ​​indicate a deceleration of the zoom process. Based on the pattern classification results, the corresponding zoom type threshold parameter is selected from a preset parameter library. The parameter library maps the typical second-order difference fluctuation ranges under the three states of accelerated zoom, constant speed zoom and decelerated zoom to different threshold parameter combinations, respectively setting the acceleration judgment threshold, constant speed judgment threshold and deceleration judgment threshold. For example, for continuous zoom, the acceleration judgment threshold is set to 0.5ms. 2 , the constant speed judgment threshold is ±0.2ms 2 , the deceleration threshold is -0.6ms 2For step zoom, the threshold range is narrow, the stability tolerance is small, and the acceleration and deceleration thresholds are highly symmetrical. For fine focus, due to the low number of pulses and frequent state changes, the system uses relatively sensitive threshold settings to accommodate the frequent jumps. For fine focus, a more sensitive judgment criterion is preferred to accommodate the frequent rhythm switching. Based on these threshold settings, the system compares each value in the second-order rate of change sequence with three sets of thresholds. If it exceeds the acceleration threshold, it is considered to be in the accelerated zoom state; if it is within the constant speed range, the current rhythm is considered to be stable and in the constant speed zoom state; if it is below the deceleration threshold, the current operation has entered the deceleration phase or is about to stop. The resulting state label sequence is a structured data set with the same length as the pulse interval sequence. Each element in the sequence identifies the zoom state type corresponding to the current moment. Finite state logic is used to monitor and confirm each legal state transition in the state sequence. The system's state machine model contains five core states: static, pre-zoom, accelerated zoom, constant-speed zoom, and decelerated stop. The order of state transitions conforms to physical behavior. The transition from static to pre-zoom is triggered by a significant jump in the envelope derivative, coupled with a pulse start event. The condition for the pre-zoom to accelerated zoom state is that multiple consecutive second-order rate-of-change values ​​remain above the acceleration threshold. The condition for the transition from accelerated zoom to constant-speed zoom is that the value remains within the constant-speed tolerance range for a certain time. The transition from constant speed to deceleration requires that the rate of change continues to decrease and is less than the deceleration threshold. When the envelope stabilizes and returns to near the baseline and the pulse stop condition is met in the deceleration state, the system is considered to have entered a static state. Whenever a structural transition event that meets these transition conditions occurs in the aforementioned state sequence, the system marks the time of its occurrence, recording the sampling moment as a valid state switch timestamp. These timestamps are organized in chronological order to form a sequence of zoom state switching moments, which is used to describe the time distribution of key behavior nodes in the current zoom process. These typically include the start time of the zoom action, the entry time of the acceleration process, the starting point of the constant speed process, the starting position of the deceleration process, and the precise boundary where the zoom stops.

[0103] In a specific embodiment, the process of performing continuous pulse interval calculation and second-order difference operation on the envelope first-order derivative sequence to obtain the encoder pulse interval sequence and the corresponding second-order difference change rate sequence may specifically include the following steps:

[0104] Perform extreme value detection and peak screening on the first-order derivative sequence of the envelope. When the amplitude change rate of the first-order derivative of the envelope exceeds a preset fluctuation threshold, it is marked as the pulse peak moment, and a pulse peak moment sequence is obtained.

[0105] According to the pulse peak time sequence, the i-th pulse peak time is subtracted from the i+1-th pulse peak time to obtain the i-th pulse interval value, and the differences of all adjacent pulse peak times are calculated in sequence based on the pulse interval value to obtain the encoder pulse interval sequence;

[0106] According to the encoder pulse interval sequence, the difference between adjacent pulse intervals is calculated to obtain a first-order difference sequence, and then the difference between adjacent elements of the first-order difference sequence is calculated to obtain a second-order difference sequence;

[0107] The second-order difference sequence is divided element by element by the encoder pulse interval sequence to obtain the second-order difference change rate sequence.

[0108] Specifically, the first-order derivative sequence of the envelope reflects the real-time variation trend of the envelope amplitude in the lens encoder signal with high time sensitivity. The amplitude of any derivative value, as well as its positive or negative variation trend, directly indicates whether the zoom action is in the startup, stabilization, or decay phase. Based on this, to extract pulse feature points with periodic patterns, the derivative sequence is subjected to extreme value detection. Combined with threshold judgment logic based on peak variation trends, pulse response points with significant physical significance are screened. The system uses a sliding window analysis technique to scan the derivative sequence point by point, determining within each window whether the current sampling point is a local maximum or minimum. To suppress spurious peak responses caused by noise or transient perturbations, a preset fluctuation threshold is set, based on a multiple of the standard deviation of the derivative in the static region (for example, three times the standard deviation of the baseline fluctuation). Extreme points are marked only when the amplitude change relative to the preceding and following points exceeds this threshold. All sampling times marked as valid extreme values ​​are added to the pulse peak time sequence. By calculating the time difference between two consecutive elements in the pulse peak moment sequence, the duration of the i-th pulse interval is obtained by subtracting the i-th peak moment from the i+1-th peak moment. This method is repeated through all adjacent peak pairs to generate a time series consisting of multiple pulse intervals, known as the encoder pulse interval sequence. The temporal structure of this sequence directly reflects the rhythm distribution during the zoom process. For example, during the acceleration phase, the pulse intervals show a decreasing trend; during the constant speed phase, the intervals tend to be consistent; and during the deceleration phase, the intervals increase. Dynamic changes in the pulse interval sequence are analyzed. By performing a first-order difference operation on this sequence, taking the numerical difference between each pair of adjacent pulse intervals, a first-order difference sequence is generated. This sequence reflects the increase or decrease trend of the pulse interval at the current moment compared to the previous moment. A negative difference indicates a shortening of the current interval, meaning the pulse rhythm is accelerating, indicating an acceleration phase. A difference close to zero indicates a stable interval, indicating a constant speed operation. A positive difference indicates an increasing interval, indicating a deceleration trend. Based on the first-order difference sequence, a differential process is performed to obtain a second-order difference sequence, that is, the difference between any two adjacent first-order difference values ​​is calculated. This step models the changing trend of the pulse rhythm. The positive and negative signs and numerical amplitudes are used to determine the acceleration state of the rhythm change, forming a measurement tool for judging the acceleration, constant speed, and deceleration stages of the zoom process. The second-order difference sequence is divided element by element by the original pulse interval sequence to form a normalized rate of change measurement sequence, resulting in a second-order difference rate of change sequence. This sequence represents the rate of change of the rhythm trend as a relative quantity. A positive value indicates that the current state is accelerating, a value close to zero indicates that the rhythm change is stable, and a negative value indicates that the rhythm is rapidly decreasing and approaching a stop. By analyzing the stability, amplitude trend, and time scalability of this relative rate of change indicator, state label mapping, switching point identification, zoom behavior estimation, and dynamic modeling of various zoom stages are performed.

[0109] In a specific embodiment, the process of executing step 500 may specifically include the following steps:

[0110] Performing a time domain sliding window cross-correlation calculation on the first encoder signal and the second encoder signal to obtain a cross-correlation calculation result;

[0111] Peak detection and time delay positioning are performed based on the cross-correlation operation results to obtain a real-time phase difference sequence, which is then arranged in time sequence and reconstructed to obtain the encoder phase difference trajectory.

[0112] The encoder phase difference trajectory is curve fitted and similarity calculated with the pre-stored continuous zoom phase standard trajectory, step zoom phase standard trajectory, and fine focus phase standard trajectory respectively to obtain the trajectory fitting coefficients corresponding to the three modes, and the maximum trajectory fitting coefficient is selected as the phase difference trajectory matching degree;

[0113] The state jump from the deceleration stop state to the static state is monitored according to the zoom state switching moment mark. When the state jump is detected to occur and the phase difference trajectory matching degree is greater than the preset matching threshold, a zoom switching completion confirmation signal is generated.

[0114] Specifically, a time-domain sliding window cross-correlation calculation is performed on the first and second encoder signals. Using the sliding time window as a unit, a segment of the first encoder signal near the current moment and a segment of the second encoder signal of the same length are captured, and a cross-correlation function is calculated within each window. By performing product-accumulation operations on the two signals at different time offsets, a graph of the cross-correlation strength versus time offset is generated. The peak position of this graph represents the time delay point where the two signals reach maximum similarity within the window, and thus this delay point constitutes the current relative phase difference between the two signals. To ensure continuity in the time-domain response and the ability to capture transient mutations, the sliding window length should be kept within a moderate range, for example, between 5 and 10 milliseconds, and the window update step size should be significantly smaller than the window width to achieve high-resolution delay tracking. After the cross-correlation calculation is completed, the system generates a complete cross-correlation curve within each time window. Peak detection is then performed on this curve, comparing the maximum value points in the cross-correlation results and identifying the corresponding time delay positions to obtain the maximum correlation delay value within that time window. The peak delays of all sliding windows are arranged in chronological order, forming a set of phase difference data corresponding to consecutive sampling points. This data is expressed as millisecond-level delays or as sample point differences, known as a real-time phase difference sequence. This sequence reflects the changing pattern of the relative positional relationship between the primary and secondary encoder signals throughout the zoom process. Its value changes directly correspond to the consistency, synchronization, and dynamic responsiveness of the mechanical rotation in the lens zoom mechanism. To extract trajectory features and perform pattern comparison, this real-time phase difference sequence is reconstructed using a time-indexed trajectory. This involves interpolation fitting, noise smoothing, and time normalization of the data points to construct an encoder phase difference trajectory. After the phase difference trajectory is constructed, a standard trajectory comparison is performed to assess the similarity between the current phase difference curve and the standard trajectories corresponding to three typical zoom modes, verifying the physical behavior and confirming the zoom type. Three standard phase difference trajectories are pre-stored in the system: a smooth monotonic trajectory for continuous zoom mode, a rhythmic step trajectory for step zoom mode, and a rapid fluctuation trajectory for fine focus mode. Each standard trajectory is derived from regression modeling and smoothing of extensive experimental data. During the comparison process, a curve fit operation is performed on the current phase difference trajectory and each standard trajectory, and a corresponding goodness-of-fit index is calculated. This index is obtained through residual minimization, normalized error accumulation, or correlation coefficient. The closer the value is to 1, the greater the similarity between the current trajectory and the corresponding standard trajectory. After the comparison is complete, the trajectory fitting coefficients of the three modes are obtained, and the system selects the maximum fitting coefficient as the final phase difference trajectory match. To prevent the risk of misjudgment caused by single-dimensional judgment, state jump constraints are introduced as auxiliary conditions for confirming zoom completion.In the previously completed envelope derivative analysis and state label determination, the system has already recorded the state transition structure of the entire zoom process. In particular, when detecting the critical transition from "deceleration stop state to static state," the system has identified the switching node in this stage through the derivative change trend and state label sequence. Therefore, when the system detects that the phase difference trajectory matching degree is greater than the preset matching threshold (for example, set to 0.85) during the phase trajectory matching determination stage, and simultaneously detects a legitimate transition event from deceleration stop state to static state in the state sequence, if both conditions are met, the system will simultaneously confirm that the zoom action has been fully completed and generate a zoom switch completion confirmation signal accordingly.

[0115] The lens recognition method according to the embodiment of the present invention is described above. The lens recognition device according to the embodiment of the present invention is described below. Figure 2 In one embodiment of the present invention, a lens recognition device includes:

[0116] A signal acquisition module 11 is used to acquire signals from a lens focal length encoder to obtain a first encoder signal and a second encoder signal;

[0117] A detection module 12 is configured to perform envelope detection and pulse detection on the first encoder signal and the second encoder signal to obtain an envelope first-order derivative sequence and an encoder pulse timing characteristic sequence;

[0118] A calculation module 13 is used to perform dynamic time warping distance calculation on the encoder pulse timing feature sequence to obtain a mode classification result of the current zoom operation;

[0119] A determination module 14 is configured to perform state switching determination based on the envelope first-order derivative sequence and the pattern classification result, and obtain a zoom state switching moment mark;

[0120] The generating module 15 is configured to calculate the phase difference trajectory matching degree and generate a zoom switching completion confirmation signal according to the zoom state switching moment mark.

[0121] Through the collaborative efforts of the above components, by directly acquiring and processing the A-phase and B-phase signals of the lens focal length encoder, the indirectness problem of traditional image frame difference detection is bypassed, and zoom status information can be directly obtained from the mechanical level inside the lens, eliminating the interference of external factors such as lighting changes and target object movement on the detection results, significantly improving the accuracy and reliability of detection. By using Hilbert transform envelope detection technology to directly process the encoder signal, the detection response time is shortened from the frame-level delay of traditional methods to the millisecond level, realizing real-time detection of zoom switching and meeting the timeliness requirements of high-speed zoom operation and precision control. By using the dynamic time warping distance calculation method to perform pattern matching on the encoder pulse timing characteristics, it is possible to accurately distinguish between three different types of zoom operations: continuous zoom, step zoom, and fine focus, solving the technical problem that traditional methods cannot effectively distinguish zoom modes. The constructed five-state encoder identification controller can accurately track the static state, pre-zoom state, accelerated zoom state, constant speed zoom state and decelerated stop state during the zoom process. The second-order differential rate of change analysis is used to accurately mark the state switching moment, providing fine-grained state information for zoom control. Using the phase correlation analysis of the first encoder signal and the second encoder signal, a dual-channel cross-validation mechanism is established, which can effectively eliminate false detections caused by electromagnetic interference and mechanical jitter, and significantly reduce the system's false detection rate and missed detection rate. Through cross-correlation function calculation and phase difference trajectory analysis, the system can maintain stable detection performance in complex electromagnetic environments. The phase correlation verification mechanism provides a reliable technical guarantee for the final zoom switching confirmation. The dynamic time warping algorithm allows nonlinear scaling of the pulse sequence on the time axis, can adapt to signal timing changes under different zoom speeds, overcomes the limitations of the traditional fixed time window matching method, and improves the algorithm's applicability and robustness.

[0122] The lens provided by the embodiment of the present invention is used to execute any of the above lens recognition methods.

[0123] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0124] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the existing technology, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a lens (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0125] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that the technical solutions described in the above embodiments can still be modified, or some of the technical features thereof can be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A lens recognition method, characterized in that: include: Acquire signals from a lens focal length encoder to obtain a first encoder signal and a second encoder signal; Performing envelope detection and pulse detection on the first encoder signal and the second encoder signal to obtain an envelope first-order derivative sequence and an encoder pulse timing characteristic sequence; Performing dynamic time warping distance calculation on the encoder pulse timing feature sequence to obtain a mode classification result of the current zoom operation; Performing state switching determination based on the envelope first-order derivative sequence and the pattern classification result to obtain a zoom state switching moment mark; The phase difference track matching degree is calculated and a zoom switching completion confirmation signal is generated according to the zoom state switching moment mark.

2. The lens recognition method according to claim 1, characterized in that: The lens focal length encoder signal acquisition is performed to obtain a first encoder signal and a second encoder signal, including: The A-phase TTL level signal and the B-phase TTL level signal output by the lens focal length encoder are synchronously sampled and analog-to-digital converted to obtain the A-phase encoder signal and the B-phase encoder signal; Inputting the A-phase encoder signal and the B-phase encoder signal into a 4th-order Butterworth low-pass filter for filtering, respectively, to obtain a filtered A-phase encoder signal and a filtered B-phase encoder signal; The filtered A-phase encoder signal is standardized to obtain a first encoder signal, and the filtered B-phase encoder signal is standardized to obtain a second encoder signal.

3. The lens recognition method according to claim 1, wherein: The performing envelope detection and pulse detection on the first encoder signal and the second encoder signal to obtain an envelope first-order derivative sequence and an encoder pulse timing characteristic sequence includes: Performing Hilbert transform calculations on the first encoder signal and the second encoder signal respectively to obtain a first Hilbert transform result and a second Hilbert transform result; constructing a first analytical signal based on the first encoder signal and the first Hilbert transform result, and constructing a second analytical signal based on the second encoder signal and the second Hilbert transform result; Performing modulus calculation on the first analytical signal and the second analytical signal respectively to obtain a first encoder instantaneous envelope and a second encoder instantaneous envelope; Performing amplitude-weighted fusion on the instantaneous envelope of the first encoder and the instantaneous envelope of the second encoder to obtain an encoder signal envelope, and performing a time-domain differential operation on the encoder signal envelope to obtain an envelope first-order derivative sequence; Focus step pulse edge detection and pulse duration extraction are performed based on the encoder signal envelope to obtain an encoder pulse timing feature sequence.

4. The lens recognition method according to claim 3, characterized in that: The step of performing focus step pulse edge detection and pulse duration extraction based on the encoder signal envelope to obtain an encoder pulse timing feature sequence includes: Performing baseline mean calculation and noise variance analysis on the encoder signal envelope to obtain an envelope baseline reference value, and setting a pulse start detection threshold and a pulse stop detection threshold based on the envelope baseline reference value; Performing rising edge detection on the encoder signal envelope based on the pulse start detection threshold, marking the pulse start time when the envelope amplitude rises and exceeds the pulse start detection threshold, and obtaining a pulse start time sequence; Performing falling edge detection on the encoder signal envelope based on the pulse stop detection threshold, marking the pulse end time when the envelope amplitude drops below the pulse stop detection threshold, and obtaining a pulse end time sequence; A time difference is calculated based on the pulse start time sequence and the pulse end time sequence to obtain a duration value of each pulse, and an encoder pulse timing feature sequence is generated based on the duration value of each pulse.

5. The lens recognition method according to claim 1, characterized in that: The performing dynamic time warping distance calculation on the encoder pulse timing feature sequence to obtain a mode classification result of the current zoom operation includes: Extracting the continuous zoom pulse timing template, the step zoom pulse timing template, and the fine focus pulse timing template from the preset zoom mode library, respectively, to obtain the pulse duration reference sequences of the three standard zoom modes; Performing dynamic time warping path search and Euclidean distance accumulation calculation on the encoder pulse timing feature sequence and the pulse duration reference sequences of the three standard zoom modes, respectively, to obtain a first cumulative distance value corresponding to the continuous zoom mode, a second cumulative distance value corresponding to the step zoom mode, and a third cumulative distance value corresponding to the fine focus mode; performing a minimum comparison on the first cumulative distance value, the second cumulative distance value, and the third cumulative distance value, selecting the zoom mode with the smallest cumulative distance value as the initial classification result, and calculating a ratio of the smallest cumulative distance value to the second smallest cumulative distance value to obtain a pattern recognition confidence coefficient; A threshold determination is performed based on the pattern recognition confidence coefficient, and when the pattern recognition confidence coefficient is less than a preset confidence threshold, the initial classification result is confirmed to be a valid classification, thereby obtaining a pattern classification result of the current zoom operation.

6. The lens recognition method according to claim 1, characterized in that: The performing state switching determination based on the envelope first-order derivative sequence and the pattern classification result to obtain a zoom state switching moment mark includes: Performing continuous pulse interval calculation and second-order difference operation on the envelope first-order derivative sequence to obtain an encoder pulse interval sequence and a corresponding second-order difference change rate sequence; Selecting corresponding zoom type threshold parameters from a preset parameter library according to the pattern classification result, setting an acceleration determination threshold, a constant speed determination threshold, and a deceleration determination threshold respectively, to obtain a state switching threshold combination for the current zoom operation; The second-order difference change rate sequence is combined with the state switching threshold for point-by-point comparison and state transition logic determination. When the second-order difference change rate is greater than the acceleration determination threshold, it is determined to be an accelerated zoom state; when the second-order difference change rate is within the constant speed determination threshold, it is determined to be a constant speed zoom state; when the second-order difference change rate is less than the deceleration determination threshold, it is determined to be a deceleration stop state, thereby obtaining a zoom state sequence; The zoom state sequence is subjected to state jump detection and moment marking. When a jump from the static state to the pre-zoom state, a jump from the pre-zoom state to the accelerated zoom state, a jump from the accelerated zoom state to the constant-speed zoom state, a jump from the constant-speed zoom state to the decelerated stop state, and a jump from the decelerated stop state to the static state is detected, the corresponding timestamps are recorded to obtain a zoom state switching moment mark.

7. The lens recognition method according to claim 6, characterized in that: The continuous pulse interval calculation and second-order difference operation are performed on the envelope first-order derivative sequence to obtain the encoder pulse interval sequence and the corresponding second-order difference change rate sequence, including: Performing extreme value detection and peak screening on the first-order derivative sequence of the envelope, marking the moment when the amplitude change rate of the first-order derivative of the envelope exceeds a preset fluctuation threshold as a pulse peak moment, and obtaining a pulse peak moment sequence; According to the pulse peak time sequence, subtract the i-th pulse peak time from the i+1-th pulse peak time to obtain the i-th pulse interval value, and sequentially calculate the difference between all adjacent pulse peak times based on the pulse interval value to obtain the encoder pulse interval sequence; According to the encoder pulse interval sequence, the difference between adjacent pulse intervals is calculated to obtain a first-order difference sequence, and then the difference between adjacent elements of the first-order difference sequence is calculated to obtain a second-order difference sequence; An element-by-element division operation is performed on the second-order difference sequence and the encoder pulse interval sequence to obtain a second-order difference change rate sequence.

8. The lens recognition method according to claim 1, wherein: The calculating the phase difference trajectory matching degree and generating a zoom switching completion confirmation signal according to the zoom state switching moment mark includes: Performing a time domain sliding window cross-correlation calculation on the first encoder signal and the second encoder signal to obtain a cross-correlation calculation result; Performing peak detection and time delay positioning based on the cross-correlation operation result to obtain a real-time phase difference sequence, and performing time sequence arrangement and trajectory reconstruction on the real-time phase difference sequence to obtain an encoder phase difference trajectory; The encoder phase difference trajectory is subjected to curve fitting and similarity calculation with the pre-stored continuous zoom phase standard trajectory, step zoom phase standard trajectory and fine focus phase standard trajectory respectively, to obtain the trajectory fitting coefficients corresponding to the three modes, and the maximum value of the trajectory fitting coefficient is selected as the phase difference trajectory matching degree; The state jump from the deceleration stop state to the static state is monitored according to the zoom state switching moment mark, and when the state jump is detected to occur and the phase difference trajectory matching degree is greater than a preset matching threshold, a zoom switching completion confirmation signal is generated.

9. A lens recognition device, characterized in that: A lens recognition device for executing the lens recognition method according to any one of claims 1 to 8, wherein the lens recognition device comprises: A signal acquisition module is used to acquire signals from a lens focal length encoder to obtain a first encoder signal and a second encoder signal; a detection module, configured to perform envelope detection and pulse detection on the first encoder signal and the second encoder signal to obtain an envelope first-order derivative sequence and an encoder pulse timing characteristic sequence; a calculation module, configured to perform dynamic time warping distance calculation on the encoder pulse timing feature sequence to obtain a mode classification result of the current zoom operation; a determination module, configured to perform state switching determination based on the envelope first-order derivative sequence and the pattern classification result, and obtain a zoom state switching moment mark; A generation module is used to calculate the phase difference trajectory matching degree and generate a zoom switching completion confirmation signal according to the zoom state switching moment mark.

10. A lens, characterized in that: The lens executes the lens recognition method according to any one of claims 1 to 8.