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