Inside AI
← Ideas Lab
Proposed idea / Edge AI

Count objects without keeping frames

Proposed enhancement · Turn a stream of detections into one count per crossing, retaining only aggregate totals.

Device profile · Raspberry Pi AI HAT+ ↗

Use the tracker’s output

Hailo’s full detection pipeline includes tracking. At the application callback, select bottle detections and check for exactly one tracking ID before treating detections in consecutive frames as the same object. An absent or ambiguous ID becomes an unresolved observation. Hailo’s tracking example Hailo’s Python callback

Proposed counting rule

For the proposed one-way counter, arm a track once its box center is to the left of the band. Count that track once after it reaches the right edge. For a short test, keep the set of counted IDs until the end of the session. A long-running installation also needs an expiry policy that handles tracker ID reuse.

Try the event rule without hardware

This Python example was run with invented track positions. A stable track produces [7] once even across repeated right-side observations. Switching from ID 7 to ID 8 mid-crossing produces an empty list: a real crossing would be missed. This checks the event rule only. Whether a physical camera preserves a track ID through an occlusion still needs a bench run.

def crossing_events(frames):
    armed, counted = set(), set()
    for track_id, x in frames:
        if x <= 0.45:
            armed.add(track_id)
        if x >= 0.55 and track_id in armed and track_id not in counted:
            counted.add(track_id)
            yield track_id

# Synthetic horizontal positions, normalized to the width of the frame.
print(list(crossing_events([(7, .30), (7, .49), (7, .53), (7, .60), (7, .58)])))
print(list(crossing_events([(7, .30), (8, .60)])))

Break the rule on purpose

Try a stationary bottle near the line, one bottle crossing twice, and two crossing together through an occlusion. Keep a manual count by direction. A missed ID can split a crossing, while an ID swap can merge two. Report extra and missed events separately. This is an untested design; the examples establish the available metadata, not the counter’s reliability.

Primary sources

Hailo’s tracking example Hailo’s Python callback