rhombus-node-mcp
Version:
MCP server for Rhombus API
63 lines (62 loc) • 2.46 kB
JavaScript
import { postApi } from "../network/network.js";
function mapEmbedding(e) {
return {
deviceUuid: e.deviceUuid ?? undefined,
locationUuid: e.locationUuid ?? undefined,
timestamp: e.timestamp ?? undefined,
embedding: (e.embedding ?? []).filter((n) => n != null),
embeddingId: e.embeddingId ?? undefined,
stableTrackId: e.stableTrackId ?? undefined,
thumbnailUri: e.thumbnailUri ?? undefined,
};
}
/**
* Lists the person re-identification embeddings recorded on the given camera(s) in a time window —
* i.e. the people the camera's human-detection AI saw. Used to grab the embedding of the person standing
* at a door at a known moment (e.g. a badge tap), so it can be tracked across other cameras.
*/
export async function listReidentificationEmbeddings(args, requestModifiers, sessionId) {
const body = {
deviceUuids: args.deviceUuids,
locationUuid: args.locationUuid,
startTimestampMs: args.startTimestampMs,
endTimestampMs: args.endTimestampMs,
limit: args.limit ?? 100,
};
const res = await postApi({
route: "/search/listReidentificationEmbeddings",
body,
modifiers: requestModifiers,
sessionId,
});
if (res.error)
throw new Error(res.errorMsg ?? "listReidentificationEmbeddings failed");
return (res.embeddings ?? []).map(mapEmbedding);
}
/**
* Searches person re-identification matches for a given appearance embedding across cameras and time —
* "find this same person elsewhere". Returns sightings ordered by similarity (distance asc; lower is a
* closer match).
*/
export async function searchReidentificationMatchesByEmbedding(args, requestModifiers, sessionId) {
const body = {
searchEmbedding: args.searchEmbedding,
deviceUuids: args.deviceUuids,
locationUuid: args.locationUuid,
startTimestampMs: args.startTimestampMs,
endTimestampMs: args.endTimestampMs,
limit: args.limit ?? 100,
};
const res = await postApi({
route: "/search/searchReidentificationMatchesByEmbedding",
body,
modifiers: requestModifiers,
sessionId,
});
if (res.error)
throw new Error(res.errorMsg ?? "searchReidentificationMatchesByEmbedding failed");
return (res.matches ?? []).map((m) => ({
...mapEmbedding(m.embedding ?? {}),
distance: m.distance ?? undefined,
}));
}