import { AutoProcessorMediaNode, ProcessorNodeSettings } from "./common"; import { NamedChannelLayout, Resolution, SampleFormat, SampleRate } from "./types"; import { FrameRate } from "../types"; /** * @public * The data type of the elements in a tensor. */ export type EmbeddedAIElementDataType = "FLOAT" | "UINT8" | "INT8" | "UINT16" | "INT16" | "INT32" | "INT64" | "STRING" | "BOOL" | "FLOAT16" | "DOUBLE" | "UINT32" | "UINT64" | "COMPLEX64" | "COMPLEX128" | "BFLOAT16"; /** * @public * Represents a single output tensor from an inference operation. */ export interface EmbeddedAITensor { /** The name of the output tensor, as defined by the model. */ name: string; /** The data type of each element in the tensor. */ dataType: EmbeddedAIElementDataType; /** The shape of the tensor. */ dimensions: number[]; /** The raw tensor data. The interpretation of these bytes depends on the dataType. */ data: Uint8Array; } /** * @public * The pixel format that the model expects. */ export type EmbeddedAIPixelFormat = "rgb"; /** * @public * Settings for video-input models */ export interface EmbeddedAIVideoInput { /** The input type */ inputType: "video"; /** The target resolution that Norsk should scale the video to before sending it to the inference engine. */ targetResolution: Resolution; /** The pixel format that the model expects. Norsk will handle the conversion. */ pixelFormat: EmbeddedAIPixelFormat; /** The frame rate that the model expects. Norsk will handle the conversion. */ frameRate: FrameRate; } /** * @public * Settings for audio-input models */ export interface EmbeddedAIAudioInput { /** The input type */ inputType: "audio"; /** The channel layout */ channelLayout: NamedChannelLayout; /** The sample rate */ sampleRate: SampleRate; /** The sample format */ sampleFormat: SampleFormat; /** How many samples per inference call */ numSamplesPerInference: number; } export type EmbeddedAIInputType = EmbeddedAIVideoInput | EmbeddedAIAudioInput; /** * @public * Base settings common to all data types */ interface EmbeddedAISettingsBase extends ProcessorNodeSettings { /** The path to the .onnx model file on the Norsk server's filesystem. */ modelPath: string; /** The input to the model */ modelInput: EmbeddedAIInputType; /** * Callback invoked with the results of the AI inference for each frame. * @param detections An array of objects detected in the frame. */ onInferenceResult: (tensors: EmbeddedAITensor[]) => void; } /** * @public * The union of all possible input type configurations for the EmbeddedAINode */ export type EmbeddedAINodeSettings = (EmbeddedAISettingsBase & { /** Provide the model with 8-bit unsigned integer pixel data [0, 255]. */ dataType: "uint8"; }) | (EmbeddedAISettingsBase & { /** Provide the model with 32-bit float pixel data, normalized to the range [0.0, 1.0]. */ dataType: "float32_normalized"; }) | (EmbeddedAISettingsBase & { /** Provide the model with 32-bit float pixel data, applying a custom scaling factor. */ dataType: "float32_custom"; /** The custom scale factor to multiply each pixel component by. */ normalizationScale: number; }); /** * @public * A media node that can run a generic AI model for tasks like object detection. */ export declare class EmbeddedAINode extends AutoProcessorMediaNode<"audio" | "video"> { } export {}; //# sourceMappingURL=embeddedAI.d.ts.map