code wiki / (root) / nx_motion.nx

nx_motion.nx

buildroot/runtime/nx_motion.nx

18817 B459 linesdepth 5pulls 6 transitivereach 3 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 · 3 importers

syscalls.nx nx_image.nx nx_motion.nx nx_dynaoracle.nx nx_dynaoracle_gate.nx nx_motion_test.nx

imports: syscalls.nxnx_image.nx

imported by: nx_dynaoracle.nxnx_dynaoracle_gate.nxnx_motion_test.nx

structs

97struct FlowField
323struct MotionPyr

consts

32const NX_MOTION_Q: i64 = 256 // Q8 sub-pixel
33const NX_MOTION_WIN: i64 = 5 // 5x5 integration
40const NX_MOTION_LK_DOMAIN_Q8: i64 = (NX_MOTION_WIN / 2) * NX_MOTION_Q
321const NX_MOTION_PYR_MAX: i64 = 6
334const NX_MOTION_PYR_BYTES: i64 = 72

functions

46func nx_motion_frame_diff(a: *Image, b: *Image) -> *Image
71func nx_motion_temporal_grad_into(frame1: *Image, frame2: *Image, dst: *ImageS64) -> *ImageS64
109func nx_motion_lucas_kanade_into(frame1: *Image, frame2: *Image,
212func nx_motion_mean_flow_rect_bounded(flow: *FlowField, mag_threshold: i64, max_mag_q8: i64,
269func nx_motion_mean_flow_rect(flow: *FlowField, mag_threshold: i64,
278func nx_motion_mean_flow(flow: *FlowField, mag_threshold: i64,
called by 1: main calls 1: nx_motion_mean_flow_rect
290func nx_motion_temporal_grad(frame1: *Image, frame2: *Image) -> *ImageS64
295func nx_motion_lucas_kanade(frame1: *Image, frame2: *Image) -> *FlowField
339func nx_motion_pyr_levels(w: i64, h: i64) -> i64
called by 1: nx_motion_pyr_new
355func nx_motion_pyr_new(w: i64, h: i64) -> *MotionPyr
387func nx_motion_copy_into(src: *Image, dst: *Image) -> *Image
402func nx_motion_mean_flow_pyr(p: *MotionPyr, f1: *Image, f2: *Image, mag_threshold: i64,