Docs
Docs pages

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