camera-settings
English | 中文
Retrieve and modify the configuration of USB cameras, supporting both Windows and Linux environments. Typically used for Electron applications.
Installation
npm install camera-settings
Usage
import { CameraSettings } from "camera-settings";
(async () => {
const cs = new CameraSettings(0);
await cs.open();
const settings = await cs.getSettings();
await cs.setSettings([{ prop: "WhiteBalance", val: 2900, isAuto: true }]);
const resolutions = await cs.getResolutions();
await cs.close();
})();
API
CameraSettings
constructor(cameraId: number | string)
cameraId
Camera index, starting from 0, or the camera name, e.g., HD USB Camera
open(): Promise<void>
Performs initialization tasks, such as finding the device.
close(): Promise<void>
Clears cache and releases resources.
getSettings(): Promise<CameraSetting[]>
Retrieve camera settings.
interface CameraSettingInfo extends CameraSettingSetInfo {
prop: TagCameraControlProperty | TagVideoProcAmpProperty;
val: number;
isAuto?: boolean;
min: number;
max: number;
step: number;
rangeFlags: number;
def: number;
ctrlType: "video" | "camera";
}
setSettings(settings: CameraSetting[]): Promise<void>
Modify camera settings.
interface CameraSetting {
prop: TagCameraControlProperty | TagVideoProcAmpProperty;
val: number;
isAuto?: boolean;
}
getResolutions(): Promise<Resolution[]>
Retrieve all available resolutions.
interface Resolution {
width: number;
height: number;
type: string;
}