Back
Computer Vision / AI2024

CowRec System

PythonYOLOv8OpenCVFastAPIDocker
CowRec System

Overview

A computer vision system designed for precision livestock farming. It uses YOLOv8 and convolutional neural networks to process real-time video feeds, allowing for the identification, tracking, and behavioral analysis of individual animals. The architecture runs in edge computing environments, collecting health and productivity data locally to enable data-driven decisions in dairy production.

Implementation

// production excerpt
edge/detect.py
# Real-time herd inference at the edge. Raw video never leaves the farm.
from ultralytics import YOLO

model = YOLO("weights/cowrec-v8.pt")           # fine-tuned on the on-farm dataset

for frame in stream.read():                     # RTSP feed from barn cameras
    result = model.track(frame, persist=True, conf=0.6, verbose=False)[0]

    for box, tid in zip(result.boxes.xyxy, result.boxes.id):
        cow = registry.resolve(int(tid))        # stable per-animal identity
        cow.observe(bbox=box, at=frame.ts)
        if cow.gait_anomaly():                   # early lameness / health signal
            alerts.enqueue(cow.id, kind="gait", severity="review")

    # Only aggregated telemetry leaves the edge box — never raw frames.
    telemetry.flush(registry.snapshot())

Real-time per-animal tracking at the edge — only aggregates leave the box, never raw video.