code wiki / (root) / nx_motion.nx

nx_motion.nx

buildroot/runtime/nx_motion.nx

6488 B197 linesdepth 5pulls 6 transitivereach 1 importersview sourcekind librarytopic motion
docsdependenciesstructsconstsfunctions

about

nx_motion.nx -- frame-to-frame motion (Lucas-Kanade optical flow). Brightness-constancy + small-motion assumption: I(x, y, t) = I(x + u, y + v, t + 1) Taylor expand: I_x * u + I_y * v + I_t = 0 Over an N-pixel window this is N equations in 2 unknowns; solve via 2x2 least-squares (normal equations + Cramer's rule). What this unlocks: + motion detection (frame diff) + tracking (per-pixel flow vectors) + camera-motion estimation (mean flow direction) + scene-cut detection (flow magnitude spike) + activity recognition substrate Returns flow in Q8 sub-pixel precision (1 unit = 1/256 pixel). 5x5 integration window default. genealogy_id: lucas_kanade_1981 + horn_schunck_1981 lineage_id: gradient_based_optical_flow + 2x2_least_squares

dependencies 2 imports · 1 importers

syscalls.nx nx_image.nx nx_motion.nx nx_motion_test.nx

imports: syscalls.nxnx_image.nx

imported by: nx_motion_test.nx

structs

90struct FlowField

consts

32const NX_MOTION_Q: i64 = 256 // Q8 sub-pixel
33const NX_MOTION_WIN: i64 = 5 // 5x5 integration

functions

39func nx_motion_frame_diff(a: *Image, b: *Image) -> *Image
64func nx_motion_temporal_grad(frame1: *Image, frame2: *Image) -> *ImageS64
95func nx_motion_lucas_kanade(frame1: *Image, frame2: *Image) -> *FlowField
163func nx_motion_mean_flow(flow: *FlowField, mag_threshold: i64,
called by 1: main calls 1: nx_image_s64_get