An optical mouse movement trajectory detection method and system

CN122816481APending Publication Date: 2026-09-25DONGGUAN WEIJI ELECTRONICS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610998158.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-06
Publication Date
2026-09-25

AI Technical Summary

Technical Problem

[0005]为解决弱纹理、各向异性纹理下位移检测精度低、轨迹易抖动漂移的技术问题,本发明提出了一种光学鼠标移动轨迹检测方法及系统,能够提高弱纹理、各向异性纹理表面下的位移检测精度和轨迹输出稳定性

Benefits of technology

[0023]本发明通过计算图像梯度信息生成局部能量驱动的各向异性窗函数并进行加窗处理,降低图像边缘截断效应和频谱泄露影响,增强纹理有效区域在位移计算中的贡献;同时构建由全局主梯度轴向方向引导的频域相位可靠性掩码,基于相位散度对频域相位信息进行加权筛选,减少低可靠相位噪声对互功率谱的干扰,提高相位相关矩阵主峰的稳定性;并在整数位移基础上利用残差矩阵的二阶矩协方差矩阵对模型方向尺度参数进行有界自适应调整,使拟合过程适应不同方向上的峰值展宽差异,降低固定对称模型带来的拟合偏差,从而提高复杂纹理表面下帧间位移检测精度,改善光学鼠标移动轨迹输出的稳定性和连续性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122816481A_ABST
    Figure CN122816481A_ABST
Patent Text Reader

Abstract

The present application belongs to the technical field of optical mouse, and particularly relates to an optical mouse moving track detection method and system, which comprises the following steps: collecting two continuous frames of images of an optical mouse sensor, extracting a global main gradient axial direction based on gradient amplitude weighting; performing Fourier transform on the windowed image to obtain an initial cross power spectrum, constructing a frequency domain phase reliability mask, and obtaining a phase correlation matrix after mask weighting and inverse Fourier transform; performing cyclic boundary solution and neighborhood peak fitting based on the main peak of the phase correlation matrix to obtain a sub-pixel level inter-frame displacement vector; and performing time sequence accumulation on the inter-frame displacement vector to generate and output the optical mouse moving track. The present application can improve the displacement detection precision and track output stability on a weak texture and anisotropic texture surface.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of optical mouse technology. More specifically, this invention relates to a method and system for detecting the movement trajectory of an optical mouse. Background Technology

[0002] Optical mice continuously acquire microscopic texture images of the working surface through internal optical sensors, perform displacement matching calculations on adjacent two frames of images to obtain inter-frame displacement, and accumulate to generate the mouse movement trajectory. In the field of image displacement detection, frequency domain-based phase correlation algorithms are widely used for inter-frame displacement estimation due to their good resistance to illumination changes and high computational efficiency.

[0003] Currently, optical mice come into contact with various surfaces such as glass, rough wood, and smooth plastic in practical use. Different surfaces have significant differences in texture distribution, reflectivity, and directional structure. Images acquired by the sensor often suffer from weak texture, local texture degradation, uneven directional structure, or motion blur. Traditional phase correlation methods typically use fixed symmetric window functions to suppress boundary effects, which are difficult to adapt to the anisotropic distribution of local texture energy and gradient direction in images. This can easily weaken effective directional information in texture degradation areas. At the same time, traditional cross-power spectrum calculations generally assign the same weight to the phase information of all frequency components, failing to adequately distinguish the reliability of phase at different frequency points and in different directions. This leads to low-quality phase information participating in the generation of correlation peaks, producing false peaks or peak diffusion, which affects the stability of the initial displacement estimation.

[0004] However, with the development of high-resolution display devices and precision operation scenarios, users have placed higher demands on the accuracy of optical mouse trajectory positioning. Subpixel-level inter-frame displacement estimation has become an important link in improving the smoothness and accuracy of movement trajectory. Existing subpixel displacement estimation mostly relies on symmetrical surface fitting or fixed interpolation models, which usually assume that the decay shape of the correlation peak is consistent in all directions. However, due to the influence of optical system distortion, non-uniform illumination, surface reflection differences, and rapid motion blur, the real correlation peak often exhibits directional broadening, skewness, or non-uniform decay characteristics. Fixed symmetrical models are difficult to fully fit the actual peak shape and are prone to introducing model mismatch errors. Furthermore, the mouse trajectory is formed by the continuous accumulation of a large number of tiny inter-frame displacements. The subpixel error of a single frame will gradually accumulate during long-distance sliding, causing trajectory jitter, drift, or spatial distortion. Therefore, there is an urgent need for an optical mouse movement trajectory detection method that can adapt to texture direction features, filter reliable phase information, and improve the accuracy of subpixel peak fitting. Summary of the Invention

[0005] To address the technical problems of low displacement detection accuracy and easy trajectory jitter and drift under weak textures and anisotropic textures, this invention proposes an optical mouse movement trajectory detection method and system, which can improve the displacement detection accuracy and trajectory output stability under weak textures and anisotropic textures.

[0006] In a first aspect, the present invention provides a method for detecting the movement trajectory of an optical mouse, comprising: S1, acquiring a current frame image and a next frame image continuously collected by an optical mouse sensor, calculating the gradient information of the two frames, generating a local energy-driven anisotropic window function based on the gradient information, windowing the two frames, and extracting the global principal gradient axis direction of the current frame image according to the gradient magnitude weight; S2, performing Fourier transform on the windowed current frame image and the next frame image to calculate the initial cross-power spectrum matrix, constructing a frequency domain phase reliability mask guided by the global principal gradient axis direction, multiplying the frequency domain phase reliability mask with the initial cross-power spectrum matrix, and then performing an inverse Fourier transform to obtain the phase... S3, determine the main peak point in the phase correlation matrix, and perform cyclic boundary calculation on the coordinates of the main peak point to obtain the signed integer pixel displacement. Fit the initial sub-pixel displacement using an asymmetric two-dimensional singer function model in the neighborhood of the cyclic phase correlation matrix corresponding to the main peak point, and calculate the fitting difference to form the residual matrix; S4, calculate the first moment and second moment covariance matrix of the residual matrix, and perform bounded adaptive adjustment of the anisotropic attenuation parameter of the asymmetric two-dimensional singer function model using the second moment covariance matrix, and then perform a second fitting to obtain the final sub-pixel level inter-frame displacement vector. The final sub-pixel level inter-frame displacement vector is then time-series accumulated to generate and output the movement trajectory of the optical mouse.

[0007] By employing the above technical solutions, anisotropic window functions are generated and windowed, which can suppress image boundary truncation effects and spectral leakage, and enhance the signal contribution of the effective texture region. At the same time, the construction of a frequency domain phase reliability mask is guided by the axial direction of the global principal gradient, which can reduce the interference of low-reliability phase noise on the cross-power spectrum and improve the stability of the main peak of the phase correlation matrix. On this basis, by combining asymmetric two-dimensional singer function model fitting and adaptive parameter adjustment based on the second-order moment covariance of the residual matrix, the fitting process can adapt to the peak broadening differences in different directions, thereby effectively improving the sub-pixel level detection accuracy of inter-frame displacement and the stability and continuity of trajectory output under complex texture surfaces.

[0008] Preferably, the step of extracting the global principal gradient axial direction of the current frame image includes: using the Sobel operator to calculate the horizontal and vertical gradients of the current frame image and the next frame image respectively, to obtain the gradient magnitude and gradient direction of each pixel; constructing a local energy distribution based on the gradient magnitude, stretching and deforming the Hamming window in the spatial domain according to the local energy distribution and the local texture axial direction determined by the gradient direction, generating an anisotropic window function with an internal effective region shape that is adapted and forced to decay at the edges; converting the gradient directions of all pixels in the current frame image into axial direction vectors according to the axial equivalence relation, performing a weighted average of the axial direction vectors according to the gradient magnitude, and restoring the global principal gradient axial direction of the current frame image based on the weighted average result; multiplying the anisotropic window function point by point with the pixel grayscale values ​​of the current frame image and the next frame image respectively, to obtain the windowed current frame image and the next frame image.

[0009] By employing the above technical solution, the gradient magnitude and direction are extracted, and the Hamming window is stretched and deformed with local energy distribution to generate an anisotropic window function with internal shape adaptation and forced edge attenuation. The global principal gradient axial direction is extracted by gradient magnitude weighting. This can suppress edge artifacts while preserving the directional features of the texture structure, making the windowing process more consistent with the local texture energy distribution of the image, and providing a higher quality spatial domain input signal for subsequent frequency domain calculations.

[0010] Preferably, the step of calculating the initial cross-power spectrum matrix by performing Fourier transform on the windowed current frame image and the next frame image includes: performing Fast Fourier Transform on the windowed current frame image and the next frame image respectively to obtain the current frame spectrum matrix and the next frame spectrum matrix; obtaining the conjugate matrix of the next frame spectrum matrix; performing a dot product operation on the current frame spectrum matrix and the conjugate matrix to obtain the cross-power spectrum matrix; and normalizing each element of the cross-power spectrum matrix by dividing it by the element's amplitude to obtain the initial cross-power spectrum matrix.

[0011] By adopting the above technical solution, performing a fast Fourier transform on the windowed image and calculating the cross power spectrum matrix, and then obtaining the initial cross power spectrum matrix through amplitude normalization, it is possible to shield the interference caused by fluctuations in illumination brightness and attenuation of global contrast, and compress the frequency domain information to a unit ring containing only phase information, thereby improving the stability of displacement estimation to illumination changes.

[0012] Preferably, the construction of the frequency domain phase reliability mask guided by the global principal gradient axis direction includes: normalizing the initial cross-power spectrum matrix and extracting the phase angle of each coordinate point in the frequency domain; establishing an elliptical neighborhood with the major axis orthogonal to the global principal gradient axis direction, centered on any coordinate point in the frequency domain; calculating the circular square difference of the phase angles of all points in the elliptical neighborhood relative to the phase angle of the center point, as the phase divergence of the coordinate points; mapping the phase divergence to mask weights using an exponential decay function, where the smaller the phase divergence, the closer the mask weights are to 1, and the larger the phase divergence, the closer the mask weights are to 0, thus obtaining the frequency domain phase reliability mask composed of the weights of each coordinate point.

[0013] By adopting the above technical solution, an orthogonal elliptical neighborhood is established guided by the axial direction of the global principal gradient. The circular square difference of the phase angle in the neighborhood is calculated as the phase divergence. The phase divergence is mapped to mask weights through an exponential decay function. This can effectively distinguish the reliability of phase information in the frequency domain, keep the frequency points corresponding to stable structural features high weights, suppress low-quality phase information at noise or diffraction divergence points, and improve the identification ability and positioning accuracy of the main peak of the phase correlation matrix.

[0014] Preferably, obtaining the initial sub-pixel displacement and calculating the fitting difference to form a residual matrix includes: traversing the phase correlation matrix to find the coordinate point with the largest amplitude as the main peak point; performing cyclic boundary calculation on the coordinates of the main peak point according to the width and height of the phase correlation matrix to obtain the horizontal and vertical signed integer pixel displacements; extracting a pixel window of size 3x3 or 5x5 as a neighborhood with the coordinates of the main peak point in the phase correlation matrix as the center, according to the cyclic boundary method; performing initial surface fitting on the pixel amplitudes in the neighborhood using the basic form of the asymmetric two-dimensional Singer function model, wherein the anisotropic attenuation parameter is taken as a preset neutral value; determining the sub-pixel offset relative to the main peak point according to the coordinates of the continuous function extremum point obtained from the initial surface fitting, and combining the sub-pixel offset with the signed integer pixel displacement to obtain the initial sub-pixel displacement.

[0015] By adopting the above technical solution, signed integer pixel displacements are obtained, and initial sub-pixel displacements are obtained by first-time surface fitting using an asymmetric two-dimensional Singer function model in the neighborhood of the main peak point. The displacement direction can be correctly analyzed by utilizing the cyclic boundary characteristics. At the same time, by leveraging the approximation capability of the Singer function model for the main peak shape, continuous sub-pixel-level position information is extracted from the discrete phase correlation matrix, providing accurate iterative initial values ​​for subsequent adaptive quadratic fitting.

[0016] Preferably, the calculation of the fitting difference to form a residual matrix includes: calculating the difference between the actual amplitude of each pixel in the neighborhood and the fitting amplitude calculated by the two-dimensional Singer function model to form a residual matrix.

[0017] Preferably, the calculation of the first moment and second moment covariance matrix of the residual matrix includes: normalizing the absolute residual values ​​in the residual matrix to construct a two-dimensional probability density function; calculating the expected values ​​of the two-dimensional probability density function in the horizontal and vertical directions, and using them as the first moment to set the centroid of the residual; and calculating the second central moment of the two-dimensional probability density function about the centroid of the residual to construct the second moment covariance matrix.

[0018] Preferably, obtaining the final sub-pixel level inter-frame displacement vector includes: performing eigenvalue decomposition on the second-order moment covariance matrix to obtain the eigenvector corresponding to the largest eigenvalue as the error principal axis direction; determining the parameter adjustment factor of the asymmetric two-dimensional Singer function model in the error principal axis direction based on the ratio of the largest to the smallest eigenvalue; using the parameter adjustment factor to perform bounded adaptive adjustment on the anisotropic attenuation parameter of the asymmetric two-dimensional Singer function model in the error principal axis direction; using the initial sub-pixel displacement as the initial value for iteration, performing nonlinear least squares fitting on the neighborhood data of the phase correlation matrix corresponding to the main peak point using the asymmetric two-dimensional Singer function model after adjusting the attenuation parameter; determining the sub-pixel offset relative to the main peak point based on the coordinates of the extreme point after the fitting convergence, and synthesizing the sub-pixel offset with the signed integer pixel displacement as the final sub-pixel level inter-frame displacement vector.

[0019] Preferably, the step of generating and outputting the movement trajectory of the optical mouse by time-series accumulation of the final subpixel-level inter-frame displacement vector includes: setting the absolute spatial position of the optical mouse at time 0 as the origin of the trajectory; converting the final subpixel-level inter-frame displacement vector obtained from the current frame image to the next frame image into a distance vector, with the conversion coefficient determined by the resolution of the optical mouse sensor; successively accumulating the distance vector calculated in each frame onto the position coordinates of the previous moment in the time series to obtain the absolute spatial coordinates of the optical mouse at the current moment; combining and connecting all the absolute spatial coordinates in the time series to generate the movement trajectory of the optical mouse, and outputting the movement trajectory to the display interface of the test terminal for display.

[0020] Secondly, the present invention provides an optical mouse movement trajectory detection system, including a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the above-mentioned optical mouse movement trajectory detection method is implemented.

[0021] By adopting the above technical solution, a computer program is generated from the above-mentioned optical mouse movement trajectory detection method and stored in the memory so that it can be loaded and executed by the processor. In this way, a terminal device can be made based on the memory and the processor for convenient use.

[0022] The present invention has the following beneficial effects:

[0023] This invention generates a locally energy-driven anisotropic window function by calculating image gradient information and performs windowing processing to reduce image edge truncation effects and spectral leakage, thereby enhancing the contribution of the effective texture region in displacement calculation. Simultaneously, it constructs a frequency-domain phase reliability mask guided by the axial direction of the global principal gradient, and performs weighted filtering of frequency-domain phase information based on phase divergence to reduce the interference of low-reliability phase noise on the cross-power spectrum and improve the stability of the main peak of the phase correlation matrix. Furthermore, based on integer displacements, it uses the second-order moment covariance matrix of the residual matrix to perform bounded adaptive adjustment of the model's directional scale parameters, enabling the fitting process to adapt to peak broadening differences in different directions, reducing fitting bias caused by the fixed symmetric model, thus improving the accuracy of inter-frame displacement detection on complex textured surfaces and enhancing the stability and continuity of optical mouse movement trajectory output.

[0024] Furthermore, this invention employs the Sobel operator to extract gradient magnitude and direction, stretches and deforms the Hamming window using local energy distribution to generate an anisotropic window function with an internally adapted shape and forced edge attenuation, and extracts the global principal gradient axial direction according to gradient magnitude weights. This can suppress edge artifacts while preserving the directional features of the texture structure, providing a higher quality spatial domain input signal for subsequent frequency domain calculations. An initial cross-power spectrum matrix is ​​obtained through magnitude normalization, shielding the interference of illumination brightness fluctuations and global contrast attenuation, improving the robustness of displacement estimation to illumination changes. An orthogonal elliptical neighborhood is established guided by the global principal gradient axial direction, and the phase divergence is calculated. A frequency domain phase reliability mask is generated through exponential decay mapping, effectively distinguishing the reliability of phase information in the frequency domain and improving the identification ability and positioning accuracy of the main peak of the phase correlation matrix. Signed integer pixel displacements are obtained using cyclic boundary calculation, and an initial sub-pixel displacement is obtained by using an asymmetric two-dimensional Singer function model in the neighborhood of the main peak point. Continuous sub-pixel level position information is extracted from the discrete phase correlation matrix, providing accurate iterative initial values ​​for subsequent adaptive quadratic fitting. Attached Figure Description

[0025] Figure 1 This is a flowchart of an optical mouse movement trajectory detection method; Figure 2 This is a grayscale illustration of an anisotropic window function generated by local energy driving. Figure 3 It is a two-dimensional grayscale distribution map of sub-pixel peak values ​​fitted by the Singer function within the neighborhood of integer pixel displacement; Figure 4 This is a bar chart comparing the absolute deviation of the trajectory endpoints of the benchmark algorithm and the algorithm proposed in this invention on different surface materials. Detailed Implementation

[0026] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are some embodiments of the present invention, but not all embodiments.

[0027] This invention discloses a method for detecting the movement trajectory of an optical mouse, referring to... Figure 1 This includes steps S1-S4: S1. Acquire the current frame image and the next frame image continuously collected by the optical mouse sensor, calculate the gradient information of the two frames, generate a local energy-driven anisotropic window function based on the gradient information, perform windowing processing on the two frames, and extract the global principal gradient axis direction of the current frame image according to the gradient magnitude weight.

[0028] The optical mouse continuously captures images of the desktop texture using a complementary metal-oxide-semiconductor (CMOS) image sensor located at the bottom, obtaining the current frame image and the next frame image, converted into grayscale matrices. The Sobel operator is used to perform one-dimensional spatial convolution operations on the current and next frame images in the horizontal and vertical directions, respectively, to calculate the horizontal and vertical gradient matrices. The square root of the sum of the squares of corresponding elements in the horizontal and vertical gradient matrices is calculated using the Pythagorean theorem to obtain the gradient magnitude matrix. The ratio of the vertical gradient to the horizontal gradient is calculated using the arctangent function arctan² to obtain the gradient direction matrix. Finally, the energy matrix is ​​obtained by squaring the elements of the gradient magnitude matrix.

[0029] A Gaussian blur function is used to smooth and filter the energy matrix to extract the local energy distribution matrix. Based on the standard two-dimensional Hamming window function, the values ​​of the local energy distribution matrix are read pixel by pixel. When the local energy is greater than a set threshold, the local texture axis direction orthogonal to the gradient axis direction of the corresponding pixel is determined, and the Hamming window is stretched and deformed along the local texture axis direction to generate an anisotropic window function matrix whose major axis is adapted to the local texture structure. The anisotropic window function matrix is ​​multiplied element-wise with the current frame image matrix and the next frame image matrix to complete the windowing process. The gradient directions of all pixels in the current frame image are converted into axial direction vectors according to the axial equivalence relationship. The corresponding gradient magnitudes are used as weights for weighted averaging, and the global principal gradient axis direction of the current frame image is restored based on the weighted averaging result.

[0030] In an optional embodiment, the steps of acquiring the current frame image and the next frame image continuously collected by the optical mouse sensor, calculating the gradient information of the two frames, generating a local energy-driven anisotropic window function based on the gradient information, windowing the two frames, and extracting the global principal gradient axis direction of the current frame image according to the gradient magnitude include: using the Sobel operator to calculate the horizontal and vertical gradients of the current frame image and the next frame image respectively, obtaining the gradient magnitude and gradient direction of each pixel; constructing a local energy distribution based on the gradient magnitude, using the Hamming window as a reference, and based on the local energy... The distribution and the local texture axial direction determined by the gradient direction stretch and deform the Hamming window in the spatial domain to generate an anisotropic window function with an internal effective region shape that is adapted and forced to decay at the edges. The gradient directions of all pixels in the current frame image are converted into axial direction vectors according to the axial equivalence relation. The axial direction vectors are weighted and averaged according to the gradient magnitude, and the global principal gradient axial direction of the current frame image is restored based on the weighted average result. The anisotropic window function is multiplied point by point with the pixel gray values ​​of the current frame image and the next frame image to obtain the windowed current frame image and the next frame image.

[0031] Taking a 32×32 pixel resolution image continuously acquired by an optical mouse sensor as an example, the image is convolved using a 3×3 horizontal Sobel convolution kernel, such as [-1,0,1;-2,0,2;-1,0,1], and a vertical Sobel convolution kernel, respectively, to obtain the horizontal gradient matrix. and vertical gradient matrix The gradient magnitude M of each pixel is calculated as follows: and The square root of the sum of squares, and the gradient direction angle θ, are equal to the direction angle calculated using the arctangent function. The gradient magnitude M is normalized to the [0,1] interval to construct a local energy distribution map. Based on the standard two-dimensional Hamming window function, the Hamming window is geometrically stretched in the spatial domain according to the clustering region of the local energy distribution and the direction angle θ. If the gradient axis direction corresponding to the local energy is 45°, then the 135° direction orthogonal to this gradient axis direction is taken as the local texture axis direction, and the Hamming window size expansion ratio parameter for this local texture axis direction is set to 1.2 to 1.5, for example, 1.3. An attenuation coefficient of 0.7 is input in the direction orthogonal to this local texture axis direction to generate an anisotropic window function with smooth interior, adapted shape, and convergent edges.

[0032] When calculating the global principal gradient axial direction, the gradient directions of all 1024 pixels in the current frame are processed according to axial equivalence relations. For example, the gradient direction angle θ is mapped to a double-angle direction vector (cos2θ, sin2θ). Using the normalized gradient magnitude M as a weighting coefficient, a weighted summation is performed on the axial direction vectors of all pixels to obtain the comprehensive axial vector. Then, half-angle restoration is performed on the direction angle of the comprehensive axial vector to obtain the global principal gradient axial direction angle of the entire image. When the magnitude of the comprehensive axial vector is lower than a preset direction stabilization threshold, the stable direction of the previous frame or the principal direction of the structure tensor can be used as a backup direction. The anisotropic window function 2D mask with deformation characteristics generated above is multiplied element-wise by the image grayscale matrices of the current frame and the next frame, both with a size of 32×32, with grayscale values ​​ranging from 0 to 255. This operation can reduce high-frequency truncation artifacts at the edges of the image and maintain a higher weight signal in texture regions where gradient energy is concentrated. A schematic diagram of the grayscale of the anisotropic window function generated by local energy driving is shown below. Figure 2 As shown.

[0033] S2. Perform Fourier transform on the current frame image and the next frame image after windowing to calculate the initial cross-power spectrum matrix. Construct a frequency domain phase reliability mask guided by the global principal gradient axis direction. Multiply the frequency domain phase reliability mask with the initial cross-power spectrum matrix and then perform an inverse Fourier transform to obtain the phase correlation matrix.

[0034] The Discrete Fourier Transform (DFT) function is used to transform the windowed current frame image and the next frame image from the spatial domain to the frequency domain, obtaining the complex spectrum matrices of the current frame and the next frame, respectively. The conjugate matrix of the next frame's complex spectrum matrix is ​​then calculated. A complex dot product is performed between the conjugate matrices of the current and next frames to calculate the cross-power spectrum matrix, which is then divided element-wise by the amplitude of the cross-power spectrum matrix. An initial cross-power spectrum matrix is ​​obtained through an amplitude normalization algorithm. The phase angle of this matrix is ​​extracted to generate the phase matrix. In a two-dimensional frequency domain coordinate system, an elliptical neighborhood is established centered at each frequency domain coordinate point to be calculated, with its major axis orthogonal to the global principal gradient axis. For each frequency domain coordinate point of the phase matrix within an orthogonal elliptical neighborhood, the circular square difference of the phase angle at each point within the elliptical neighborhood relative to the phase angle at the center point is calculated. This circular square difference is used as the phase divergence value representing local phase consistency. An exponential decay mapping function is established to convert the phase divergence value into a reliability weight coefficient between 0 and 1. The smaller the divergence, the closer the weight is to 1. A frequency domain phase reliability mask matrix with the same dimension as the initial cross-power spectrum matrix is ​​constructed. This mask matrix is ​​then multiplied element-wise with the initial cross-power spectrum matrix using the Hadamard product. The inverse discrete Fourier transform function is called to convert the product result back to the spatial domain, and the absolute value is taken to construct a phase correlation matrix containing displacement peak information.

[0035] In an optional embodiment, the step of calculating the initial cross-power spectrum matrix by performing Fourier transform on the windowed current frame image and the next frame image includes: performing Fast Fourier Transform on the windowed current frame image and the next frame image respectively to obtain the current frame spectrum matrix and the next frame spectrum matrix; obtaining the conjugate matrix of the next frame spectrum matrix; performing a dot product operation on the current frame spectrum matrix and the conjugate matrix to obtain the cross-power spectrum matrix; and normalizing each element of the cross-power spectrum matrix by dividing it by the element's amplitude to obtain the initial cross-power spectrum matrix.

[0036] To improve the computational efficiency of the Fast Fourier Transform (FFT) and enhance the interpolation resolution of the frequency domain discrete grid, the 32×32 image matrices of the current and next frames after windowing are zero-padded in the surrounding edge regions, expanding the dimensions to powers of 2. For example, uniform zero-padding expands the matrix to a 64×64 pixel matrix. The standard two-dimensional FFT algorithm is then called to perform a frequency domain transformation on the zero-padding images, generating a 64×64 complex spectrum matrix of the current frame corresponding to the specified dimensions. and the complex spectrum matrix of the next frame Extract the complex spectrum matrix of the next frame. For each complex element in the matrix, the conjugate complex matrix is ​​calculated by keeping the real part unchanged and inverting the sign of the imaginary part. .

[0037] The complex spectrum matrix of the current frame Conjugate matrix with the next frame Complex point-by-point multiplication is performed on the frequency domain grid to generate a cross-power spectrum matrix R representing the spatiotemporal frequency shift characteristics of two frames of images. During the spectrum normalization process, the absolute amplitude |R| of each complex coordinate grid point in the cross-power spectrum matrix R is traversed and calculated; this is the square root of the sum of the squares of the real and imaginary parts of the complex number. To prevent division-by-zero errors caused by points in dark or zero-frequency regions, a very small stability constant, for example, 0.00001, is input into the denominator of the amplitude normalization. By calculating R / (|R|+0.00001), the amplitude intensity of each point in the complex matrix is ​​mapped and compressed onto a ring with an amplitude of 1, shielding against interference from illumination brightness fluctuations and global contrast attenuation caused by mouse movement, and outputting an initial cross-power spectrum matrix containing only phase information.

[0038] In an optional embodiment, constructing a frequency domain phase reliability mask guided by the global principal gradient axis direction includes: normalizing the initial cross-power spectrum matrix and extracting the phase angle of each coordinate point in the frequency domain; establishing an elliptical neighborhood with its major axis orthogonal to the global principal gradient axis direction, centered on any coordinate point in the frequency domain; calculating the circular square difference of the phase angles of all points in the elliptical neighborhood relative to the phase angle of the center point, as the phase divergence of the coordinate point; and mapping the phase divergence to mask weights using an exponential decay function, where the smaller the phase divergence, the closer the mask weights are to 1, and the larger the phase divergence, the closer the mask weights are to 0, thus obtaining a frequency domain phase reliability mask composed of the weights of each coordinate point.

[0039] After obtaining the normalized initial cross-power spectrum matrix, the arctangent argument parameter of each complex element is extracted. This arctangent argument parameter is then unpacked and constrained within the range of [-π, π] radians, generating a 64×64 phase angle frequency domain mapping map containing 4096 angle values. An arbitrary frequency coordinate grid point is selected as the center anchor point in the mapping map, and a two-dimensional elliptical window neighborhood containing surrounding discrete pixels is established around this anchor point. To adapt to the optical texture deformation characteristics of the mouse sensor, the size of the major semi-axis 'a' of this elliptical neighborhood is set to 3 to 5 discrete pixels, for example, 3, and the size of the minor semi-axis 'b' is set to 1 to 2 pixels, for example, 1. Through manipulation of the mask rotation matrix, the major axis direction of this elliptical geometry is made orthogonal to the global principal gradient axis direction obtained in the previous stage.

[0040] A data traversal is performed on the established orthogonal elliptical neighborhood. The phase angle of each local point contained in the orthogonal elliptical neighborhood is successively subtracted from the central phase angle of the center point to obtain the relative phase deviation difference. Directional statistics are performed on the relative phase deviation, and the average magnitude of the unit complex vector corresponding to the relative phase deviation within the elliptical neighborhood is calculated. The circular square difference is obtained by subtracting the average magnitude from 1. This circular square difference is used as the phase divergence V of the current frequency domain point, and the phase divergence value can be normalized to the [0,1] interval; if the phase consistency is strong, V will approach 0. The exponential decay formula W=exp(-k×V) is applied to complete the nonlinear mapping and allocation of weights. The empirical threshold range of the decay constant k is between 3.0 and 5.0, and for ordinary material surfaces, for example, 4.5 is selected. This mapping mechanism can achieve weight filtering: reducing the frequency weight at background noise or diffraction divergence points, while maintaining a higher mask weight for reliable frequency domain points corresponding to stable structural features, generating a set of two-dimensional smooth real-valued frequency domain phase reliability mask grids.

[0041] S3. Determine the main peak point in the phase correlation matrix, and perform cyclic boundary calculation on the coordinates of the main peak point to obtain the signed integer pixel displacement. Fit the initial sub-pixel displacement in the neighborhood of the cyclic phase correlation matrix corresponding to the main peak point using an asymmetric two-dimensional singer function model, and calculate the fitting difference to form the residual matrix.

[0042] The global extremum optimization function is invoked to traverse each element of the phase correlation matrix, finding the row and column indices of the main peak point with the largest amplitude. Based on the width and height of the phase correlation matrix, a cyclic boundary calculation is performed on the row and column indices of the main peak point to obtain the signed integer pixel displacements in the horizontal and vertical directions of the image. Using the coordinates of the main peak point in the phase correlation matrix as the center, a five-row, five-column submatrix is ​​extracted as the analysis neighborhood according to the cyclic boundary method, constructing the basic form of the asymmetric two-dimensional Singer function model. The anisotropic attenuation parameter in the initial fitting stage is set to a preset neutral value so that it is not modulated according to the residual covariance. The coordinates of the extracted five-row, five-column neighborhood are substituted into this basic form. The asymmetric two-dimensional Singer function model is used to describe the continuous peak shape of the main peak neighborhood of the phase correlation matrix. In one implementation, the model includes peak amplitude coefficients, background bias terms, subpixel offsets, and scale attenuation parameters in different directions. In the initial fitting stage, the scale attenuation parameters in each direction are set to preset neutral values. In the secondary fitting stage, the error principal axis direction and parameter adjustment factor are determined based on the second-order moment covariance matrix of the residual matrix, and the scale attenuation parameters in the corresponding directions are adjusted in a bounded adaptive manner.

[0043] Optionally, the asymmetric two-dimensional Singer function model is based on the two-dimensional Sinc main lobe function. The sub-pixel offset to be solved is subtracted from the horizontal and vertical coordinates respectively and then input into the Sinc function. The main peak broadening is controlled by the scale attenuation parameters in different directions. The scale attenuation parameters are used to limit the attenuation rate of the model's main lobe in the corresponding direction.

[0044] A nonlinear least squares optimization algorithm is used to iteratively solve for the model parameters with the objective of minimizing the squared error between the actual response value and the model prediction value in the neighborhood. The obtained horizontal and vertical bias parameters are the initial sub-pixel displacement compensation amounts in the horizontal and vertical directions. These initial sub-pixel displacement compensation amounts are combined with the signed integer pixel displacements to obtain the initial sub-pixel displacements. The obtained bias parameters are substituted back into the asymmetric two-dimensional Singer function model to calculate the theoretical fitting value for each coordinate point in the five-row, five-column neighborhood. The corresponding theoretical fitting value is then subtracted element-by-element from the actual five-row, five-column submatrix to obtain the two-dimensional bias matrix, which is the residual matrix.

[0045] In an optional embodiment, the step of determining the dominant peak point in the phase correlation matrix, performing cyclic boundary calculation on the coordinates of the dominant peak point to obtain signed integer pixel displacements, fitting an asymmetric two-dimensional Singer function model within the neighborhood of the cyclic phase correlation matrix corresponding to the dominant peak point to obtain initial sub-pixel displacements, and calculating the fitting difference to form a residual matrix includes: traversing the phase correlation matrix to find the coordinate point with the largest amplitude as the dominant peak point; performing cyclic boundary calculation on the coordinates of the dominant peak point according to the width and height of the phase correlation matrix to obtain signed integer pixel displacements in the horizontal and vertical directions; and using the dominant peak point in the phase correlation matrix... Centered on the coordinates, a pixel window of size 3x3 or 5x5 is extracted as the neighborhood according to the cyclic boundary method; the basic form of the asymmetric two-dimensional Singer function model is used to perform initial surface fitting on the amplitude of the pixels in the neighborhood, where the anisotropic attenuation parameter is taken as a preset neutral value; based on the coordinates of the extreme points of the continuous function obtained from the initial surface fitting, the sub-pixel offset relative to the main peak point is determined, and the sub-pixel offset is combined with the signed integer pixel displacement to obtain the initial sub-pixel displacement; the difference between the actual amplitude of each pixel in the neighborhood and the fitted amplitude calculated by the two-dimensional Singer function model is calculated to form a residual matrix.

[0046] After multiplying the weighted frequency-domain phase reliability mask array element-wise with the initial cross-power spectrum matrix, a two-dimensional inverse fast Fourier transform is performed to convert back to the spatial domain, obtaining a 64×64 real phase correlation matrix, i.e., the impulse response correlation plane. A numerical comparison and traversal search is performed within the data plane of the matrix array to extract the extreme point with the largest global absolute amplitude, determining the discrete pixel coordinate system position of the main peak. Assuming the current extreme point coordinates are (15, 17), and the width and height of the phase correlation matrix are both 64, since 15 and 17 are less than half of their corresponding dimensions, the signed integer pixel displacement obtained after cyclic boundary calculation is 15 pixels along the X direction and 17 pixels along the Y direction. If the horizontal coordinate of the main peak is 63, since 63 is greater than half of 64, 63 is subtracted from 64 to obtain a horizontal signed integer pixel displacement of -1; the vertical coordinate is calculated similarly using cyclic boundary calculation. Centered on the coordinates of the main peak in the phase correlation matrix, a discrete data pixel neighborhood of fixed size 3×3 is extracted according to the cyclic boundary method, and these 9 real amplitude data are used as the basic data for sub-pixel interpolation.

[0047] For the extracted 3×3 neighborhood matrix, a surface fitting is performed using the basic form of the asymmetric two-dimensional Sinc model, where the anisotropic attenuation parameter is set to a preset neutral value. Through nonlinear least-squares fitting, the continuous coordinate readings of the extreme points in the continuous domain of the initially fitted model can be calculated, obtaining the fractional offset relative to the main peak point. For example, when the main peak coordinates are (15, 17), the continuous coordinate readings obtained from the initial fitting are (15.25, 17.18), and the sub-pixel offset relative to the main peak point is (0.25, 0.18). This sub-pixel offset is then combined with the signed integer pixel displacement to obtain the initial sub-pixel displacement (15.25, 17.18). Substituting the model parameters corresponding to this initial sub-pixel displacement into the two-dimensional Sinc equation generates the theoretical prediction function surface height amplitude containing 9 positional elements. The predicted amplitude output is then subtracted point-by-point from the 9 actual absolute amplitudes within this neighborhood to obtain a 3×3 residual matrix representing the discrete error of the initial fitting. The Singer function fits the sub-pixel peak two-dimensional grayscale distribution within the neighborhood of integer pixel displacement, as shown below. Figure 3 As shown.

[0048] S4. Calculate the first and second moment covariance matrices of the residual matrix. Use the second moment covariance matrix to perform bounded adaptive adjustment on the anisotropic attenuation parameters of the asymmetric two-dimensional Singer function model, and then perform a second fitting to obtain the final sub-pixel level inter-frame displacement vector. Then, perform time-series accumulation on the final sub-pixel level inter-frame displacement vector to generate and output the movement trajectory of the optical mouse.

[0049] The absolute values ​​of each element in the 5x5 residual matrix are taken and normalized to construct a two-dimensional discrete probability density function. Using the horizontal and vertical coordinates of each pixel position in the neighborhood as independent variables, the expected values ​​of this two-dimensional probability density function in the horizontal and vertical directions are calculated, serving as the centroids of the residuals. The horizontal second-order central moments, vertical second-order central moments, and covariances between the horizontal and vertical coordinates of each neighborhood coordinate relative to the centroids of the residuals are calculated, forming a second-order moment covariance matrix. The eigenvalues ​​and eigenvectors of this second-order moment covariance matrix are calculated, and the eigenvector corresponding to the largest eigenvalue is extracted as the main divergence direction of the residuals.

[0050] The parameter adjustment factor is determined based on the ratio of the largest to the smallest eigenvalue. Following the definition of the anisotropic attenuation parameter in the asymmetric two-dimensional Singer function model, the attenuation parameter along the principal axis of the error is adjusted adaptively with bounded bounds. Using the updated asymmetric two-dimensional Singer function model, the Levenberg-Marquardt algorithm is invoked to iteratively solve the quadratic surface fitting problem on the neighborhood data of the phase correlation matrix corresponding to the main peak point. High-precision horizontal and vertical offset parameters are extracted after the quadratic fitting converges. These offset parameters are then combined with signed integer pixel displacements to synthesize horizontal and vertical sub-pixel-level inter-frame displacement vectors.

[0051] In the main loop of the microcontroller, a global trajectory accumulator variable containing horizontal and vertical coordinates is created. As the optical mouse sensor outputs a frame of image, the newly obtained horizontal subpixel level inter-frame displacement vector and vertical subpixel level inter-frame displacement vector are added to the horizontal and vertical coordinates in the global trajectory accumulator variable, respectively. The absolute position coordinates obtained by the timing accumulation are then output to the host computer operating system through the endpoint transmission function of the Universal Serial Bus (USB) communication protocol, generating and displaying the movement trajectory of the optical mouse on the computer screen.

[0052] In an optional embodiment, the calculation of the first moment and second moment covariance matrix of the residual matrix includes: normalizing the absolute residual values ​​in the residual matrix to construct a two-dimensional probability density function; calculating the expected values ​​of the two-dimensional probability density function in the horizontal and vertical directions, using them as the first moment to set the centroid of the residual; and calculating the second central moment of the two-dimensional probability density function about the centroid of the residual to construct the second moment covariance matrix.

[0053] For the extracted 3×3 residual matrix, the absolute values ​​of 9 elements are taken. The absolute values ​​of the 9 residuals are summed to obtain a total. The absolute values ​​of each point are then divided by the sum to normalize the matrix elements. The normalized result is converted into a two-dimensional discrete probability density function matrix where all values ​​are within [0,1] and the overall integral is 1. The horizontal offset variable of this neighborhood is then... Vertical offset independent variable Set to the spatial range of [-1, 0, 1]. Based on mathematical expectation theory, use... and Multiply by the probability density weights at the corresponding positions and then sum them to obtain the centroids of the horizontal components that describe the distribution bias trend, i.e., the first moment of the expectation and the centroids of the vertical components.

[0054] Obtain the centroid coordinates with directional bias characteristics. For example, assuming the calculated bias is located at (0.08, -0.04), continue to translate each of the 3×3 local coordinate points towards the new centroid, subtract the bias value, square the result, and multiply by the local probability density matrix of the original mesh. Calculate the horizontal and vertical second-order central moments describing the strength of error fluctuations along the X and Y axes, and jointly calculate the cross-correlation covariance central moment term reflecting cross-bias characteristics. These three constitute a 2×2 real symmetric second-order moment covariance matrix with positive semi-definite properties. Due to various aberrations present in optical lenses, residual fluctuations are usually not perfectly circular. Therefore, the two orthogonal eigenvectors extracted by performing eigenparametric analysis on this 2×2 array represent the major and minor axis tilt angles of the error spread caused by the actual environment; simultaneously, the corresponding maximum and minimum eigenvalues ​​represent the degree of error stretching and the scale of dispersion.

[0055] In an optional embodiment, the step of performing bounded adaptive adjustment of the anisotropic attenuation parameters of the asymmetric two-dimensional Singer function model using the second-order moment covariance matrix and then performing a quadratic fitting to obtain the final sub-pixel-level inter-frame displacement vector includes: performing eigenvalue decomposition on the second-order moment covariance matrix to obtain the eigenvector corresponding to the largest eigenvalue as the error principal axis direction; determining the parameter adjustment factor of the asymmetric two-dimensional Singer function model in the error principal axis direction according to the ratio of the largest to the smallest eigenvalue; performing bounded adaptive adjustment of the anisotropic attenuation parameters of the asymmetric two-dimensional Singer function model in the error principal axis direction using the parameter adjustment factor; using the initial sub-pixel displacement as the initial value for iteration, performing nonlinear least squares fitting on the neighborhood data of the phase correlation matrix corresponding to the main peak point using the asymmetric two-dimensional Singer function model after adjusting the attenuation parameters; determining the sub-pixel offset relative to the main peak point based on the coordinates of the extreme point after fitting convergence, and synthesizing the sub-pixel offset with the signed integer pixel displacement as the final sub-pixel-level inter-frame displacement vector.

[0056] Eigenvalue decomposition or singular value decomposition is performed on the 2×2 second-order moment covariance matrix to obtain the maximum eigenvalue, minimum eigenvalue, and corresponding direction vector. The normalized eigenvector coordinate angle corresponding to the maximum eigenvalue is extracted, and this coordinate angle is used as the direction of the principal axis torsion error that is prominent when the current system encounters stray signals and displacement estimation uncertainties. The control factor for asymmetric deformation is determined by calculating the square root of the quotient of the maximum and minimum eigenvalues. If the quotient of the maximum and minimum eigenvalues ​​is 4, the control factor is set to 2.0. Based on the definition of the attenuation parameter in the asymmetric two-dimensional Singer function model, the parameter to be adjusted corresponding to the principal direction with strong error divergence is determined, and the attenuation exponent or scale parameter in this direction is corrected using the parameter adjustment factor. After correction, the attenuation exponent or scale parameter is truncated by preset lower and upper limits, for example, it can be expressed as... ,in, Here, η is the initial attenuation parameter, and η is the parameter adjustment factor. and These are preset lower and upper limits, respectively. Through the above processing, the bias effect of the residual concentration direction on peak position estimation can be suppressed, reducing the risk of sub-pixel displacement misjudgment caused by local fluctuations.

[0057] After parameter adjustment, a nonlinear least-squares fitting algorithm based on the Levenberg-Marquardt method is employed. The initial sub-pixel displacement and its offset relative to the main peak point are used as initial iteration values, substituted into an asymmetric two-dimensional Singer function model with adjusted attenuation parameters. Phase correlation matrix data from real hardware feedback within a 3×3 window around the main peak is also imported into the algorithm. After up to 20 nonlinear iterations and Jacobian partial derivative calculations for correction, the algorithm proceeds until the Euclidean distance of the newly generated floating-point extremum changes between adjacent iteration steps falls within a set 1×10⁻⁶. -4 The iteration stops after the tolerance range is reached. The extracted, relatively stable new extreme point coordinate parameter pairs are calculated as sub-pixel offsets relative to the main peak point and synthesized with signed integer pixel displacements to form the final sub-pixel level displacement vector result for mouse optical tracking.

[0058] In an optional embodiment, the step of generating and outputting the movement trajectory of the optical mouse by time-series accumulation of the final subpixel-level inter-frame displacement vector includes: setting the absolute spatial position of the optical mouse at time 0 as the origin of the trajectory; converting the final subpixel-level inter-frame displacement vector obtained from the current frame image to the next frame image into a distance vector, with the conversion coefficient determined by the resolution of the optical mouse sensor; successively accumulating the distance vector calculated in each frame onto the position coordinates of the previous moment in the time series to obtain the absolute spatial coordinates of the optical mouse at the current moment; combining and connecting all the absolute spatial coordinates in the time series to generate the movement trajectory of the optical mouse, and outputting the movement trajectory to the display interface of the test terminal for display.

[0059] When the mobile test platform or system program's main loop is reset to zero, the mouse's main control MCU sets the time register T, representing the timer, to zero and establishes an initial origin array (0.00, 0.00) in the system RAM, representing a two-dimensional Cartesian pose register in double-precision floating-point format. After each timing loop's calculation is completed, the currently acquired final sub-pixel level inter-frame displacement vector is in pixels or output counts, such as 0.56 pixels or -1.24 pixels, and needs to be scaled. The conversion factor is determined by the optical mouse sensor resolution or a preset calibration relationship; for example, when calibrated to 1000 output counts corresponding to 1 inch displacement, the spatial distance corresponding to a single output count is 1 inch divided by 1000, approximately equal to 0.0254 mm. Multiplying the calculated offset by the aforementioned constant yields the spatial displacement, such as 0.014 mm or -0.031 mm.

[0060] As the sensor continuously acquires images and outputs data, it performs an accumulation operation on the time series, updating the absolute spatial coordinates according to the formula X(t) equals the position X(t-1) of the previous moment plus the displacement of the current frame. The group of fixed-point parameter variables accumulated along with the time series constructs continuous trajectory data. By connecting all the absolute spatial coordinates on the time series, the movement trajectory of the optical mouse is generated. The final stage of the process uses an SPI data backhaul link or USB interface to transmit the trajectory data to the backend analysis host. The computer-based algorithm drawing suite performs line rendering and color reproduction, and the trajectory is drawn and displayed on the test terminal's display interface to characterize the product's control accuracy and trajectory detection precision.

[0061] The experiment used an optical mouse sensor with a resolution of 1000 CPI and a sampling rate of 4000 FPS, coupled with a high-precision robotic arm as the test platform. The robotic arm drove the mouse sensor to perform uniform linear and circular displacement movements at a speed of 20 centimeters per second on three typical test surfaces: a standard matte cloth surface, a highly reflective glass surface, and a rough wooden surface. The experiment established a baseline control group using a conventional algorithm combining a symmetrical Hamming window with a standard two-dimensional Singer function for initial fitting, and a core experimental group using an anisotropic window function and an asymmetric two-dimensional Singer function for secondary fitting based on adjusting the attenuation parameter using the second-order moment covariance matrix.

[0062] Test results show that the root mean square error of subpixel displacement on the standard cloth surface, rough wood surface, and reflective glass surface of the benchmark control group is 0.075 pixels, 0.128 pixels, and 0.352 pixels, respectively, corresponding to absolute deviations of the trajectory endpoints for 10 cm linear motion of 0.95 mm, 2.45 mm, and 5.85 mm, respectively. Using the core experimental group of this invention, the root mean square error of displacement on the above three surfaces is reduced to 0.015 pixels, 0.032 pixels, and 0.085 pixels, respectively, with corresponding absolute deviations of the trajectory endpoints compressed to 0.12 mm, 0.48 mm, and 1.15 mm. Figure 4 As shown.

[0063] Local energy-driven anisotropic windowing helps attenuate high-frequency truncation artifacts at image boundaries and enhances signal weights in textured regions, thereby improving the signal-to-noise ratio in the frequency domain of cross-power spectrum calculations. A nonlinear fitting technique based on the second-order moment covariance extraction error principal axis direction for adjusting anisotropic attenuation parameters compensates for spatial asymmetric distortions caused by lens aberrations and local illumination speckle, reducing overfitting of traditional models to divergent extrema and outputting sub-pixel-level inter-frame displacements and continuous trajectory coordinates that more closely resemble real motion.

[0064] This invention also discloses an optical mouse movement trajectory detection system, including a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement an optical mouse movement trajectory detection method according to the present invention.

[0065] The system also includes other components well known to those skilled in the art, such as communication buses and communication interfaces, the settings and functions of which are known in the art and will not be described in detail here.

[0066] In the description of this specification, "multiple" or "several" means at least two, such as two, three or more, unless otherwise expressly and specifically defined.

Claims

1. A method for detecting the movement trajectory of an optical mouse, characterized in that, include: S1. Acquire the current frame image and the next frame image continuously collected by the optical mouse sensor, calculate the gradient information of the two frames, generate a local energy-driven anisotropic window function based on the gradient information, perform windowing processing on the two frames, and extract the global principal gradient axis direction of the current frame image according to the gradient magnitude weight; S2. Perform Fourier transform on the windowed current frame image and the next frame image to calculate the initial cross-power spectrum matrix, construct a frequency domain phase reliability mask guided by the global principal gradient axis direction, multiply the frequency domain phase reliability mask with the initial cross-power spectrum matrix, and then perform an inverse Fourier transform to obtain the phase correlation matrix; S3. In the phase correlation matrix... In step S4, the main peak point is determined, and the coordinates of the main peak point are solved by cyclic boundary calculation to obtain the signed integer pixel displacement. The initial sub-pixel displacement is obtained by fitting an asymmetric two-dimensional Singer function model in the neighborhood of the cyclic phase correlation matrix corresponding to the main peak point, and the fitting difference is calculated to form the residual matrix. In step S5, the first moment and second moment covariance matrix of the residual matrix are calculated. The anisotropic attenuation parameter of the asymmetric two-dimensional Singer function model is adjusted by bounded adaptive adjustment using the second moment covariance matrix and then a second fitting is performed to obtain the final sub-pixel level inter-frame displacement vector. The final sub-pixel level inter-frame displacement vector is accumulated in time to generate and output the movement trajectory of the optical mouse.

2. The method according to claim 1, characterized in that, The step of extracting the global principal gradient axial direction of the current frame image includes: using the Sobel operator to calculate the horizontal and vertical gradients of the current and next frame images respectively, obtaining the gradient magnitude and gradient direction of each pixel; constructing a local energy distribution based on the gradient magnitude, stretching and deforming the Hamming window in the spatial domain according to the local energy distribution and the local texture axial direction determined by the gradient direction, generating an anisotropic window function with an internal effective region shape that is adapted and forced to decay at the edges; converting the gradient directions of all pixels in the current frame image into axial direction vectors according to the axial equivalence relation, performing a weighted average of the axial direction vectors according to the gradient magnitude, and restoring the global principal gradient axial direction of the current frame image based on the weighted average result; multiplying the anisotropic window function point by point with the pixel grayscale values ​​of the current and next frame images respectively, to obtain the windowed current and next frame images.

3. The method according to claim 1, characterized in that, The step of calculating the initial cross-power spectrum matrix by performing Fourier transform on the windowed current frame image and the next frame image includes: Perform Fast Fourier Transform on the windowed current frame image and the next frame image respectively to obtain the current frame spectrum matrix and the next frame spectrum matrix; Find the conjugate matrix of the spectrum matrix in the next frame; Perform a dot product operation between the current frame spectrum matrix and the conjugate matrix to obtain the cross power spectrum matrix; Normalize the cross power spectrum matrix by dividing each element by its magnitude to obtain the initial cross power spectrum matrix.

4. The method according to claim 1, characterized in that, The construction of the frequency domain phase reliability mask guided by the global master gradient axial direction includes: The initial cross-power spectrum matrix is ​​normalized, and the phase angle of each coordinate point in the frequency domain is extracted. An elliptical neighborhood is established with any coordinate point in the frequency domain as the center, and the major axis is orthogonal to the direction of the global principal gradient axis. Calculate the circular square difference of the phase angle of all points in the elliptical neighborhood relative to the phase angle of the center point, and use it as the phase divergence of the coordinate points; The phase divergence is mapped to mask weights using an exponential decay function. The smaller the phase divergence, the closer the mask weights are to 1, and the larger the phase divergence, the closer the mask weights are to 0, thus obtaining a frequency domain phase reliability mask composed of the weights of each coordinate point.

5. The method according to claim 2 or 4, characterized in that, The process of obtaining the initial sub-pixel displacement and calculating the fitting difference to form a residual matrix includes: traversing the phase correlation matrix to find the coordinate point with the largest amplitude as the main peak point; performing cyclic boundary calculation on the coordinates of the main peak point according to the width and height of the phase correlation matrix to obtain the horizontal and vertical signed integer pixel displacements; extracting a pixel window of size 3x3 or 5x5 as a neighborhood with the coordinates of the main peak point in the phase correlation matrix as the center, according to the cyclic boundary method; performing initial surface fitting on the pixel amplitudes in the neighborhood using the basic form of the asymmetric two-dimensional Singer function model, wherein the anisotropic attenuation parameter is taken as a preset neutral value; determining the sub-pixel offset relative to the main peak point based on the coordinates of the continuous function extremum point obtained from the initial surface fitting, and combining the sub-pixel offset with the signed integer pixel displacement to obtain the initial sub-pixel displacement.

6. The method according to claim 5, characterized in that, The calculation of the fitting difference constitutes the residual matrix, including: The difference between the actual amplitude of each pixel in the neighborhood and the fitted amplitude calculated by the two-dimensional Singer function model is used to form the residual matrix.

7. The method according to claim 1, characterized in that, The calculation of the first and second moments covariance matrices of the residual matrix includes: The absolute residual values ​​in the residual matrix are normalized to construct a two-dimensional probability density function; Calculate the expected values ​​of the two-dimensional probability density function in the horizontal and vertical directions, and use them as the first moment to set the centroid of the residual; Calculate the second central moment of the two-dimensional probability density function about the residual centroid, and construct the second moment covariance matrix.

8. The method according to claim 1, characterized in that, The process of obtaining the final sub-pixel level inter-frame displacement vector includes: performing eigenvalue decomposition on the second-order moment covariance matrix to obtain the eigenvector corresponding to the largest eigenvalue as the direction of the error principal axis; determining the parameter adjustment factor of the asymmetric two-dimensional Singer function model in the direction of the error principal axis based on the ratio of the largest to the smallest eigenvalue; using the parameter adjustment factor to perform bounded adaptive adjustment on the anisotropic attenuation parameter of the asymmetric two-dimensional Singer function model in the direction of the error principal axis; using the initial sub-pixel displacement as the initial value for iteration, performing nonlinear least squares fitting on the neighborhood data of the phase correlation matrix corresponding to the main peak point using the asymmetric two-dimensional Singer function model after adjusting the attenuation parameter; determining the sub-pixel offset relative to the main peak point based on the coordinates of the extreme point after the fitting convergence, and synthesizing the sub-pixel offset with the signed integer pixel displacement as the final sub-pixel level inter-frame displacement vector.

9. The method according to claim 1, characterized in that, The step of generating and outputting the movement trajectory of the optical mouse by temporally accumulating the final sub-pixel level inter-frame displacement vectors includes: Set the absolute spatial position of the optical mouse at time 0 as the origin of the trajectory; The final subpixel-level inter-frame displacement vector obtained from the current frame image to the next frame image is converted into a distance vector, and the conversion coefficient is determined by the resolution of the optical mouse sensor. The distance vector calculated in each frame is successively added to the position coordinates of the previous moment in the time series to obtain the absolute spatial coordinates of the optical mouse at the current moment. By combining and connecting all the absolute spatial coordinates in the time series, the movement trajectory of the optical mouse is generated, and the movement trajectory is output to the display interface of the test terminal for display.

10. An optical mouse movement trajectory detection system, characterized in that, include: A processor and a memory, wherein the memory stores computer program instructions that, when executed by the processor, implement the optical mouse movement trajectory detection method according to any one of claims 1-9.