@abpd2001/rpicam
Version:
A lightweight library to control CSI-2 camera modules via any raspberry pi can read camera module but is dependent to shell.
166 lines (165 loc) • 9.14 kB
TypeScript
import type { ICameraDescriptor, ICameraOptions, ICameraStillOptions, ICameraVideoOptions, IOutputException } from "./interfaces/index";
import { ChildProcessWithoutNullStreams } from "node:child_process";
import { EventEmitter } from "node:events";
import { TASKMAN } from "./common";
declare class LiveMode extends EventEmitter {
constructor();
}
export declare class RPICam extends TASKMAN {
private camera;
private options?;
private reserved;
/** @type {{ id: string; pid: number }[]} */
/**@prop `tasks` is current async opreations running on camera with pid and id.*/
tasks: {
id: string;
pid: number;
}[];
/** @type {LiveMode} */
/** @prop live streaming of camera comes to `live` event emitter of class.*/
live: LiveMode;
/**
* @constructor class of `RPICam`, also this constructor can wait until camera get ready.
* @param {number} camera is number of camera to get in use.
* @param {ICameraOptions} options is avail options and formatting and setting camera by manual and method of capturing.
*/
constructor(camera: number, options?: ICameraOptions);
private _serveStill_params;
private _serveVideo_params;
/**
* Reserve camera to not get in use of other process by opening a infinite and cancellable stream of recording.
* @returns {Promise<IOutputException>} reservation status.
*/
reserve(): Promise<IOutputException>;
/**
* kills process of reservation of camera and make it free.
* @returns {IOutputException} status of unlocking camera.
*/
unlockReserve(): IOutputException;
/**
* Check reservation of camera by this process.
* @returns {boolean} is reserved or not.
*/
isReserved(): boolean;
/**
* Same as `serveStill` but is sync.
* @param {string} filename is path of saving image, also is okay set it to empty string for streaming options and everything like stream should not be outputed on a file or use `serveStillCutomSync` to set everything manually.
* @param {number} width (no description needed)
* @param {number} height (no description needed)
* @param { ICameraStillOptions & { stream?: boolean }} options of serving (full settings and options of camera and rpicam).
* @returns {IOutputException} capturing status or stream event emitter output.
*/
serveStillSync(filename: string, width: number, height: number, options?: ICameraStillOptions & {
stream?: boolean;
}): IOutputException;
/**
* Same as `serveStillCustom` but is sync.
* @param {number} width (no description needed)
* @param {number} height (no description needed)
* @param { ICameraStillOptions & {stream?: boolean,output?: string,format?: string}} options of serving (full settings and options of camera and rpicam).
* @returns {IOutputException} capturing status or stream event emitter output.
*/
serveStillCustomSync(width: number, height: number, options?: ICameraStillOptions & {
stream?: boolean;
output?: string;
format?: string;
}): IOutputException;
/**
* Same as `serveStill` But everything except some required things must setted manually.
* @param {number} width (no description needed)
* @param {number} height (no description needed)
* @param {string} id of task for managing.
* @param { ICameraStillOptions & {stream?: boolean,output?: string,format?: string}} options of serving (full settings and options of camera and rpicam).
* @returns { Promise<IOutputException>} capturing status or stream event emitter output (as a `Promise`).
*/
serveStillCustom(width: number, height: number, id: string, options?: ICameraStillOptions & {
stream?: boolean;
output?: string;
format?: string;
}): Promise<IOutputException>;
/**
* Same as `serveVideoCustom` but is sync.
* @param {number} timeout of capturing or time argument of streams and other stuff needs time.
* @param {number} width (no description needed)
* @param {number} height (no description needed)
* @param {ICameraVideoOptions & { stream?: boolean, output?: string }} options of serving (full settings and options of camera and rpicam).
* @returns {IOutputException} capturing status or stream event emitter output.
*/
serveVideoCustomSync(timeout: number, width: number, height: number, options?: ICameraVideoOptions & {
stream?: boolean;
output?: string;
}): IOutputException;
/**
* Same as `serveVideo` But everything except some required things must setted manually.
* @param {number} timeout of capturing or time argument of streams and other stuff needs time.
* @param {number} width (no description needed)
* @param {number} height (no description needed)
* @param {string} id of task for managing.
* @param {ICameraVideoOptions & { stream?: boolean, output?: string }} options of serving (full settings and options of camera and rpicam).
* @returns {Promise<IOutputException>} capturing status or stream event emitter output (as a `Promise`).
*/
serveVideoCustom(timeout: number, width: number, height: number, id: string, options?: ICameraVideoOptions & {
stream?: boolean;
output?: string;
}): Promise<IOutputException>;
/**
* Takes a photo and save it into a file (powered by `rpicam-still`).
* @param {string} filename is path of saving image, also is okay set it to empty string for streaming options and everything like stream should not be outputed on a file or use `serveStillCutomSync` to set everything manually.
* @param {number} width of resolution.
* @param {number} height of resolution.
* @param {string} id of task for managing.
* @param { ICameraStillOptions & { stream?: boolean }} options of serving (full settings and options of camera and rpicam).
* @returns {Promise<IOutputException>} capturing status or stream event emitter output (as a `Promise`).
*/
serveStill(filename: string, width: number, height: number, id: string, options?: ICameraStillOptions & {
stream?: boolean;
}): Promise<IOutputException>;
/**
* Same as `serveVideo` but is sync.
* @param {string} filename is path of saving video, also is okay set it to empty string for streaming options and everything like stream should not be outputed on a file or use `serveVideoCutomSync` to set everything manually.
* @param {number} width of resolution.
* @param {number} height of resolution.
* @param { ICameraStillOptions & { stream?: boolean }} options of serving (full settings and options of camera and rpicam).
* @returns {Promise<IOutputException>} capturing status or stream event emitter output.
*/
serveVideoSync(filename: string, timeout: number, width: number, height: number, options?: ICameraVideoOptions & {
stream?: boolean;
}): IOutputException;
/**
* Capture a video and save it into a file (powered by `rpicam-vid`).
* @param {string} filename is path of saving video, also is okay set it to empty string for streaming options and everything like stream should not be outputed on a file or use `serveVideoCutomSync` to set everything manually.
* @param {number} width of resolution.
* @param {number} height of resolution.
* @param {string} id of task for managing.
* @param { ICameraStillOptions & { stream?: boolean }} options of serving (full settings and options of camera and rpicam).
* @returns {Promise<IOutputException>} capturing status or stream event emitter output (as a `Promise`).
*/
serveVideo(filename: string, timeout: number, width: number, height: number, id: string, options?: ICameraVideoOptions & {
stream?: boolean;
}): Promise<IOutputException>;
/**
* Start a live stream, load stream to `live` property or access it via return value (is similar to event emitter, and powered by `serveVideo`).
* @param width (no description needed)
* @param height (no description needed)
* @param id of task for managing.
* @param options of serving (full settings and options of camera and rpicam).
* @returns {ChildProcessWithoutNullStreams } spawn stream of node:child_process.
*/
serveLive(width: number, height: number, id: string, options: ICameraVideoOptions): ChildProcessWithoutNullStreams;
/**
* Gets list of avail camera (connected cameras).
* @returns {ICameraDescriptor[]} list of cameras, must be empty if nothing connected.
*/
static getAvailCameras(): ICameraDescriptor[];
/**
* Same as `isReady` but is sync.
* @returns {Promise<boolean>} ready status by boolean.
*/
isReadySync(): boolean;
/**
* Checks is Camera ready or not by testing a simple rpicam-still on camera (purpose of testing is to check is connected okay or is free or not).
* @returns {Promise<boolean>} ready status by boolean (as a`Promise`).
*/
isReady(): Promise<boolean>;
}
export {};