Open-source · Edge AI · GPLv3

🐷 animal-counter

Real-time bidirectional pig counter on an NVIDIA Jetson Orin Nano — YOLO → TensorRT detection, OC-SORT tracking with custom anti-ID-switch guards, and a fixed-camera counting line. Deployed on single-node K3s via Ansible.

Python OC-SORT TensorRT Jetson Orin Nano K3s Ansible GPL-3.0

How it works

A fixed camera watches the aisle. Every frame runs through a hardware-accelerated detection + tracking pipeline, and a virtual counting line registers each animal that crosses it — right→left counts +1, left→right counts -1.

📷 Video frame→ 🔍 YOLO detection→ ⚡ TensorRT engine→ 🧭 OC-SORT tracking→ 🛡️ Anti-ID-switch guards→ 🔢 Counting line→ 🎥 Auto-recorded clips
📹 Demo video / GIF coming soon — drop a screen capture here to boost star conversion.

Features

🧭

OC-SORT tracking

Keeps stable track IDs across frames. Custom anti-ID-switch guards prevent double-counting when animals occlude each other or re-enter the frame.

⚡

TensorRT acceleration

YOLO weights compiled to a TensorRT engine for low-latency edge inference on the Jetson Orin Nano GPU.

🔢

Bidirectional counting line

A fixed virtual line: crossings right→left are +1, left→right are -1. Hysteresis tuned against regressions on real footage.

🎥

Auto-recorded clips

Counting sessions are recorded to video clips with the live count overlay, for audit and replay.

📦

Single-node K3s

The countingapp pod runs on K3s with a hostPath live-code mount for rsync + hot restart. Deployed and rendered via Ansible + Jinja2 templates.

✅

Reference-video validation

A validation script runs a reference clip and compares the pig count to the expected value derived from the filename — a built-in regression gate.

Companion app

A separate repo, animal-counter-companion, holds the Android phone app and the Jetson host companion (an HTTP bridge). The companion and the countingapp pod communicate only via shared files in /data/orin/files — there is no HTTP/RPC between them. See docs/IPC_CONTRACT.md (kept identical in both repos).

Get started