In my live Kinect viewer, I can turn the cloud and look at the room from the side. I added boxes to that view so I could watch specific parts of the room. A box in the open passage and a box behind a piece of furniture can both contain zero points. I can see through one of them. The sensor has no view of the other.
A count of points inside a box tells me about surfaces the Kinect measured there. To decide what zero means, I also need to know where the other measurements ended.
Where the rays end
I define a zone as an axis-aligned box in the Kinect’s coordinate system. Its center and dimensions are in metres. Coordinates belong to the fixed sensor, so turning the view leaves the box in place. Moving the sensor changes the space those coordinates describe.
For every measured point, the zone evaluator considers a ray from
the sensor origin through that point. I can write the ray as t × point,
with the measurement at t = 1. The intersection calculation gives me
the interval of that ray inside the box. A point in the box contributes an
inside sample. If the interval ends before 1, the measurement is behind the
box and the ray contributes to the through count. If the interval starts
after 1, the ray reaches a surface before it reaches the box. I count that
as blocked. Rays that miss the box contribute nothing.
A pixel without valid depth gives me no endpoint for this calculation. Even when some rays go all the way through, I have only sampled paths through the volume. A small object could sit between those paths.

Blue marks the clear passage, green a measured surface and amber the occluded box. The side panel shows the blue and amber zones. Open the full capture.
In the final live check, the passage had no inside samples and more than 31,000 rays through it in one logged observation. The box behind visible surfaces also had no inside samples, with zero through rays and more than 2,000 blocked rays. The third box contained a stationary surface. Those three states held during a separate 60-second measurement window in the same run, so there were no transitions to log in that window. The regression tests exercise entry and exit on this version.
When a change becomes an event
The viewer calls a zone occupied (Presence detected) when it sees at least 100 samples inside. To call it clear (No surface detected), it needs at most 50 inside and at least 100 rays through. Between 51 and 99 inside samples, it can hold the previous confirmed state. The gap gives the state room to survive small fluctuations at the boundary. The counts are application thresholds for sampled depth.
The monitor waits for three distinct observations of the new state in a row, spanning at least 200 ms of captured host arrival time. The first confirmed state sets a baseline silently. A chair already in the box when I press Start has no entry time I can observe. A later confirmed change adds an Entered or Exited entry with the depth sequence that confirmed it.
A short loss of visibility can leave the previous confirmed state available for comparison. When a result arrives more than 750 ms after the last usable observation on the host arrival clock, the monitor abandons that baseline. A newly visible clear zone can then establish a baseline of its own.
The ray counts come back from a browser worker. The monitor checks that a result still belongs to the current observation and zone configuration before using it. The regression tests include a delayed result after depth goes missing. By the time that answer arrives, the monitor has invalidated the request. The last cloud can still be visible on screen while the zone no longer has current evidence.
After an obstruction that lasts longer than those 750 ms, I can see the passage come back clear while the journal still ends with Entered. The clear state belongs to a new baseline, so it adds no Exited entry for that passage. I have a view of the zone again, with a gap in what I was able to observe.
Comments, questions, or just a reaction?
Send an email to ~bounga/bounga.org-discuss@lists.sr.ht. It is public and archived, so other readers can follow along and answer too.