Socket
Book a DemoInstallSign in
Socket

camera-settings

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

camera-settings

Modify the configuration of the usb camera, support windows and linux, support electron

0.0.7
latest
Source
npmnpm
Version published
Weekly downloads
3
200%
Maintainers
1
Weekly downloads
 
Created
Source

camera-settings npm

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.

Installation

npm install camera-settings

Usage

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();
})();

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 & 1 Auto; rangeFlags & 2 Auto Manual */
  rangeFlags: number;
  /** Default configuration */
  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;
  /** mjpg, yuy2, yuyv... */
  type: string;
}

Keywords

camera

FAQs

Package last updated on 01 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.