@asunited/ai-engine
v0.2.0
Published
Typed client for the ASU AI Engine: video analytics from CCTV and other video sources. Attendance, behavioural analysis and task-completion verification.
Downloads
232
Readme
@asunited/ai-engine
Typed client for the ASU AI Engine: video analytics for supported-living settings. Attendance, behavioural analysis, and task-completion verification from CCTV or any other video source.
npm install @asunited/ai-engineQuick start
import { createClient } from "@asunited/ai-engine";
const engine = createClient({
baseUrl: "https://aiengine-api.asunited.com.sg",
apiKey: process.env.ASU_AI_ENGINE_KEY,
});
// Pull 20 seconds off a camera and prepare it for analysis
const clip = await engine.ingestStream({
url: "rtsp://user:[email protected]:554/Streaming/Channels/101",
seconds: 20,
});
// Did the client do the task in an acceptable order?
const result = await engine.checkSequence("prepare_vegetables", ["A", "C", "B", "D"]);
if (!result.completed) {
for (const v of result.violations) console.warn(v.message, v.detail);
}What this talks to
The engine splits the work in two, and the split is the point. A model answers one narrow question per window of video (which step is this?). Whether the observed order is acceptable is decided by a deterministic grammar, so the part a supervisor will challenge gives the same answer every time.
Ingest
await engine.ingestYouTube({ url: "https://youtu.be/UqIsK6NdJ7w" });
await engine.ingestStream({ url: "rtsp://…", seconds: 30 });
await engine.ingestUpload(fileBlob, "kitchen.mp4");Workflows
A workflow is its steps plus a partial order over them.
await engine.saveTask({
task_id: "prepare_vegetables",
label: "Prepare vegetables",
steps: {
A: { name: "take", prompt_hint: "picks up a raw vegetable" },
B: { name: "wash", prompt_hint: "rinsed under running water" },
C: { name: "cut", prompt_hint: "cut on a chopping board" },
D: { name: "cook", prompt_hint: "placed into a pan on a stove" },
},
required: ["A", "B", "C", "D"],
precedence: [
{ earlier: "A", later: "B" }, { earlier: "A", later: "C" },
{ earlier: "A", later: "D" }, { earlier: "B", later: "D" },
{ earlier: "C", later: "D" },
],
});Wash and cut may happen in either order; both must follow take and precede
cook. A,B,C,D and A,C,B,D pass. A,D,B,C and A,D,C,B fail.
Attendance and behaviour
const roll = await engine.rollCall({
sessionId: "morning",
expected: ["adam.k", "brenda.l"],
recognised: ["adam.k", "unknown-01"],
});
roll.alarm; // true
roll.unexpected; // ["unknown-01"]
const state = await engine.assessBehaviour({
subjectId: "client-01",
indicators: { violent_hand_movement: 0.9, facial_distress: 0.8 },
});
state.state; // "meltdown"Errors
Every non-2xx throws EngineError with status, code and detail.
Licence
Proprietary. © AS United Pte Ltd.
