A method for constructing a Lu Xiu embroidery track reconstruction large model based on motion capture
By using an adaptive dual-threshold Kalman filter and a frequency-domain hybrid range attention embroidery sequence modeling network, combined with an asynchronous parallel pipeline multi-channel inference architecture, the problem of frequency overlap between physiological tremor pseudo-signals and real stitch motion signals in embroidery stitch motion signals was solved, achieving high-precision and real-time stitch trajectory reconstruction.
Patent Information
- Application Number
- CN202611348562.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-02
- Publication Date
- 2026-11-24
AI Technical Summary
In existing technologies, the physiological tremor pseudo-signals in embroidery stitch motion signals highly overlap with the real stitch motion signals in terms of frequency, resulting in a significant decrease in the accuracy of long sequence trajectory reconstruction.
An adaptive dual-threshold Kalman filter is used to purify six-DOF inertial signals. Combined with a frequency domain hybrid range attention embroidery sequence modeling network and an asynchronous parallel pipeline multi-channel inference architecture, high-precision reconstruction of needle traces is achieved through multimodal fusion feature sequences and a two-layer game model.
It effectively separates physiological tremor spurs from real needle movement signals, improves the accuracy of long sequence trajectory reconstruction, and achieves millisecond-level real-time trajectory prediction and visualization output.
Smart Images

Figure CN123159537A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of industrial large-scale model technology, specifically, it relates to a method for constructing a large-scale model of Lu embroidery trajectory reconstruction based on motion capture. Background Technology
[0002] As an important part of traditional Chinese handicrafts, Lu embroidery's digital reconstruction of its needlework trajectories is of great significance in the fields of cultural heritage protection and intelligent manufacturing. Existing technologies typically combine inertial sensors with Kalman filtering to collect the operator's hand motion signals and suppress noise. Then, recurrent neural networks or standard transformer models are used to model the collected motion sequences to reconstruct the needlework trajectory coordinates. This method is applicable to scenarios with short trajectories and large operator movements. However, in embroidery, the operator's hand movements while holding the needle are delicate and extremely short. The high-frequency jitter signals (typically 8 to 12 Hz) caused by physiological tremors are highly similar in amplitude distribution to the actual needlework motion signals (typically 0.5 to 4 Hz). Traditional single-threshold Kalman filtering cannot accurately distinguish between the two types of signals, resulting in a large amount of pseudo-signals from physiological tremors mixing into the valid signal sequence. When modeling ultra-long embroidery motion sequences, the cumulative effect of these pseudo-signals causes the trajectory reconstruction error to continuously amplify as the sequence length increases. In other words, existing technologies have a technical problem where the pseudo-signal of physiological tremor in the embroidery stitch motion signal highly overlaps with the real stitch motion signal in frequency, leading to a serious decrease in the accuracy of long sequence trajectory reconstruction. Summary of the Invention
[0003] In view of this, the present invention provides a method for constructing a large model for reconstructing the trajectory of Lu embroidery based on motion capture, which can solve the technical problem in the prior art where the physiological tremor pseudo signal in the embroidery stitch motion signal highly overlaps with the real stitch motion signal in frequency, resulting in a serious decrease in the accuracy of long sequence trajectory reconstruction.
[0004] This invention is implemented as follows: This invention provides a method for constructing a large model of Lu embroidery trajectory reconstruction based on motion capture, including the following steps:
[0005] An array of motion capture sensors is deployed on the embroidery operator's hand and the needle-holding area to collect the original six-degree-of-freedom inertial signals of the needlework. An adaptive dual-threshold Kalman filter is applied to the original six-degree-of-freedom inertial signals to remove physiological tremor pseudo signals and output the purified needlework motion signal sequence.
[0006] The purified needle motion signal sequence is subjected to segmented discrete cosine transform, and the low-frequency components of each segment are extracted as frequency domain compression features. These features are then fused with time domain posture and motion features to construct a multimodal fusion feature sequence.
[0007] Using a multimodal fusion feature sequence as input, a frequency domain hybrid range attention embroidery sequence modeling network is invoked to perform long-sequence modeling and prediction of the entire stitch trajectory, and output a trajectory prediction feature sequence.
[0008] An adaptive attention resource allocation function is used to dynamically adjust the ratio of neuron activation resource allocation between local dense window attention and global sparse anchor attention in a frequency domain mixed-range attention embroidery sequence modeling network.
[0009] We construct an upper-level game model with trajectory reconstruction accuracy as the objective and a lower-level game model with inference delay as the objective. We then solve the computation graph segmentation scheme between trajectory reconstruction and real-time inference through a two-level game.
[0010] Based on the two-layer game computation graph segmentation scheme, an asynchronous parallel pipeline multi-channel inference architecture is deployed. A lock-free circular buffer queue is used to realize asynchronous data transfer between layers, and millisecond-level real-time trajectory prediction and visualization output are achieved.
[0011] Specifically, the adaptive dual-threshold Kalman filter sets a high threshold and a low threshold for the observation noise covariance matrix based on the joint statistical distribution of the speed and acceleration of the needlework movement. When the Mahalanobis distance of the observation residual falls into the low threshold range, it is determined to be a pseudo signal of physiological tremor and is suppressed. When the Mahalanobis distance of the observation residual is between the low threshold and the high threshold, it is determined to be a real needlework movement signal and is retained. When the Mahalanobis distance of the observation residual exceeds the high threshold, it is determined to be abnormal noise and is subjected to forced zeroing truncation.
[0012] Specifically, the high and low thresholds are determined by conducting multiple comparative experiments on the physiological tremor frequency range and the actual needle movement frequency range of different operators, using the valley point of the frequency distribution histogram as the dividing line.
[0013] Specifically, the piecewise discrete cosine transform involves dividing the purified needle motion signal sequence into segments with a fixed window length, then independently performing a discrete cosine transform on each segment to project the signal into the frequency domain. The window length is set to a threshold value, and the number of low-frequency components retained is set to a threshold value. Both the window length threshold and the threshold value for the number of low-frequency components retained are determined through inflection point analysis of experimental curves showing the mean square error of the reconstructed trajectory and the true trajectory as a function of the number of retained coefficients.
[0014] Specifically, the construction of the multimodal fusion feature sequence involves concatenating the low-frequency frequency domain compressed features of each segment with the posture and action feature vectors within the corresponding time domain window according to the channel dimension, forming a fusion feature vector of a unified dimension, and then arranging them along the time axis to form a fusion feature sequence.
[0015] The core attention layer of the frequency domain hybrid range attention embroidery sequence modeling network includes a local dense window attention submodule and a global sparse anchor attention submodule. The local dense window attention submodule performs complete attention calculation on the preceding and following neighborhoods of each frame. The global sparse anchor attention submodule samples global anchor frames at equal intervals from the entire sequence and approximates the correlation weight matrix between the current frame and the global anchors through a bilinear kernel function. The outputs of the two are weighted and superimposed by a gated fusion layer, and the gate weights are determined by the frequency domain energy entropy value of the current frame.
[0016] Among them, the feedforward subnetwork of the frequency domain hybrid range attention embroidery sequence modeling network adopts a dynamic feedforward routing design. The prediction confidence of the stitch corresponding to the current frame is used as the routing independent variable. When the confidence is higher than the confidence threshold, the intermediate hidden layer is skipped and directly transmitted to the output projection layer. When the confidence is lower than the confidence threshold, the complete two-layer feedforward calculation path is activated. The confidence threshold is determined by joint experiments on the inference frame rate and reconstruction accuracy under different thresholds.
[0017] Among them, the frequency domain hybrid range attention embroidery sequence modeling network alleviates the deep gradient vanishing problem by using a long-span residual dense jump matrix. A cross-layer direct connection channel is set every few layers. The number of cross-layers is determined by the stable range of the experimental curve of gradient norm changing with depth. The cross-layer weights are initialized to zero and gradually activated during training. At the same time, a layer-by-layer gradient norm pruning mechanism is introduced. The pruning upper limit is determined by experimental analysis of the oscillation amplitude of the training loss curve.
[0018] Specifically, the adaptive attention resource allocation function is based on the frequency domain energy entropy value of the current frame. Confidence of needle prediction for the current sequence segment The maximum singular value of the association weight matrix with the current global sparse anchor attention submodule Calculate the attention resource allocation index using the input. , ,in For dimensional coefficients, based on With high matching threshold Low ratio threshold The size relationship is used to dynamically determine the ratio of neuron activations in the local dense window attention submodule to those in the global sparse anchor point attention submodule.
[0019] Among them, the frequency domain energy entropy value The calculation specifically involves calculating the Shannon entropy of the normalized energy distribution of the frequency domain feature vector of the current frame. A high entropy value indicates that the spectrum of needle movement is diffuse, while a low entropy value indicates that the spectrum of needle movement is concentrated.
[0020] Wherein, the objective function of the upper-level game model The input includes the number of graph segments to be calculated. Layer allocation vector for each segment Sequence length of the feature sequence fused with multimodal features The constraints are And the number of layers in each segment Not less than the lower limit of the number of layers; the objective function of the lower-level game model The input includes the number of graph segments to be calculated. Number of parallel threads in each flow channel The number of buffer slots in the lockless circular buffer queue The constraints are Not exceeding the maximum number of parallel threads in the hardware and Not less than .
[0021] Specifically, the two-layer game involves iteratively solving for the optimal upper-layer partitioning scheme and the optimal lower-layer resource allocation until the objective function converges, and determining the number of partitioning segments in the upper-layer model. The number of parallel channels in the lower-level model is determined, and the inference delay feedback of the lower-level model constrains the maximum number of segments allowed in the upper-level model.
[0022] Specifically, the asynchronous parallel pipeline multi-channel inference architecture divides the frequency domain mixed range attention embroidery sequence modeling network into multiple sub-graph segments according to the computation graph segmentation scheme obtained by the two-layer game. Each sub-graph segment is computed in parallel on an independent channel. Intermediate feature tensors are passed between sub-graph segments through a lock-free circular buffer queue. Producer and consumer threads read and write the head and tail pointers of the queue through atomic operations, eliminating the thread blocking bottleneck of inter-layer synchronization waiting.
[0023] The training of the frequency domain hybrid range attention embroidery sequence modeling network specifically uses the mean squared error loss function as the main loss term and the trajectory topological continuity penalty term as the auxiliary loss term. The AdamW optimizer is used for parameter updates, and the learning rate is gradually decayed through cosine annealing scheduling. The mean squared error of the trajectory is calculated on the validation set every training cycle, and early stopping is based on the validation set error no longer decreasing.
[0024] Specifically, the window length threshold is set to 200 to 300 steps, the low-frequency component retention threshold is set to 28 to 36 frequency coefficients, the neighborhood step count for the local dense window attention submodule is set to 14 to 18 steps, the global anchor frame count is set to 58 to 70, the confidence threshold is set to 0.87 to 0.93, and the pruning upper limit is set to 0.8 to 1.2. Take the upper quartile of the experimental distribution. Take the lower quartile of the experimental distribution, and set the initial learning rate to... to The interval between direct cross-floor passages is 3 to 5 floors.
[0025] This invention employs an adaptive dual-threshold Kalman filter to purify the original six-degree-of-freedom inertial signal. Based on the joint statistical distribution of needlework speed and acceleration, two observation noise covariance thresholds (high and low) are dynamically set. Mahalanobis distance is used to identify physiological tremor spurious signals, genuine needlework motion signals, and abnormal noise, achieving accurate separation of these three types of signals. This ensures the reliability of the input data received by subsequent frequency domain modeling and long-sequence attention mechanisms. The introduction of the dual-threshold mechanism ensures that the filtering decision boundary directly corresponds to the frequency distribution of the actual signal, avoiding the accumulation of misjudgments caused by fixed thresholds in single-threshold methods. This prevents the trajectory reconstruction error from continuously amplifying with increasing sequence length. In summary, this invention solves the technical problem mentioned in the background art: the high frequency overlap between physiological tremor spurious signals and genuine needlework motion signals in embroidery needlework motion signals leads to a severe decrease in the accuracy of long-sequence trajectory reconstruction. Attached Figure Description
[0026] Figure 1 This is a flowchart of the method of the present invention.
[0027] Figure 2 This is a comparison of the needle movement signals before and after filtering.
[0028] Figure 3 Modeling network data flow graph for frequency domain mixed-range attention embroidery sequence.
[0029] Figure 4 This is a schematic diagram of an asynchronous parallel pipeline multichannel inference architecture.
[0030] Figure 5 This is the iterative convergence curve of the two-layer game. Detailed Implementation
[0031] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below.
[0032] like Figure 1 The diagram shown is a flowchart of a method for constructing a large model of Lu embroidery trajectory reconstruction based on motion capture, provided by the present invention. This method includes the following steps:
[0033] S01. An array of motion capture sensors is deployed on the hands and needle-holding area of the embroidery operator to collect the original six-degree-of-freedom inertial signals of the needlework movement. An adaptive double-threshold Kalman filter is applied to the original signals to remove physiological tremor pseudo signals and output the purified needlework movement signal sequence.
[0034] S02. Perform piecewise discrete cosine transform on the purified needle motion signal sequence, extract the low-frequency components of each segment as frequency domain compression features, and fuse them with time domain posture and motion features to construct a multimodal fusion feature sequence.
[0035] S03. Using the constructed multimodal fusion feature sequence as input, the frequency domain hybrid range attention embroidery sequence modeling network is called to perform long sequence modeling and prediction of the entire needle trajectory, and output the trajectory prediction feature sequence.
[0036] S04. The ratio of neuron activation resource allocation between local dense window attention and global sparse anchor point attention in the frequency domain mixed range attention embroidery sequence modeling network is dynamically adjusted using an adaptive attention resource allocation function.
[0037] S05. Construct an upper-level game model with trajectory reconstruction accuracy as the objective and a lower-level game model with inference delay as the objective. Solve the computation graph segmentation scheme between trajectory reconstruction and real-time inference through two-level game theory.
[0038] S06. Based on the two-layer game computation graph segmentation scheme, deploy an asynchronous parallel pipeline multi-channel inference architecture, realize asynchronous data transfer between layers through a lock-free circular buffer queue, and complete millisecond-level real-time trajectory prediction and visualization output.
[0039] The specific principle of the adaptive dual-threshold Kalman filter is as follows: based on the joint statistical distribution of the speed and acceleration of the needlework movement, two dynamic thresholds are set for the observation noise covariance matrix. When the Mahalanobis distance of the observation residual falls into the lower threshold range, it is determined to be a pseudo-signal of physiological tremor and is suppressed. When the Mahalanobis distance of the observation residual exceeds the lower threshold range but is lower than the higher threshold, it is determined to be a real needlework movement signal and is retained. When the Mahalanobis distance of the observation residual exceeds the higher threshold, it is determined to be abnormal noise and is subject to forced zeroing and truncation. Both thresholds are determined by conducting multiple comparative experiments on the physiological tremor frequency range (usually 8-12Hz) and the real needlework movement frequency range (usually 0.5-4Hz) of different operators, using the valley point of the frequency distribution histogram as the dividing line. Mahalanobis distance is a distance metric that considers the covariance relationship between variables and is used to measure the degree of deviation between the observed residual and the expected distribution.
[0040] The six-degree-of-freedom inertial signal refers to the sensor simultaneously acquiring three-axis acceleration signals and three-axis angular velocity signals, totaling six dimensions, used to fully describe the translational and rotational states in space.
[0041] The segmented discrete cosine transform refers to dividing the time-domain signal sequence into segments with a fixed window length, and then independently performing a discrete cosine transform on each segment to project the signal into the frequency domain. The recommended window length is 200 to 300 steps, and the recommended number of low-frequency components to retain is 28 to 36 frequency coefficients. The specific values are determined by analyzing the inflection point of the experimental curve of the mean square error between the reconstructed trajectory and the true trajectory as a function of the number of retained coefficients.
[0042] The multimodal fusion feature sequence is constructed by concatenating the low-frequency compressed features of each segment with the posture and action feature vectors in the corresponding time-domain window according to the channel dimension to form a fusion feature vector of a unified dimension, and then arranging them along the time axis to form a fusion feature sequence.
[0043] The frequency domain hybrid range attention embroidery sequence modeling network is a deep learning-based sequence modeling network. Its specific structure is as follows: the input layer receives a multimodal fusion feature sequence with a dimension equal to the sequence length multiplied by the feature dimension, and the sequence length can reach tens of thousands of steps. A pre-processing module performs piecewise discrete cosine transform on the input, retaining low-frequency components and compressing the effective sequence length to one-eighth of the original length. The core attention layer adopts a hybrid range design, consisting of two parts: a local dense window attention submodule, which performs standard full attention calculation on the 14-18 steps before and after each frame, with the number of steps determined through statistical experiments on the number of stitch transition frames, used to capture fine local features of stitch transitions; and a global sparse anchor point attention submodule, which samples 58-70 global anchor point frames at equal intervals from the entire sequence, approximating the association weight matrix between the current frame and the global anchor points using a bilinear kernel function, avoiding the overhead of generating a complete global attention matrix. The number of anchor points is determined through multiple sets of experiments on the relationship between the number of frames in the entire sequence and the reconstruction accuracy. Verification confirms that the outputs of the local dense window attention submodule and the global sparse anchor attention submodule are weighted and superimposed through a gated fusion layer. The gate weights are determined by the frequency domain energy entropy value of the current frame. When the frequency domain energy entropy is high, the weight of the local dense window attention submodule is increased; when the frequency domain energy entropy is low, the weight of the global sparse anchor attention submodule is increased. The feedforward subnetwork adopts a dynamic feedforward routing design, using the prediction confidence of the corresponding needle pattern in the current frame as the routing independent variable. When the confidence is higher than a threshold, the intermediate hidden layer is skipped and the signal is directly transmitted to the output projection layer; when the confidence is lower than a threshold, the signal is transmitted to the output projection layer. The complete two-layer feedforward computation path is activated at the threshold. The confidence threshold is recommended to be 0.87 to 0.93, and determined through joint experiments on inference frame rate and reconstruction accuracy under different thresholds. The overall network alleviates the deep gradient vanishing problem by using a long-span residual dense jump matrix. A cross-layer direct connection channel is set every 3 to 5 layers. The number of cross-layers is determined by the stable range of the experimental curve of gradient norm changing with depth. The cross-layer weights are initialized to zero and gradually activated during training. At the same time, a layer-by-layer gradient norm pruning mechanism is introduced, and the upper limit of pruning is recommended to be 0.8 to 1.2. The oscillation amplitude of the training loss curve was determined through experimental analysis. At the neuron activation resource allocation level, the ratio of neuron activations in the local dense window attention submodule to the global sparse anchor point attention submodule is dynamically determined by the adaptive attention resource allocation function. At the memory allocation level, the output cache size of the pre-processing module is linked to the sequence compression ratio parameter; the higher the compression ratio, the smaller the cache size. At the hierarchical allocation level, the dynamic feedforward routing design determines the computational path depth of each layer, thereby achieving layer-by-layer allocation of floating-point operations. In terms of technical effects, frequency domain compression fundamentally reduces the input scale of subsequent attention layers; the hybrid range attention structure enables collaborative modeling of local fine features and global contextual features; the gated fusion layer directly embeds the physical behavior features of the needlework into the attention routing mechanism; and the dynamic feedforward routing is based on the needlework prediction confidence level. By adapting to the computational load, the combined effect of these three factors simultaneously improves the modeling efficiency and accuracy on ultra-long embroidery sequences. Memory consumption increases linearly with sequence length rather than quadratically, thus supporting full-process trajectory modeling. The training dataset establishment steps for the frequency domain hybrid range attention embroidery sequence modeling network specifically include: collecting six-degree-of-freedom inertial signals from multiple embroidery operators throughout the entire embroidery process, synchronously recording the corresponding real needle trajectory coordinates, applying adaptive double-threshold Kalman filtering to the original signals, performing piecewise discrete cosine transform, and dividing the training and validation sets at a 9:1 ratio. The training steps for the frequency domain hybrid range attention embroidery sequence modeling network specifically include: using the mean squared error loss function as the main loss term and the trajectory topological continuity penalty term as the auxiliary loss term, updating parameters using the AdamW optimizer, and recommending an initial learning rate of [value missing]. ~ The error is gradually decayed through cosine annealing scheduling. The mean square error of the trajectory is calculated on the validation set every training cycle. The early stopping is based on the validation set error no longer decreasing.
[0044] The bilinear kernel function approximation refers to replacing the direct calculation of the complete attention weight matrix with a low-rank bilinear matrix decomposition. Matrix operations are decomposed into two The product of matrices, where Much smaller than the sequence length This reduces the computational load from the quadratic level to the linear level.
[0045] The long-span residual dense jump matrix refers to setting a cross-layer path that directly connects the output of the previous layer and the input of the next layer every few layers in the deep network. The cross-layer weights are initialized to zero and then gradually activated during training, so that the gradient has a direct path during backpropagation, thereby avoiding the vanishing of deep gradients.
[0046] The adaptive attention resource allocation function is specifically defined as follows: based on the frequency domain energy entropy value of the current frame. Confidence of needle prediction for the current sequence segment The maximum singular value of the association weight matrix with the current global anchor attention submodule Calculate the attention resource allocation index using the input. , The calculation formula is: ,in Dimensional coefficients are used to ensure The dimensions of the ratio of the number of activated neurons are consistent with those of the number of neurons activated; when When the ratio of the number of activated neurons in the locally dense window attention submodule to the globally sparse anchor point attention submodule is taken as the high local ratio parameter; when When, the ratio of activated neurons is taken as a balanced ratio parameter; when At that time, the ratio of activated neurons is taken as a high global ratio parameter; among which and All experiments were conducted on embroidery sequences with different needlework types. The optimal value of the joint index of mean square error of the reconstructed trajectory and inference frame rate was used as the dividing criterion. It is recommended that... Take the upper quartile of the experimental distribution. The lower quartile of the experimental distribution was taken; the specific values of the high local ratio parameter, the balanced ratio parameter, and the high global ratio parameter were all determined through ablation experiments within the corresponding intervals; the frequency domain energy entropy value... The calculation method involves taking the Shannon entropy from the normalized energy distribution of the current frame's frequency domain feature vector. A high value indicates that the acupuncture technique's motion spectrum is diffused, meaning that the acupuncture technique transitions are active. A low value indicates that the acupuncture technique's motion spectrum is concentrated, meaning the acupuncture technique is stable and repetitive.
[0047] Specifically, the two-layer game model is defined as follows: the upper-layer game model aims at trajectory reconstruction accuracy, and the objective function is... The input includes calculating the number of graph segments. Layer allocation vector for each segment Sequence length of the feature sequence fused with multimodal features The functional relationship is ,in and For dimensional coefficients, the constraint condition is: ( (Total number of network layers) and the number of layers in each segment Not less than 2; the lower-level game model aims at inference delay, with the objective function... The input includes calculating the number of graph segments. Number of parallel threads in each flow channel The number of buffer slots in the lockless circular buffer queue The functional relationship is ,in For dimensional coefficients, the constraint condition is: ( (the maximum number of parallel threads in the hardware) and The coupling terms of the two objective functions are: The number of segments in the upper-level model determines the number of parallel channels in the lower-level model, and the inference delay feedback of the lower-level model constrains the maximum number of segments allowed in the upper-level model; This function measures the trajectory reconstruction accuracy under different computational graph segmentation schemes. The input includes the number of computational graph segments. Layer allocation vector With sequence length The output is the trajectory reconstruction accuracy score; The function is used to measure inference latency under different parallel resource configurations. The input includes the number of computation graph segments. Number of parallel threads With the number of buffer slots The output is the inference delay score; the two-layer game iteratively solves the optimal upper-layer segmentation scheme and the optimal lower-layer resource allocation until the objective function converges, thus obtaining a computational graph segmentation scheme that balances reconstruction accuracy and real-time inference constraints.
[0048] The asynchronous parallel pipelined multi-channel inference architecture refers to dividing the deep network into multiple sub-segments according to the computation graph segmentation scheme obtained from a two-layer game. Each sub-segment is computed in parallel on an independent channel. Intermediate feature tensors are passed between sub-segments through a lock-free circular buffer queue, eliminating the thread blocking bottleneck caused by inter-layer synchronization waiting and reducing inference latency from serial accumulation to the longest pipeline latency. The lock-free circular buffer queue is a circular memory queue that does not rely on mutex locks. Producer and consumer threads read and write the head and tail pointers of the queue atomically, avoiding thread blocking. It is suitable for inter-layer transmission scenarios with high-frequency real-time data streams.
[0049] The Shannon entropy calculation principle for the frequency domain energy entropy is as follows: after normalizing the square of each component of the frequency domain feature vector, a probability distribution is obtained, and then the negative logarithmic expectation of the probability distribution is calculated. The higher the entropy value, the more uniform the energy is distributed in each frequency component, and the more active the needle movement is. The lower the entropy value, the more concentrated the energy is in a few low-frequency components, and the more stable and regular the needle movement is.
[0050] As an optional implementation, this solution also provides a computer-based system for reconstructing the trajectory of Lu embroidery. The computer is equipped with a readable storage medium that stores program instructions. When the program instructions are run on the computer, they execute all the steps of the above method. The computer is connected to a motion capture sensor array and a visualization output device, receives the original sensor signals, and outputs the trajectory prediction visualization results in real time.
[0051] The specific implementation of step S01 is as follows: Inertial measurement units are deployed on the wrist, index finger, middle finger, and needle-holding area of the embroidery operator to form a motion capture sensor array. Each inertial measurement unit synchronously outputs a three-axis acceleration signal and a three-axis angular velocity signal, totaling six dimensions, forming a raw six-degree-of-freedom inertial signal. An adaptive dual-threshold Kalman filter is applied to the raw six-degree-of-freedom inertial signal. The specific implementation principle is as follows: The Kalman filter calculates the observation residual at each moment, that is, the difference between the actual observed value and the predicted value. Then, the Mahalanobis distance of the residual is calculated. The Mahalanobis distance introduces the covariance relationship between the signals of each dimension when measuring the degree of deviation of the residual, which can accurately measure the degree of deviation of the residual from the expected distribution in the multi-dimensional signal space. Both the high and low thresholds are determined by comparing the physiological tremor frequency distribution (usually 8 to 12 Hz) of multiple operators with the actual needle movement frequency distribution (usually 0.5 to 4 Hz), and the valley point of the frequency distribution histogram is used as the dividing line. When the Mahalanobis distance falls within the low threshold range, the frame signal is determined to be a pseudo-signal of physiological tremor and suppressed to zero; when the Mahalanobis distance is between the low and high thresholds, it is determined to be a genuine stitch motion signal and preserved as is; when the Mahalanobis distance exceeds the high threshold, it is determined to be abnormal noise and forced zeroing truncation is performed. After the above three-level decision, the purified stitch motion signal sequence is output, providing high-quality input for subsequent frequency domain feature extraction.
[0052] The specific implementation of step S02 is as follows: The purified needle movement signal sequence is segmented according to a fixed window length, with a reference window length of 200 to 300 steps. A discrete cosine transform is independently performed on each segment, projecting the time-domain signal to the frequency domain. Low-frequency components are retained, with a reference number of 28 to 36 frequency coefficients, while high-frequency components are discarded, resulting in a frequency-domain compressed feature vector for each segment. The discrete cosine transform projects the signal as a superposition of a set of cosine basis functions. The low-frequency coefficients concentrate the main energy of the signal, compactly expressing the periodicity of the needle movement, while significantly compressing the effective sequence length and reducing the input scale for subsequent attention calculations. Simultaneously, posture and motion feature vectors are extracted from the corresponding time-domain window, including time-domain statistics such as the integral of the rotational angular velocity of each joint and the acceleration direction component. The low-frequency compressed feature vector of each segment is concatenated with the corresponding posture and motion feature vector along the channel dimension to form a unified-dimensional fused feature vector, which is then arranged along the time axis to obtain a multimodal fused feature sequence, serving as the input for subsequent networks.
[0053] The specific implementation of step S03 is as follows: Using the multimodal fusion feature sequence as input, a frequency domain mixed-range attention embroidery sequence modeling network is invoked for long sequence modeling and prediction. The network input layer receives the multimodal fusion feature sequence, and the pre-processing module performs a piecewise discrete cosine transform on the input again, retaining low-frequency components and compressing the effective sequence length to one-eighth of the original length, fundamentally reducing the input scale of subsequent attention layers. The core attention layer consists of a local dense window attention submodule and a global sparse anchor attention submodule. The local dense window attention submodule performs standard full attention calculation on the neighborhood of each frame for 14 to 18 steps before and after, capturing the fine local features of the stitch transition; the global sparse anchor attention submodule samples 58 to 70 global anchor frames at equal intervals from the entire sequence, and approximates the association weight matrix between the current frame and the global anchors using a bilinear kernel function. The bilinear kernel function... Matrix operations are decomposed into two The product of matrices, where Much smaller than the sequence length This reduces the computational cost from the quadratic order of magnitude to the linear order of magnitude, avoiding the overhead of generating a complete global attention matrix. The outputs of the two sub-modules are weighted and superimposed through a gated fusion layer. The gate weights are determined by the frequency domain energy entropy value of the current frame. When the frequency domain energy entropy is high, the weight of the local dense window attention sub-module is increased; when the frequency domain energy entropy is low, the weight of the global sparse anchor point attention sub-module is increased. The feedforward sub-network adopts a dynamic feedforward routing design, using the prediction confidence of the corresponding needle pattern in the current frame as the routing independent variable. When the confidence is higher than the confidence threshold (reference value is 0.87 to 0.93), the intermediate hidden layer is skipped and the signal is directly transmitted to the output projection layer. When the confidence is lower than the confidence threshold, the complete two-layer feedforward computation path is activated. The overall network alleviates the deep gradient vanishing problem through a long-span residual dense jump matrix. A cross-layer direct connection channel is set every 3 to 5 layers. The cross-layer weights are initialized to zero and gradually activated during training. At the same time, a layer-by-layer gradient norm pruning mechanism is introduced, with a pruning upper limit reference value of 0.8 to 1.2. The network finally outputs a trajectory prediction feature sequence.
[0054] The specific implementation of step S04 is as follows: the adaptive attention resource allocation function uses the frequency domain energy entropy value of the current frame. Confidence of needle prediction for the current sequence segment The maximum singular value of the association weight matrix with the current global sparse anchor attention submodule Calculate the attention resource allocation index using the input. ,in Dimensional coefficients. Frequency domain energy entropy value. The probability distribution is obtained by normalizing the squares of each component of the frequency domain feature vector of the current frame, and then the Shannon entropy (i.e., the negative logarithmic expectation) is calculated from this probability distribution. Greater than or equal to the high ratio threshold When the ratio of the number of activated neurons in the locally dense window attention submodule to the globally sparse anchor point attention submodule is taken as the high local ratio parameter; when Given the low ratio threshold With high matching threshold When the ratio is between, take the balanced ratio parameter; when Less than the low ratio threshold At that time, the high global ratio parameter is taken. It is recommended to use the upper quartile of the experimental distribution. It is recommended to use the lower quartile of the experimental distribution. The aforementioned dynamic regulation mechanism enables the neuronal activation resources to be adaptively allocated according to the state of needle manipulation.
[0055] The specific implementation of step S05 is as follows: the upper-level game model takes the trajectory reconstruction accuracy as the objective, and the objective function is... ,in To calculate the number of graph segments, Assign a vector to the number of layers in each segment. The sequence length of the multimodal fusion feature sequence. and The coefficients are dimensional, and the constraint is that the sum of the number of layers in each segment equals the total number of layers in the network. Furthermore, each segment has at least two layers; the lower-level game model aims at inference delay, with the objective function... ,in The number of parallel threads for each flow channel. This represents the number of buffer slots in the lockless circular buffer queue. For dimensional coefficients, the constraint condition is: Not exceeding the maximum number of parallel threads in the hardware and Not less than The two models are passed through The coupling is achieved by iteratively optimizing the bi-objective functions until both converge, resulting in a computational graph segmentation scheme that balances reconstruction accuracy and real-time inference constraints.
[0056] The specific implementation of step S06 is as follows: Based on the computation graph segmentation scheme obtained from the two-layer game, the frequency domain mixed-range attention embroidery sequence modeling network is divided into multiple sub-segments. Each sub-segment is assigned to an independent computational pipeline for parallel execution. Intermediate feature tensors are passed between sub-segments through a lock-free circular buffer queue. The producer thread and consumer thread of the lock-free circular buffer queue read and write the head and tail pointers of the queue through atomic operations, without relying on a mutex lock mechanism, thus avoiding thread blocking. This is suitable for inter-layer transmission scenarios of high-frequency real-time data streams. The inference latency is reduced from serial accumulation to the computation latency of the longest sub-segment in the pipeline, enabling the overall system to achieve millisecond-level real-time trajectory prediction. The prediction result is decoded and output to a visualization device to restore the stitch trajectory coordinates in real time and display them dynamically.
[0057] It should be noted that the key technologies of this invention include: adaptive dual-threshold Kalman filtering separates physiological tremor pseudo-signals, real needle movement signals, and abnormal noise signals through Mahalanobis distance, eliminating the pollution of subsequent modeling by pseudo-signals from the source of signal processing, so that errors do not accumulate with sequence length; frequency domain hybrid range attention structure reduces the computational cost of global attention from the quadratic order of magnitude to the linear order of magnitude through bilinear kernel function, while the gated fusion layer driven by frequency domain energy entropy value directly embeds the physical behavior of needlework into the attention routing mechanism, enabling local fine features and global context features to be modeled collaboratively; two-layer game computation graph segmentation decouples the reconstruction accuracy target and the inference delay target, and then solves iteratively by coupling the number of segmentation segments, so that the inference architecture adaptively approaches the optimal balance point between accuracy and delay under hardware constraints. The synergistic effect of the three is as follows: the purified signal ensures the information quality of frequency domain modeling, the frequency domain mixed range attention structure enables ultra-long sequence modeling to maintain accuracy under linear memory growth, and the two-layer game and pipeline architecture realize the above modeling capabilities into millisecond-level real-time inference. The three links form a complete closed loop from signal acquisition to real-time output. The absence of any link will lead to the degradation of the overall system performance.
[0058] It should be noted that in long embroidery sequences with frequent needlework type switching, the motion spectrum distribution differs significantly between different needlework segments. If the attention mechanism adopts a fixed ratio of local to global resource allocation, a large amount of local attention computational resources will be wasted in the smooth repetition of needlework segments, while insufficient computational resources can be allocated to fine local features in the rapid needlework switching segments. This results in the reconstruction accuracy of both types of segments not being able to maintain the optimal level simultaneously. The reason for the above technical problem is that the frequency domain energy entropy values of different needlework segments differ significantly. In the smooth repetition segments, the energy is concentrated in a few low-frequency components, resulting in low entropy values, and the contribution of global context information to reconstruction is much greater than that of local fine information. In contrast, in the needlework switching segments, the energy is diffused across multiple frequency components, resulting in high entropy values, and the weight of local fine information needs to be significantly increased. A fixed ratio of resource allocation cannot perceive these dynamic changes and therefore cannot adaptively adjust the computational focus between different needlework segments. The usual solution to the above technical problem is to set independent and fixed neuron activation ratios for local attention and global attention in the network, or to train multiple independent models for different needlework types by manually tuning parameters. However, manual parameter tuning requires prior knowledge of the type label for each stitch, making online switching impossible in real-time inference scenarios. Training multiple independent models significantly increases deployment costs, and the latency and boundary errors introduced by model switching itself disrupt the topological continuity of long-sequence trajectories. This invention effectively solves this technical problem by using an adaptive attention resource allocation function to allocate frequency domain energy entropy values during inference in each frame. Confidence level of acupuncture prediction Maximum singular value of the correlation weight matrix As input, calculate the attention resource allocation index in real time. and based on With high matching threshold Low ratio threshold The magnitude of the ratio dynamically switches between three levels: high local ratio, balanced ratio, and high global ratio, representing the ratio of activated neurons. Frequency domain energy entropy value. It directly reflects the diffusion degree of the needlework spectrum in the current frame, without relying on external needlework type labels. Therefore, it can run completely online in real-time inference scenarios without needing to know the needlework type in advance; Maximum Singular Value The current information aggregation intensity of the global anchor attention submodule is introduced as the adjustment basis, so that resource allocation not only responds to the local spectral features of the current frame, but also senses the aggregation state of the global context, thereby achieving a smooth transition between the stable segment and the switching segment, and avoiding discontinuous jumps in trajectory prediction caused by abrupt changes in resource allocation.
[0059] Specifically, the principle of this invention is as follows: The fundamental reason why this invention can solve the above-mentioned technical problems is that the adaptive dual-threshold Kalman filter establishes a decision mechanism directly corresponding to the physical characteristics of embroidery movements from the source of signal processing. In its standard form, the Kalman filter judges the reliability of the observed value by the relationship between the observation residual and the observation noise covariance matrix. However, when the amplitude distribution of physiological tremors and real stitch movements highly overlap, a single covariance threshold cannot simultaneously satisfy the correct judgment of both types of signals, inevitably leading to misjudgment. This invention introduces Mahalanobis distance as a metric for the observation residual. Mahalanobis distance considers the covariance relationship between signals in different dimensions when measuring the degree of residual deviation, thus enabling more accurate differentiation of signal types in a multi-dimensional inertial signal space, without relying on a single amplitude magnitude. Based on this, the present invention sets two dynamic thresholds, a low threshold corresponding to the statistical upper bound of the physiological tremor frequency range, and a high threshold corresponding to the statistical lower bound of abnormal noise. Both thresholds are determined by comparing the physiological tremor frequency distribution of different operators with the actual needlework movement frequency distribution, using the valley point of the frequency distribution histogram as the dividing line. Therefore, the thresholds themselves directly correspond to the physical frequency characteristics of the signal and have clear physical meaning. When the Mahalanobis distance of the observation residual falls into the low threshold range, the signal is judged as a physiological tremor pseudo-signal and suppressed to ensure that pseudo-signals do not enter the subsequent modeling process. When the Mahalanobis distance is between the low and high thresholds, the signal is retained as a real needlework movement signal. When the Mahalanobis distance exceeds the high threshold, the signal is judged as abnormal noise and forced to zero is truncated to prevent outliers from interfering with subsequent frequency domain feature extraction. After the purified signal sequence enters the piecewise discrete cosine transform module, the low-frequency components can truly reflect the periodicity of the needlework movement without being contaminated by tremor pseudo-signals, thus fundamentally ensuring the information quality of the multimodal fusion feature sequence received by the frequency domain mixed-range attention embroidery sequence modeling network. In the modeling process of ultra-long embroidery sequences, since the input features of each frame have undergone rigorous double-threshold purification, errors no longer accumulate and propagate along the time axis. Therefore, the accuracy of long sequence trajectory reconstruction theoretically remains stable with increasing sequence length, rather than experiencing a continuous decrease in accuracy. The above logical chain demonstrates that the technical solution of this invention is highly compatible with the technical problem it addresses at both the physical mechanism and algorithm design levels, and the solution is logically self-consistent.
[0060] The following provides a specific embodiment 1 of the present invention, and the specific implementation of each step in this embodiment 1 is described in detail below.
[0061] The specific implementation method of step S01 is as follows.
[0062] An array of motion capture sensors was deployed on the embroidery operator's hand and needle-holding area. Each sensor simultaneously acquired three-axis acceleration and three-axis angular velocity signals, totaling six dimensions, forming a raw six-degree-of-freedom inertial signal sequence. An adaptive double-threshold Kalman filter was applied to the raw signal to eliminate pseudo-signals caused by physiological tremors. In the prediction phase of the Kalman filter, the state estimate was recursively derived based on the state transition equation; in the update phase, the observation residual vector was calculated based on the observed values. This is the difference between the current observed value and the predicted observed value. The Mahalanobis distance of the observation residuals. The calculation formula is as follows:
[0063] ;
[0064] In the formula, for The column vector of observation residuals at time t. for The observation residual covariance matrix at time t. for The inverse matrix, superscript This represents the transpose of a vector. Index of the current frame. Mahalanobis distance. It is a distance metric that considers the covariance relationship between variables, used to measure the degree of deviation between the observed residuals and the expected distribution; a larger value indicates a more significant difference between the current observation and the prediction. Based on... The relationship between the magnitude of the two thresholds is used for signal classification: when When the signal is identified as a physiological tremor spurious signal, the observation value of that frame is suppressed; when When the signal is determined to be a real needle movement signal, the observation value of that frame is retained for filtering updates; when When this occurs, it is identified as abnormal noise, and a forced zero-reset truncation process is performed, that is, the observation residual of that frame is set to zero before the Kalman update is performed. Among them, the low threshold With high threshold The determination method is as follows: collect physiological tremor signals (frequency range usually 8-12Hz) and real needle movement signals (frequency range usually 0.5-4Hz) from multiple operators, plot Mahalanobis distance frequency distribution histograms for each, and take the Mahalanobis distance value corresponding to the valley point between two peaks of the histogram as the value. The Mahalanobis distance value corresponding to the starting point of the sparse region outside the shaking peak is taken as... After multiple comparative experiments, the final output is the purified needle movement signal sequence for use in subsequent steps.
[0065] The specific implementation method of step S02 is as follows.
[0066] The purified needle motion signal sequence is segmented according to a fixed window length, empirically between 200 and 300 steps. A discrete cosine transform is independently performed on each segment, projecting the time-domain signal to the frequency domain. Low-frequency components are retained, with an empirically defined number of retained coefficients between 28 and 36 frequency coefficients. The specific value is determined through inflection point analysis of experimental curves showing the mean square error between the reconstructed and actual trajectories as a function of the number of retained coefficients. The low-frequency compressed feature vector of each segment is concatenated with the corresponding attitude and motion feature vector within the time-domain window along the channel dimension to form a unified-dimensional fused feature vector. This fused feature vector is then arranged along the time axis to construct a multimodal fused feature sequence.
[0067] The specific implementation method of step S03 is as follows.
[0068] Using a multimodal fused feature sequence as input, a frequency domain hybrid range attention embroidery sequence modeling network is invoked. The input layer of this network receives the fused feature sequence, with a dimension equal to the sequence length multiplied by the feature dimension; the sequence length can reach tens of thousands of steps. A pre-processing module performs a piecewise discrete cosine transform on the input again, compressing the effective sequence length to one-eighth of the original length after retaining low-frequency components. The local dense window attention submodule of the core attention layer performs standard attention calculations on the neighborhood of each frame, 14-18 steps before and after it. The global sparse anchor point attention submodule samples 58-70 anchor point frames at equal intervals from the entire sequence and approximates the association weight matrix between the current frame and the global anchor points using a bilinear kernel function. The attention weight matrix operation is decomposed into the product of two low-rank matrices, approximating the attention weight matrix. The calculation formula is as follows:
[0069] ;
[0070] In the formula, This is an approximate attention weight matrix with dimension . , It is a left decomposition matrix with dimension . , A right decomposition matrix The transpose of, with dimension , For the number of frames in the sequence, The rank parameter of the low-rank decomposition and This decomposition reduces the computational load from Down to Output of the local dense window attention submodule Output of the Global Sparse Anchor Attention Submodule After weighted superposition by the gated fusion layer, the fused output is... The calculation formula is as follows:
[0071] ;
[0072] In the formula, for The gated fusion output feature vector of the frame This is the output feature vector of the local dense window attention submodule. This is the output feature vector of the global sparse anchor attention submodule. for The frame gating weight, with a value range of 1. The frequency domain energy entropy value of the current frame in step S04 Decide, High Time Take a larger value to increase the weight of the local dense window attention submodule. Low time Smaller values are chosen to increase the weight of the global sparse anchor attention submodule. All three output feature vectors have the same dimension, representing the feature space dimension of the attention layer's output. The weights are dimensionless, and both sides of the equation have the same dimensions. The feedforward subnetwork adopts a dynamic feedforward routing design, using the prediction confidence of the needle method corresponding to the current frame. As a routing argument, when When the intermediate hidden layer is skipped and the output projection layer is directly passed, The complete two-layer feedforward computation path is activated at that time. The confidence threshold for dynamic feedforward routing is empirically set at 0.87–0.93, determined through joint experiments on inference frame rate and reconstruction accuracy under different thresholds. The overall network mitigates deep gradient vanishing by using a long-span residual dense jump matrix. Cross-layer direct connections are established every 3–5 layers, with cross-layer weights initialized to zero and gradually activated during training. A layer-by-layer gradient norm pruning mechanism is also introduced, with an empirical upper limit of 0.8–1.2. The final output is a trajectory prediction feature sequence.
[0073] The specific implementation method of step S04 is as follows.
[0074] An adaptive attention resource allocation function dynamically adjusts the ratio of neuron activations in the local dense window attention submodule to those in the global sparse anchor point attention submodule. Attention resource allocation index. The calculation formula is as follows:
[0075] ;
[0076] In the formula, An index for attention resource allocation. For a dimensional coefficient, its dimensions are such that... The dimensions are consistent with the ratio of the number of activated neurons. This is the frequency domain energy entropy value (dimensionless) of the current frame. Calculate the confidence level (dimensionless) for the needle technique prediction of the current sequence segment. Associating weight matrix for the current global sparse anchor attention submodule The largest singular value (dimensionless), therefore Absorb all dimensions to ensure The dimensions are correct. Among them, The calculation method is as follows: the probability distribution is obtained by normalizing the squares of each component of the frequency domain feature vector of the current frame. Next, calculate the Shannon entropy for this distribution, using the following formula:
[0077] ;
[0078] In the formula, For the first The normalized energy percentage of each frequency component It is the natural logarithm. High indicates active switching between different needle techniques. A low needle depth indicates a smooth and repetitive stitch pattern. (Based on...) The value of , when When the ratio of activated neurons is high, the local ratio parameter is taken; when When, take the balanced ratio parameter; when At that time, the high global ratio parameter is taken. For a high threshold of attention resource allocation, it is recommended to take the upper quartile of the experimental distribution. To set a low threshold for attention resource allocation, it is recommended to take the lower quartile of the experimental distribution. Both are determined by using the optimal point of the joint index of the mean square error of the reconstructed trajectory and the inference frame rate on embroidery sequences of different needlework types as the dividing criterion. Each ratio parameter is determined by ablation experiments in the corresponding interval.
[0079] The specific implementation method of step S05 is as follows.
[0080] Construct a two-level game model. The upper-level game model aims at trajectory reconstruction accuracy, with the objective function being... The calculation formula is as follows:
[0081] ;
[0082] In the formula, Assign a score to the trajectory reconstruction accuracy. and For dimensional coefficients, make The dimensions are unified to the precision score dimension. The sequence length of the multimodal fusion feature sequence. To calculate the number of graph segments, For the first The number of network layers allocated to a segment. For segment indexes, the constraints are: and , This represents the total number of network layers. The first term in the formula... The second term measures the contribution of the average carrying sequence length of each segment to the reconstruction accuracy. A uniformity penalty term is assigned to the number of layers to penalize schemes where the number of layers is too concentrated across different segments. The lower-level game model aims to reduce inference delay; the objective function is... The calculation formula is as follows:
[0083] ;
[0084] In the formula, For inference delay score, For dimensional coefficients, make The units of measurement are unified to the units of delayed scores. The number of parallel threads for each flow channel. The number of buffer slots in the lockless circular buffer queue is given by the following constraint: and , This represents the maximum number of parallel threads allowed by the hardware. The two-layer model utilizes... The coupling is such that the optimal number of segments in the upper layer determines the number of parallel channels in the lower layer, and the lower layer inference delay feedback constrains the maximum number of segments allowed in the upper layer. By iteratively solving for the optimal segmentation scheme in the upper layer and the optimal resource allocation in the lower layer until both objective functions converge, a computational graph segmentation scheme that balances reconstruction accuracy and real-time inference constraints is obtained.
[0085] The specific implementation method of step S06 is as follows.
[0086] Based on the computation graph segmentation scheme obtained from the two-layer game, the network is divided into multiple sub-graph segments. Each sub-graph segment is computed in parallel on an independent pipeline. Intermediate feature tensors are passed between sub-graph segments through a lock-free circular buffer queue. Producer and consumer threads read and write the head and tail pointers of the queue through atomic operations, eliminating the thread blocking bottleneck of inter-layer synchronization waiting. This reduces the inference latency from serial accumulation to the longest pipeline latency, thereby achieving millisecond-level real-time trajectory prediction and visualization output.
[0087] To better understand and implement this invention, the following is a specific application scenario of this invention, Example 2:
[0088] This embodiment uses the reconstruction process of the stitch trajectory of a complete Lu embroidery piece as a scenario to verify the actual execution effect of the method of the present invention. The operator is a craft inheritor with rich embroidery experience. The embroidery pattern includes various stitch types such as flat stitch, braid stitch, and overlock stitch. The total operation time is about 42 minutes, the acquisition frame rate is 100Hz, and the total length of the original six-degree-of-freedom inertial signal is about 252,000 steps.
[0089] During the sensor array deployment phase, one inertial measurement unit was deployed on the palmar side of the operator's right wrist, the distal phalanx of the index finger, and the needle-holding area, for a total of three measurement nodes. Each node outputs triaxial acceleration and triaxial angular velocity, with a total of 18 channels for the raw signal. After acquisition, an adaptive dual-threshold Kalman filter was applied to the raw signal. A comparative experiment was conducted between the physiological tremor frequency distribution of this operator and four other operators and the actual needle movement frequency distribution. Frequency distribution histograms were plotted, determining that the low threshold corresponded to a Mahalanobis distance of 3.7, and the high threshold corresponded to a Mahalanobis distance of 9.2. After filtering, approximately 18% of the frames were identified as physiological tremor spurious signals and suppressed, approximately 0.3% were identified as abnormal noise and truncated, and the remaining frames were retained as the purified needle movement signal sequence, such as... Figure 2 The diagram shows a comparison of the signals before and after filtering.
[0090] In the frequency domain feature extraction stage, the purified needle motion signal sequence is segmented into segments with a window length of 256 steps. A discrete cosine transform is performed on each segment, retaining the first 32 low-frequency coefficients as frequency domain compression features. The effective sequence length is compressed to 12.5% of the original length, approximately 31,500 frames. The temporal attitude motion feature vector has a dimension of 24, the frequency domain compression feature has a dimension of 32, and the fused feature vector after concatenation by channel dimension has a dimension of 56. The total dimension of the multimodal fused feature sequence is 31500×56.
[0091] The specific structure of the frequency domain hybrid range attention embroidery sequence modeling network is as follows. The input layer receives a multimodal fusion feature sequence with a dimension of 31500×56. The pre-processing module performs piecewise discrete cosine transform on the input again, and after retaining the low-frequency components, the sequence length is compressed to 3938 frames. The core attention layer consists of 12 layers. The neighborhood step count of the local dense window attention submodule is 16 steps, and the global anchor frame count of the global sparse anchor point attention submodule is 64. The rank parameter of the bilinear kernel function is... Take 32, which satisfies the condition. The linearization condition is as follows: A direct cross-layer connection is set every 4 layers in the long-span residual dense jump matrix, with cross-layer weights initialized to zero, and the upper limit of the layer-by-layer gradient norm pruning is set to 1.0. The confidence threshold for the feedforward sub-network is set to 0.90; when the confidence is higher than 0.90, the intermediate hidden layers are skipped; when it is lower than 0.90, the complete two-layer feedforward path is activated. For example... Figure 3The diagram shows the network data flow. After being compressed by the pre-processing module, the multimodal fusion feature sequence passes through the core attention layer and the feedforward sub-network in sequence. After being converged through the cross-layer direct connection channel, the trajectory prediction feature sequence is output.
[0092] The training dataset for the neural network collected complete operation records from 5 operators, divided into training and validation sets in a 9:1 ratio. The training set consisted of 47 complete embroidery operation sequences, and the validation set consisted of 6 sequences. Training employed the AdamW optimizer, with an initial learning rate of [value missing]. Cosine annealing scheduling was used, and a total of 120 training cycles were conducted. The early stopping criterion was that the mean square error of the validation set no longer decreased. The early stopping was finally triggered in the 97th cycle. Table 1 shows the changes in the mean square error of the validation set trajectory under different training cycles.
[0093] Table 1. Variation of Validation Set Trajectory Mean Square Error with Training Cycle
[0094]
[0095] As the training cycle increases, the mean squared error curve of the validation set continues to decrease and tends to flatten. This trend indicates that the long-span residual dense jump matrix effectively alleviates the problem of deep gradient vanishing, enabling the gradient to be stably transmitted to the shallow layer through the cross-layer direct connection channel during backpropagation. This avoids the phenomenon that the shallow layer parameters stop updating due to gradient vanishing, thus ensuring the network's continuous convergence ability in deep structures.
[0096] In this implementation, the adaptive attention resource allocation function determines the high-ratio threshold based on the experimental distribution. The upper quartile corresponds to a value of 2.84, which is the low-ratio threshold. The lower quartile corresponds to a value of 1.13. In the flat needle segment (smooth repetition of the needlework), the frequency domain energy entropy value... The mean is 1.21. The mean value is 1.08, falling into the high global ratio range. The ratio of activated neurons in the locally dense window attention submodule to the globally sparse anchor point attention submodule is 3:7. In the braided needle segment (with frequent switching of needle techniques), the frequency domain energy entropy value... The mean is 3.47. The mean value was 3.12, falling into the high local ratio range, with the ratio of activated neurons switching to 7:3. Table 2 shows the allocation of attentional resources for different acupuncture techniques.
[0097] Table 2 Comparison of Attention Resource Allocation for Different Acupuncture Techniques
[0098]
[0099] The above data indicates that as the needlework technique shifts from steady repetition to frequent switching, the frequency domain energy entropy value... As it rises, The corresponding increase in attention resources leads to a shift towards locally dense window attention submodules. This pattern aligns with the physical representation of needle movement state by frequency domain energy entropy, where higher entropy values indicate a more diffuse motion spectrum and a greater contribution of local fine features to trajectory reconstruction. Therefore, dynamically increasing the proportion of local attention can capture more fine transition features during needle switching segments, rather than wasting computational resources on the repeated aggregation of the global context.
[0100] The maximum number of parallel threads tested in the two-layer game computation graph segmentation stage. The total number of network layers is 8. The value is 12. Through iterative solutions, the optimal partitioning scheme for the upper-level game is... The segment, and the layer number allocation vector for each segment are as follows: The optimal resource allocation in the lower-level game is: Number of buffer slots Table 3 shows the convergence of the dual objective function during the iteration process.
[0101] Table 3. Iterative Convergence Process of Two-Level Game
[0102]
[0103] like Figure 4 The diagram illustrates an asynchronous parallel pipelined multi-channel inference architecture. Four sub-segments execute in parallel on independent channels. Intermediate feature tensors are passed between sub-segments via a lock-free circular buffer queue with six buffer slots. The computation latencies for each channel are 8.3ms, 9.1ms, 8.7ms, and 9.4ms, respectively. The overall pipeline inference latency is the longest segment latency of 9.4ms, meeting millisecond-level real-time inference requirements. The lock-free circular buffer queue uses atomic operations to read and write head and tail pointers, eliminating thread blocking and allowing each channel to begin processing the next frame of data without waiting for adjacent segments to complete. The inference latency does not linearly increase with the number of network layers.
[0104] In this embodiment, the equivalent replacement structure for the frequency domain hybrid range attention embroidery sequence modeling network includes the following two schemes. The first replacement structure is a hierarchical progressive sparse transformer, whose input is also a multimodal fusion feature sequence. In the first layer, the sequence is downsampled with a fixed step size, compressing the sequence length to one-quarter of the original length. In the second layer, standard full attention calculation is performed on the downsampled sequence. In the third layer, the attention output is upsampled back to the original length and added to the input residual. The data flow is that the input sequence passes through the downsampling layer, attention layer, upsampling layer, and residual addition layer in sequence, and then outputs the trajectory feature sequence. Its feature extraction dimension is highly consistent with the main scheme. Both use multimodal fusion features as input and the mean square error of trajectory coordinates as the convergence target. The capture of local fine features depends on the retention of residuals before downsampling, and the global context features are undertaken by the full attention on the compressed sequence. Those skilled in the art can implement the above structure without creative effort. The second alternative structure is a cascaded structure of a temporal convolutional network and sparse attention. The temporal convolutional network takes a multimodal fused feature sequence as input and extracts local temporal features through multiple layers of dilated convolutions. The dilation coefficients are doubled layer by layer. The data flow is that the input sequence passes through each dilated convolutional layer in sequence and outputs a local feature sequence. Then, the local feature sequence is input into the sparse attention module. The sparse attention module samples anchor points at equal intervals from the local feature sequence and performs low-rank attention calculations to output a trajectory prediction feature sequence with global context enhancement. The loss function is consistent with the main scheme, with mean squared error loss as the main loss term and trajectory topological continuity penalty term as the auxiliary loss term.
[0105] It should be noted that the variables involved in this invention are explained in detail in Table 4.
[0106] Table 4. Variable Explanation Table
[0107]
[0108] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for constructing a large model of Lu embroidery trajectory reconstruction based on motion capture, characterized in that, Includes the following steps: An array of motion capture sensors is deployed on the embroidery operator's hand and the needle-holding area to collect the original six-degree-of-freedom inertial signals of the needlework. An adaptive dual-threshold Kalman filter is applied to the original six-degree-of-freedom inertial signals to remove physiological tremor pseudo signals and output the purified needlework motion signal sequence. The purified needle motion signal sequence is subjected to segmented discrete cosine transform, and the low-frequency components of each segment are extracted as frequency domain compression features. These features are then fused with time domain posture and motion features to construct a multimodal fusion feature sequence. Using a multimodal fusion feature sequence as input, a frequency domain hybrid range attention embroidery sequence modeling network is invoked to perform long-sequence modeling and prediction of the entire stitch trajectory, and output a trajectory prediction feature sequence. An adaptive attention resource allocation function is used to dynamically adjust the ratio of neuron activation resource allocation between local dense window attention and global sparse anchor attention in a frequency domain mixed-range attention embroidery sequence modeling network. We construct an upper-level game model targeting trajectory reconstruction accuracy and a lower-level game model targeting inference latency. We then use a two-level game to solve the computational graph segmentation scheme between trajectory reconstruction and real-time inference.
2. The method for constructing a large model of Lu embroidery trajectory reconstruction based on motion capture according to claim 1, characterized in that, The adaptive dual-threshold Kalman filter specifically sets a high threshold and a low threshold for the observation noise covariance matrix based on the joint statistical distribution of the speed and acceleration of the needlework movement. When the Mahalanobis distance of the observation residual falls into the low threshold range, it is determined to be a pseudo signal of physiological tremor and is suppressed. When the Mahalanobis distance of the observation residual is between the low threshold and the high threshold, it is determined to be a real needlework movement signal and is retained. When the Mahalanobis distance of the observation residual exceeds the high threshold, it is determined to be abnormal noise and is subjected to forced zeroing truncation.
3. The method for constructing a large model of Lu embroidery trajectory reconstruction based on motion capture according to claim 2, characterized in that, The high and low thresholds are determined by conducting multiple comparative experiments on the physiological tremor frequency range and the actual needle movement frequency range of different operators, using the valley point of the frequency distribution histogram as the dividing line.
4. The method for constructing a large model of Lu embroidery trajectory reconstruction based on motion capture according to claim 3, characterized in that, The segmented discrete cosine transform specifically involves dividing the purified needle motion signal sequence into segments with a fixed window length, then independently performing a discrete cosine transform on each segment to project the signal into the frequency domain. The window length is taken as a window length threshold, and the number of low-frequency components retained is taken as a low-frequency component retention threshold. Both the window length threshold and the low-frequency component retention threshold are determined by analyzing the inflection point of the experimental curves showing the mean square error of the reconstructed trajectory and the true trajectory as a function of the number of retention coefficients.
5. The method for constructing a large model of Lu embroidery trajectory reconstruction based on motion capture according to claim 4, characterized in that, The construction of the multimodal fusion feature sequence specifically involves concatenating the low-frequency compressed features of each segment with the attitude and action feature vectors within the corresponding time-domain window according to the channel dimension, forming a fusion feature vector of a unified dimension, and then arranging them along the time axis to form a fusion feature sequence.
6. The method for constructing a large model of Lu embroidery trajectory reconstruction based on motion capture according to claim 5, characterized in that, The core attention layer of the frequency domain hybrid range attention embroidery sequence modeling network includes a local dense window attention submodule and a global sparse anchor attention submodule. The local dense window attention submodule performs complete attention calculation on the preceding and following neighborhoods of each frame. The global sparse anchor attention submodule samples global anchor frames at equal intervals from the entire sequence and approximates the correlation weight matrix between the current frame and the global anchors through a bilinear kernel function. The outputs of the two are weighted and superimposed by a gated fusion layer, and the gate weights are determined by the frequency domain energy entropy value of the current frame.
7. The method for constructing a large model of Lu embroidery trajectory reconstruction based on motion capture according to claim 6, characterized in that, The feedforward subnetwork of the frequency domain hybrid range attention embroidery sequence modeling network adopts a dynamic feedforward routing design. The prediction confidence of the stitch corresponding to the current frame is used as the routing independent variable. When the confidence is higher than the confidence threshold, the intermediate hidden layer is skipped and the data is directly transmitted to the output projection layer. When the confidence is lower than the confidence threshold, the complete two-layer feedforward computation path is activated. The confidence threshold is determined by joint experiments on the inference frame rate and reconstruction accuracy under different thresholds.
8. The method for constructing a large model of Lu embroidery trajectory reconstruction based on motion capture according to claim 7, characterized in that, The frequency domain hybrid range attention embroidery sequence modeling network alleviates the deep gradient vanishing problem by using a long-span residual dense jump matrix. A cross-layer direct connection channel is set every few layers, and the number of cross-layers is determined by the stable range of the experimental curve of gradient norm changing with depth. The cross-layer weights are initialized to zero and gradually activated during training. At the same time, a layer-by-layer gradient norm pruning mechanism is introduced, and the pruning upper limit is determined by experimental analysis of the oscillation amplitude of the training loss curve.
9. The method for constructing a large model of Lu embroidery trajectory reconstruction based on motion capture according to claim 8, characterized in that, Also includes: Based on the two-layer game computation graph segmentation scheme, an asynchronous parallel pipeline multi-channel inference architecture is deployed. A lock-free circular buffer queue is used to realize asynchronous data transfer between layers, and millisecond-level real-time trajectory prediction and visualization output are achieved.
10. The method for constructing a large model of Lu embroidery trajectory reconstruction based on motion capture according to claim 9, characterized in that, The two-layer game specifically involves iteratively solving for the optimal upper-layer partitioning scheme and the optimal lower-layer resource allocation until the objective function converges, and determining the number of partitioning segments in the upper-layer model. The number of parallel channels in the lower-level model is determined, and the inference delay feedback of the lower-level model constrains the maximum number of segments allowed in the upper-level model.
