Docs
Docs pages

Recipes

Wildlife: sort a card of camera-trap clips

A trail camera comes back with 400 clips, most of them wind in the grass. You want the ones with animals, with a count and what they were doing. Leans on detection Pending

import csv, pathlib
from vitalsbio import VitalsBio, InvalidRequestError

client = VitalsBio()
with open("card.csv", "w", newline="") as out:
    w = csv.writer(out)
    w.writerow(["clip", "animals", "species", "top_behaviours", "request_id"])
    for clip in sorted(pathlib.Path("card").glob("*.mp4")):
        try:
            r = client.behavior(clip, max_seconds=15)          # no species: detect any animal
        except InvalidRequestError as e:                        # unreadable file, too large
            w.writerow([clip.name, "", "", e.code, e.request_id]); continue
        a = r["animals"]
        w.writerow([clip.name, len(a), " ".join(sorted({x["species"] or "?" for x in a})),
                    " ".join(x["top"] or "?" for x in a), r.request_id])

What this can and can't tell you