Papers
Topics
Authors
Recent
Search
2000 character limit reached

TrajLoc: Trajectory Similarity & Motion Control

Updated 6 July 2026
  • TrajLoc is a dual-method framework: one method embeds piecewise-linear trajectories into a Euclidean space using landmark distances, while the other employs attention localization for video diffusion.
  • The landmark-based approach computes trajectory distances by mapping GPS data to fixed landmarks, ensuring metric properties under density and general-position conditions.
  • The attention-based method replaces object token attention with Gaussian heatmaps to precisely control multi-object motion in image-to-video generative tasks.

TrajLoc is a name used for two distinct trajectory-centered methods. In "Simple Distances for Trajectories via Landmarks" (Phillips et al., 2018), TrajLoc denotes a landmark-based embedding for piecewise-linear trajectories in R2\mathbb R^2, with induced distances DD^{\parallel} and DπD^\pi that can become bona-fide metrics under density and general-position assumptions on the landmark set. In "TrajLoc: Trajectory-Attention Localization for Multi-Object Motion Control" (Sela et al., 1 Jul 2026), TrajLoc denotes a control mechanism for text-and-image-conditioned video diffusion in which each object token’s cross-attention weights are overwritten by a Gaussian heatmap centered on the target location at every frame. The two uses are unrelated in task formulation: the former is a trajectory similarity and indexing method, whereas the latter is a multi-object motion-control method for image-to-video generation.

1. Disambiguation and scope

The term TrajLoc refers to two separate constructions documented in the literature (Phillips et al., 2018, Sela et al., 1 Jul 2026).

Usage of TrajLoc Defining representation Main use
"Trajectories via Landmarks" ϕ(τ)=(d(τ,1),,d(τ,m))\phi(\tau) = (d(\tau,\ell_1), \ldots, d(\tau,\ell_m)) with induced distances DD^{\parallel} and DπD^\pi trajectory similarity, k-means clustering, classification, approximate nearest-neighbor search
"Trajectory-Attention Localization" per-object Gaussian heatmap overwrite of cross-attention, plus trajectory and appearance token embeddings precise multi-object motion control in image-to-video diffusion

This disambiguation matters because the two methods operate on different objects, optimize different objectives, and are evaluated with different metrics. The landmark-based method maps trajectories to Euclidean vectors and then uses standard Euclidean machinery. The diffusion-based method modifies attention maps and prompt tokens inside pretrained image-to-video backbones. A plausible implication is that the shared name should not be taken to indicate architectural continuity.

2. Landmark-distance TrajLoc: formal construction

In the landmark-based formulation, τ\tau is a piecewise-linear trajectory in R2\mathbb R^2, and L={1,,m}L=\{\ell_1,\ldots,\ell_m\} is a fixed set of mm landmark points. The embedding is defined by

DD^{\parallel}0

where, in the version called DD^{\parallel}1, the landmark coordinate is

DD^{\parallel}2

The induced distance between two trajectories DD^{\parallel}3 is the Euclidean distance in the embedding space,

DD^{\parallel}4

Symmetry and the triangle inequality follow immediately from the Euclidean norm in DD^{\parallel}5. The nontrivial issue is positive-definiteness. The stated theorem assumes that every critical vertex of DD^{\parallel}6 lies at least distance DD^{\parallel}7 from all other segments and that DD^{\parallel}8 is chosen so that for every such critical point DD^{\parallel}9 there are at least three landmarks in general position. In particular, if DπD^\pi0 is a sufficiently dense grid with step size DπD^\pi1 over a domain DπD^\pi2 containing all trajectories, then DπD^\pi3 is injective on that family and DπD^\pi4 is a metric (Phillips et al., 2018). The proof sketch uses three landmarks around each critical point whose distance-circles intersect only at that point; equality of all landmark distances then forces the second trajectory to pass through the same critical points and ultimately coincide everywhere.

A second variant, DπD^\pi5, retains closest-point coordinates rather than only scalar distances. For each landmark DπD^\pi6,

DπD^\pi7

and

DπD^\pi8

This is a pseudometric via embedding into DπD^\pi9 and becomes a metric under essentially the same density and general-position assumptions. The key structural point is that TrajLoc replaces alignment-heavy trajectory comparison with a fixed-dimensional Euclidean embedding.

3. Landmark-distance TrajLoc: algorithms and empirical profile

Landmark selection admits two stated modes. Random landmarks may be chosen uniformly or by Poisson process in ϕ(τ)=(d(τ,1),,d(τ,m))\phi(\tau) = (d(\tau,\ell_1), \ldots, d(\tau,\ell_m))0. Data-driven landmarks may be selected from a small random sample of all GPS fixes or from points of interest known to be semantically important. For a trajectory with ϕ(τ)=(d(τ,1),,d(τ,m))\phi(\tau) = (d(\tau,\ell_1), \ldots, d(\tau,\ell_m))1 linear segments and ϕ(τ)=(d(τ,1),,d(τ,m))\phi(\tau) = (d(\tau,\ell_1), \ldots, d(\tau,\ell_m))2, each coordinate ϕ(τ)=(d(τ,1),,d(τ,m))\phi(\tau) = (d(\tau,\ell_1), \ldots, d(\tau,\ell_m))3 can be computed in ϕ(τ)=(d(τ,1),,d(τ,m))\phi(\tau) = (d(\tau,\ell_1), \ldots, d(\tau,\ell_m))4 time by projecting ϕ(τ)=(d(τ,1),,d(τ,m))\phi(\tau) = (d(\tau,\ell_1), \ldots, d(\tau,\ell_m))5 onto each segment, so computing ϕ(τ)=(d(τ,1),,d(τ,m))\phi(\tau) = (d(\tau,\ell_1), \ldots, d(\tau,\ell_m))6 takes ϕ(τ)=(d(τ,1),,d(τ,m))\phi(\tau) = (d(\tau,\ell_1), \ldots, d(\tau,\ell_m))7 time and ϕ(τ)=(d(τ,1),,d(τ,m))\phi(\tau) = (d(\tau,\ell_1), \ldots, d(\tau,\ell_m))8 space. Once the embeddings are precomputed, evaluating ϕ(τ)=(d(τ,1),,d(τ,m))\phi(\tau) = (d(\tau,\ell_1), \ldots, d(\tau,\ell_m))9 takes DD^{\parallel}0 time. Standard Lloyd’s algorithm can then be applied directly for k-means, with cost DD^{\parallel}1 for DD^{\parallel}2 trajectories, DD^{\parallel}3 clusters, and DD^{\parallel}4 iterations. The same embeddings can be stored in Euclidean ANN indices such as FLANN, Annoy, or KGraph, with typical build time DD^{\parallel}5 and sub-millisecond query time even for DD^{\parallel}6, DD^{\parallel}7 (Phillips et al., 2018).

The reported empirical evaluation spans clustering, classification, sensitivity to landmark weighting, and ANN search. In Geolife user 155 with 42 trajectories, using DD^{\parallel}8 random Beijing POIs and Lloyd’s algorithm with DD^{\parallel}9 or DπD^\pi0 yielded coherent "central city" versus "northern" clusters. In driver classification on Geolife, with 128 users and up to 200 trajectories each for a total of approximately 20k trajectories, 5-NN in DπD^\pi1 yielded mean error DπD^\pi2, comparable to the best prior DπD^\pi3LCSS, DTW DπD^\pi4 and better than Euclidean-critical-point distance DπD^\pi5. When fed to a Gaussian-kernel SVM, DπD^\pi6 and DπD^\pi7 both achieved approximately DπD^\pi8 error versus approximately DπD^\pi9 for the raw Euclidean-critical-point embedding.

On the UCI "GPS Trajectories" Bus vs Car task with 123 trajectories, 5-NN in τ\tau0 with τ\tau1 gave τ\tau2 error versus approximately τ\tau3-τ\tau4 for DTW, Hausdorff, Euclidean, and related baselines, and a Gaussian-SVM on the τ\tau5-vectors reduced error to τ\tau6. A landmark-sensitivity experiment used two synthetic classes of 30 trajectories each that differed only in whether they passed near a special POI τ\tau7. A small uniform landmark set produced approximately τ\tau8-τ\tau9 error, while re-weighting R2\mathbb R^20’s coordinate by R2\mathbb R^21 with weights summing to R2\mathbb R^22 reduced 5-NN error in R2\mathbb R^23 to R2\mathbb R^24 and weighted Gaussian-SVM error to R2\mathbb R^25. For ANN search on the full Geolife dataset with R2\mathbb R^26, building a KGraph index on R2\mathbb R^27 for R2\mathbb R^28 took R2\mathbb R^29-L={1,,m}L=\{\ell_1,\ldots,\ell_m\}0 and used approximately L={1,,m}L=\{\ell_1,\ldots,\ell_m\}1 memory, while each 1-NN query took L={1,,m}L=\{\ell_1,\ldots,\ell_m\}2-L={1,,m}L=\{\ell_1,\ldots,\ell_m\}3 at recall L={1,,m}L=\{\ell_1,\ldots,\ell_m\}4. By contrast, state-of-the-art dedicated DFT/DTW indices were reported to require minutes on hundreds of cores for a single query.

These results establish the landmark-based TrajLoc as a Euclideanization strategy: trajectory analysis is reduced to vector analysis once the landmark embedding has been computed.

4. Trajectory-attention TrajLoc: localization inside video diffusion

The 2026 TrajLoc method addresses precise multi-object motion control in text-and-image-conditioned video diffusion. Its central operation is performed inside cross-attention layers. In a standard layer, visual queries L={1,,m}L=\{\ell_1,\ldots,\ell_m\}5 attend to text keys L={1,,m}L=\{\ell_1,\ldots,\ell_m\}6 with

L={1,,m}L=\{\ell_1,\ldots,\ell_m\}7

and the output is

L={1,,m}L=\{\ell_1,\ldots,\ell_m\}8

For each object L={1,,m}L=\{\ell_1,\ldots,\ell_m\}9 and frame mm0, TrajLoc constructs a 2D Gaussian heatmap over the latent grid,

mm1

These per-frame maps are bilinearly downsampled to the latent grid, flattened over mm2 to a vector mm3, and normalized so that mm4 (Sela et al., 1 Jul 2026).

If mm5 is the column index in mm6 corresponding to the text token for object mm7, the method replaces that column with mm8 and then renormalizes every row: mm9

DD^{\parallel}00

The modified output is

DD^{\parallel}01

which is used in place of the standard cross-attention output. In architectures such as WaN-2.1, where the full matrix DD^{\parallel}02 is explicitly built, this replacement is exact. In CogVideoX-5B, the full attention matrix is too large to materialize, approximately DD^{\parallel}03 per layer, so the method uses an efficient two-SDPA approximation that splits keys and values into supervised columns DD^{\parallel}04 and the remaining set DD^{\parallel}05, computes two small SDPA calls, and mixes them according to the total heatmap mass DD^{\parallel}06. The reported practical effect is that the attention cost per layer is doubled while remaining within memory limits.

The method’s stated departure point is that existing approaches entangle multiple trajectories within a shared, dense conditioning signal, which makes object-level correspondence difficult to preserve in crowded scenes. TrajLoc instead enforces a strict, per object spatial constraint that isolates instances independently. The same per object token interface carries trajectory and depth through a learned embedding and preserves identity by encoding first frame appearance in place of an object token. This design is reported to scale to scenes with up to 20 simultaneously controlled objects and to remain effective under occlusions and path crossings.

5. Token conditioning, optimization, and reported results in diffusion TrajLoc

Trajectory and appearance are encoded as dedicated text tokens. For object DD^{\parallel}07, the trajectory input is a sequence

DD^{\parallel}08

where DD^{\parallel}09 is per-frame depth and DD^{\parallel}10 is a normalized time channel. The encoder DD^{\parallel}11 consists of three 1D convolution layers with stride DD^{\parallel}12 and channels DD^{\parallel}13, followed by BN and GELU, then flattening to a DD^{\parallel}14-dimensional vector DD^{\parallel}15, and finally a two-layer MLP DD^{\parallel}16 producing a DD^{\parallel}17-dimensional trajectory token DD^{\parallel}18. Pretraining freezes the I2V model’s text encoder and learns DD^{\parallel}19 with

DD^{\parallel}20

After DD^{\parallel}21 steps and approximately DD^{\parallel}22 parameters, the decoder is discarded and DD^{\parallel}23 is frozen.

The appearance encoder DD^{\parallel}24 takes the first-frame VAE latent DD^{\parallel}25 and object center DD^{\parallel}26. It uses one stride-2 convolution DD^{\parallel}27 and two stride-1 convolutions DD^{\parallel}28 with BN and GELU, producing an DD^{\parallel}29-channel feature map at DD^{\parallel}30. The DD^{\parallel}31-dimensional feature sampled at DD^{\parallel}32 is projected by a DD^{\parallel}33 linear layer to DD^{\parallel}34. This replaces the generic category token embedding such as "girl" or "ball" in the prompt. Prompt construction uses a template of the form: "Scene where DD^{\parallel}35 moves [trajDD^{\parallel}36] and DD^{\parallel}37 moves [trajDD^{\parallel}38] …". Each DD^{\parallel}39 is replaced with the frozen output DD^{\parallel}40, and each category embedding DD^{\parallel}41 is replaced with DD^{\parallel}42.

Fine-tuning uses LoRA on all cross-attention layers of a pretrained I2V diffusion model, specifically CogVideoX-5B or WaN 2.1-14B, with rank DD^{\parallel}43 and DD^{\parallel}44. Only the LoRA weights and the appearance encoder are trained; the original model weights and DD^{\parallel}45 remain frozen. The objective combines standard diffusion noise-prediction MSE over all pixels with the same noise-MSE restricted to small bounding boxes centered on each trajectory point: DD^{\parallel}46 Training uses AdamW and bf16. The reported schedules are DD^{\parallel}47 steps for CogVideoX-5B with batch size DD^{\parallel}48 H100s, approximately DD^{\parallel}49, and DD^{\parallel}50 steps for WaN 2.1-14B with batch size DD^{\parallel}51 H100s, approximately DD^{\parallel}52. Diffusion uses DD^{\parallel}53 steps, classifier-free guidance DD^{\parallel}54 for CogVideoX or DD^{\parallel}55 for WaN, and DD^{\parallel}56 px (Sela et al., 1 Jul 2026).

Evaluation covers six datasets and DD^{\parallel}57 total clips with up to DD^{\parallel}58 simultaneous objects, using static-camera scenes of DD^{\parallel}59 frames at DD^{\parallel}60. The in-distribution synthetic sets are MoVi-Extended, Pool, Football, and MOTSynth; the out-of-distribution real-world sets are MOT17 and DAVIS 2017. Metrics are PSNR, LPIPS, FVD, and EPE, where EPE is the DD^{\parallel}61 distance between ground-truth and tracked object centers in the generated video. Across both backbones and all six datasets, TrajLoc is reported to outperform four baselines—Tora, MagicMotion, ATI, and Wan-Move—by an average gain of DD^{\parallel}62 PSNR with range DD^{\parallel}63-DD^{\parallel}64 and an average DD^{\parallel}65 reduction in EPE with range DD^{\parallel}66-DD^{\parallel}67. On MoVi, example numbers are: for CogVideoX, DD^{\parallel}68 versus DD^{\parallel}69-DD^{\parallel}70 and EPE DD^{\parallel}71 versus DD^{\parallel}72-DD^{\parallel}73; for WaN, DD^{\parallel}74 versus DD^{\parallel}75-DD^{\parallel}76 and EPE DD^{\parallel}77 versus DD^{\parallel}78-DD^{\parallel}79.

Ablations identify attention localization as the most critical component. Removing attention localization on WaN-14B causes PSNR to drop by DD^{\parallel}80 on MoVi and EPE to increase by a factor of DD^{\parallel}81. Removing trajectory tokens reduces PSNR by DD^{\parallel}82 and increases EPE by up to DD^{\parallel}83. Removing the depth channel yields a similar drop in depth-sensitive scenes, and removing the appearance encoder causes moderate FVD degradation. For CogVideoX, the self-attention approximation ablation reports that the 2-SDPA replacement is stronger on crowded datasets such as MOTSynth and MOT17, whereas the additive correction variant is slightly stronger on far-out-of-distribution DAVIS. Qualitatively, the reported failure modes of baselines are missing objects under occlusion, drifting over time, hallucinating duplicates, and failing in crowded crossings.

6. Relation to adjacent trajectory methods

TrajLoc should be distinguished from trajectory methods that solve next-location prediction rather than similarity search or generative motion control. TTDM, the "Travel Time Difference Model," defines a user trajectory as

DD^{\parallel}84

uses the actual travel time from all passed locations to each candidate next location, and compares it with a shortest-path travel time on a time-slot-indexed road-network graph. For a candidate location DD^{\parallel}85, the model aggregates

DD^{\parallel}86

and forms the average excess

DD^{\parallel}87

A decreasing function such as DD^{\parallel}88 or DD^{\parallel}89 converts this to

DD^{\parallel}90

which can be linearly interpolated with a first-order Markov model,

DD^{\parallel}91

The reported top-1 accuracy results are DD^{\parallel}92, DD^{\parallel}93, and DD^{\parallel}94 for MM, TTDM, and TTDM+MM on VPR, and DD^{\parallel}95, DD^{\parallel}96, and DD^{\parallel}97 on Taxi, with best interpolation weight DD^{\parallel}98-DD^{\parallel}99 (Liu et al., 2020).

The conceptual distinction is straightforward. Landmark-based TrajLoc embeds a completed trajectory into DπD^\pi00 and studies metric geometry, Euclidean learning, and ANN search. Diffusion-based TrajLoc injects trajectory and appearance into cross-attention and prompt tokens to control future video frames. TTDM predicts a next location from a partial trajectory using travel-time differences and Markov interpolation. A common source of confusion is therefore terminological rather than methodological: the three methods all process trajectories, but they belong to different task families, use different representations, and are evaluated with different criteria.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to TrajLoc.