From e4c0f66922a3bc026a39f6410c1cabeee552d6d8 Mon Sep 17 00:00:00 2001 From: ruv Date: Mon, 30 Mar 2026 14:50:38 -0400 Subject: [PATCH] fix(server): use max instead of sum for multi-node person aggregation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With nodes in the same room, each node sees the same people. Summing per-node counts double-counted (2 nodes × 1 person = 2 persons). Now uses max() so 2 nodes × 1 person = 1 person. Verified on real hardware: COM6 (node 1) + COM9 (node 2) on ruv.net, estimated_persons=1 with 1 person in room. Co-Authored-By: claude-flow --- .../crates/wifi-densepose-sensing-server/src/main.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rust-port/wifi-densepose-rs/crates/wifi-densepose-sensing-server/src/main.rs b/rust-port/wifi-densepose-rs/crates/wifi-densepose-sensing-server/src/main.rs index a8e677ec..86ccee32 100644 --- a/rust-port/wifi-densepose-rs/crates/wifi-densepose-sensing-server/src/main.rs +++ b/rust-port/wifi-densepose-rs/crates/wifi-densepose-sensing-server/src/main.rs @@ -3210,11 +3210,14 @@ async fn udp_receiver_task(state: SharedState, udp_port: u16) { else { 0.05 }; // Aggregate person count across all active nodes. + // Use max (not sum) because nodes in the same room see the + // same people — summing would double-count. let now = std::time::Instant::now(); let total_persons: usize = s.node_states.values() .filter(|n| n.last_frame_time.map_or(false, |t| now.duration_since(t).as_secs() < 10)) .map(|n| n.prev_person_count) - .sum(); + .max() + .unwrap_or(0); // Build nodes array with all active nodes. let active_nodes: Vec = s.node_states.iter() @@ -3413,11 +3416,14 @@ async fn udp_receiver_task(state: SharedState, udp_port: u16) { else { 0.05 }; // Aggregate person count across all active nodes. + // Use max (not sum) because nodes in the same room see the + // same people — summing would double-count. let now = std::time::Instant::now(); let total_persons: usize = s.node_states.values() .filter(|n| n.last_frame_time.map_or(false, |t| now.duration_since(t).as_secs() < 10)) .map(|n| n.prev_person_count) - .sum(); + .max() + .unwrap_or(0); // Build nodes array with all active nodes. let active_nodes: Vec = s.node_states.iter()