Recipes
Pets: a dog's day in one line
A home camera saves a clip whenever something moves. You want "walked 22% of the time, lay down 61%" for the owner's app. Leans on behaviour Live
import { VitalsBio } from "@vitalsbio/sdk";
import { readFile } from "node:fs/promises";
const client = new VitalsBio();
const total = {}; let frames = 0;
for (const path of clipsFromToday) { // your motion clips, each under 25 MB
const r = await client.behavior({ video: await readFile(path), species: "dog", max_seconds: 20 });
for (const a of r.animals) for (const f of a.frames) {
frames++;
for (const [b, p] of Object.entries(f.behaviour)) total[b] = (total[b] || 0) + p;
}
}
const day = Object.entries(total).map(([b, p]) => [b, p / frames]).sort((x, y) => y[1] - x[1]);
console.log(day.slice(0, 3).map(([b, p]) => `${b} ${Math.round(p * 100)}%`).join(", "));
What this can and can't tell you
- Shares are of the time the dog was on camera, not of the day.
- The behaviour test that passed was run on cattle video. How well it carries to dogs is the cross-species check Pending, so say "estimated" in your app until that is scored.
- With two dogs in the house the API can't tell you which is which across clips: identity is Pending
- Call from your server, not from the phone app. A key inside an app can be pulled out of it.
- Try it now:
client.behavior({ sample: "dog-walk" }).