Git Product home page Git Product logo

joelpurra / uvcc Goto Github PK

View Code? Open in Web Editor NEW
95.0 8.0 5.0 1.1 MB

USB Video Class (UVC) device configurator. Used for webcams, camcorders, etcetera. Command line interface for automation.

Home Page: https://joelpurra.com/projects/uvcc/

License: GNU General Public License v3.0

JavaScript 7.54% TypeScript 92.46%
usb uvc uvccamera usb-cameras configuration video webcam webcamera camera digital-camera

uvcc's Introduction

uvcc demo video showing rubber ducks and a candle with varying camera settings

USB Video Class (UVC) device configurator

Overview

  • Fine-tune camera controls on the fly, such as brightness, contrast, saturation, gain, white balance/color temperature, zoom.
  • Export/import of settings makes it easy to reliably configure one or more cameras for various situations.
  • Command line interface (CLI) with JSON input/output for automation and repeatability.

Compatible cameras

Do you have another UVC-compatible camera?

Installation

Requires Node.js (node and npm commands). Published on npm as uvcc.

npm install --global uvcc

Or use npx to execute with npx uvcc.

On Linux, you may need to change device access permissions.

Features

  • List available UVC cameras and camera controls.
  • Get/set individual camera controls.
  • Export/import full JSON control snapshots using stdout/stdin.
  • Per-user/per-directory/custom configuration files to handle multiple cameras.

Short usage example

First start a program which shows a camera preview, such as Photo Booth on macOS or Cheese on Linux.

# Display commands and options.
uvcc --help

# Export current configuration. You can save it to a file, modify, and import later.
uvcc export

# Turn off automatic white balance to manually set the white balance.
uvcc set auto_white_balance_temperature 0

# Set the white balance temperature to 2000.
# NOTE: the white_balance_temperature range for Logitech C920 is 2000-6500.
uvcc set white_balance_temperature 2000

# Set the contrast to 192.
# NOTE: the contrast range for Logitech C920 is 0-255, default value 128.
uvcc set contrast 192

See also


uvcc Copyright © 2018, 2019, 2020, 2021, 2022 Joel Purra. Released under GNU General Public License version 3.0 (GPL-3.0). Your donations are appreciated!

uvcc's People

Contributors

holbrookdev avatar joelpurra avatar m0ose avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uvcc's Issues

Typo in USAGE.md

Under "Examples:" in USAGE.md, "vendor" should be "--vendor."

Examples:
uvcc vendor 0x46d --product 0x82d get white_balance_temperature

commands take a long time to finish after upgrade to v3.0.0

Just upgraded to v3.0.0 and when I do:

time uvcc --vendor 1133 --address 4 --product 2194 set auto_exposure_mode 1 --verbose

Parsed arguments: {
  "address": 4,
  "cmd": "set",
  "control": "auto_exposure_mode",
  "product": 2194,
  "values": [
    1
  ],
  "vendor": 1133,
  "verbose": true
}

real	0m8.852s
user	0m0.119s
sys	0m0.028s

This use to happen almost instantly:

device is:

kumar-macair:~ galak$ uvcc devices
[
  {
    "name": "HD Pro Webcam C920",
    "vendor": 1133,
    "product": 2194,
    "address": 4
  }
]

commands take long time to finish after upgrade to node 17.0.1

Doing a command like:

kumar-macair:~ galak$ uvcc --verbose devices
Parsed arguments: {
  "address": 0,
  "cmd": "devices",
  "product": 0,
  "values": [],
  "vendor": 0,
  "verbose": true
}
[
  {
    "name": "HD Pro Webcam C920",
    "vendor": 1133,
    "product": 2194,
    "address": 5
  }
]

It will quickly report the output and than pause for 7-8 seconds before returning to prompt.

Not working with Logitech C270?

I downloaded the repository and installed with npm install.
Running it on macOS 10.14.6.
But I can't get it to work with my Logitech C270.

Listing the devices only shows my internal trackpad.
Checking chrome://usb-internals in Chrome gives me vendor and product ids, so I tried using them.
But I still can't control the webcam...

I am able to turn off Auto Exposure on the C270 webcam on MacOS using the sample application on this page: https://phoboslab.org/log/2009/07/uvc-camera-control-for-mac-os-x So at least I know it's possible... I tried adjusting the gain in this app, and then checking again with uvcc to see if it changed, but uvcc returned the same gain value.

I was hoping to use uvcc so I can control the exposure of my C270 cross platform. Also the exposure range slider in the example app from phoboslab.org doesn't work properly for the C270, so I was hoping to fix that too using uvcc.

Apple-MBP:uvcc-develop apple$ node index.js devices
Apple Internal Keyboard / Trackpad [ vId: 0x5ac  / pId: 0x274  ]
Apple-MBP:uvcc-develop apple$ node index.js --vendor 0x46d --product 0x825 get whiteBalanceTemperature
{ [Error: LIBUSB_TRANSFER_OVERFLOW]
  cause: { Error: LIBUSB_TRANSFER_OVERFLOW errno: 6 },
  isOperational: true,
  errno: 6 }
Apple-MBP:uvcc-develop apple$ node index.js --vendor 0x46d --product 0x825 get gain
2306
Apple-MBP:uvcc-develop apple$ node index.js --vendor 0x46d --product 0x825 get gain
2306

Is setting the manual focus available?

Hello Again :)

I see I can swap between manual and and auto focus by setting the auto_focus flag, but is it possible to change the focus value?

I can verify the auto focus is being toggled by opening the settings menu (it doesnt update in real time, but it is different if I open and close it)

image

Using a C920 with windows.

Add support for node 18.0.0

uvcc with node 18.0.0 installed:

Detected node version: 18.0.0. Required node version: ^12.20.0 || ^14.13.1 || ^16.0.0 || ^17.0.0.

Logitech BRIO: Additional features (non-standard fields)

This is a fantastic tool for controlling webcams, thanks!

I am using Logitech BRIO 4K webcam, where additional controls are possible such as

  • (i) FOV (Field of View): 65, 78, 90 degrees
  • (ii) Image Size: Standard vs Widescreen (this looks like a webcam's resolution mode): 4x3 vs 16x9

Would it be possible to control those settings as well?

FYI, the following is an output of V4L2 control for BRIO (Source: https://www.kurokesu.com/main/2016/01/16/manual-usb-camera-settings-in-linux/)

                     brightness (int)    : min=0 max=255 step=1 default=128 value=128
                       contrast (int)    : min=0 max=255 step=1 default=128 value=128
                     saturation (int)    : min=0 max=255 step=1 default=128 value=128
 white_balance_temperature_auto (bool)   : default=1 value=1
                           gain (int)    : min=0 max=255 step=1 default=0 value=0
           power_line_frequency (menu)   : min=0 max=2 default=2 value=2
      white_balance_temperature (int)    : min=2000 max=7500 step=10 default=4000 value=2770 flags=inactive
                      sharpness (int)    : min=0 max=255 step=1 default=128 value=128
         backlight_compensation (int)    : min=0 max=1 step=1 default=1 value=1
                  exposure_auto (menu)   : min=0 max=3 default=3 value=3
              exposure_absolute (int)    : min=3 max=2047 step=1 default=250 value=625 flags=inactive
         exposure_auto_priority (bool)   : default=0 value=1
                   pan_absolute (int)    : min=-36000 max=36000 step=3600 default=0 value=0
                  tilt_absolute (int)    : min=-36000 max=36000 step=3600 default=0 value=0
                 focus_absolute (int)    : min=0 max=255 step=5 default=0 value=20 flags=inactive
                     focus_auto (bool)   : default=1 value=1
                  zoom_absolute (int)    : min=100 max=500 step=1 default=100 value=100
                      led1_mode (menu)   : min=0 max=3 default=0 value=3
                 led1_frequency (int)    : min=0 max=255 step=1 default=0 value=0

RangeError [ERR_OUT_OF_RANGE]: The value of "byteLength" is out of range. It must be >= 1 and <= 6. Received 8

I'm running this on Max OSX 10.14.6 and the export command crashes (I have a Microsoft Lifecam Studio plugged in)

$ uvcc  --vendor 0x45e --product 0x772 export
internal/buffer.js:76
  throw new ERR_OUT_OF_RANGE(type || 'offset',
  ^

RangeError [ERR_OUT_OF_RANGE]: The value of "byteLength" is out of range. It must be >= 1 and <= 6. Received 8
    at boundsError (internal/buffer.js:76:9)
    at Buffer.readIntLE (internal/buffer.js:343:3)
    at Device.<anonymous> (/Users/philip/.nvm/versions/node/v12.16.1/lib/node_modules/uvcc/node_modules/uvc-control/index.js:175:29)
    at Transfer.<anonymous> (/Users/philip/.nvm/versions/node/v12.16.1/lib/node_modules/uvcc/node_modules/usb/usb.js:131:15) {
  code: 'ERR_OUT_OF_RANGE'
}

Any thoughts? I'm prepared to do debugging....

LIBUSB_ERROR_NOT_FOUND when using uvcc devices

Hello,

I get the following error when I try run uvcc devices

C:\Users\Brian>uvcc devices
Error: LIBUSB_ERROR_NOT_FOUND
    at Device.usb.Device.open (C:\Users\Brian\AppData\Roaming\npm\node_modules\uvcc\node_modules\usb\usb.js:38:7)
    at C:\Users\Brian\AppData\Roaming\npm\node_modules\uvcc\node_modules\uvc-control\index.js:297:14
    at new Promise (<anonymous>)
    at UVCControl.validate (C:\Users\Brian\AppData\Roaming\npm\node_modules\uvcc\node_modules\uvc-control\index.js:294:10)
    at Array.map (<anonymous>)
    at C:\Users\Brian\AppData\Roaming\npm\node_modules\uvcc\node_modules\uvc-control\index.js:282:40
    at new Promise (<anonymous>)
    at Function.UVCControl.discover (C:\Users\Brian\AppData\Roaming\npm\node_modules\uvcc\node_modules\uvc-control\index.js:281:10)
    at UvcDeviceLister.get (C:\Users\Brian\AppData\Roaming\npm\node_modules\uvcc\dist\uvc-device-lister.js:31:47)
    at DevicesCommand.execute (C:\Users\Brian\AppData\Roaming\npm\node_modules\uvcc\dist\command-handlers\devices.js:35:52)
    at CommandHandlers.execute (C:\Users\Brian\AppData\Roaming\npm\node_modules\uvcc\dist\command-handlers.js:43:38)
    at CommandManager.execute (C:\Users\Brian\AppData\Roaming\npm\node_modules\uvcc\dist\command-manager.js:71:55)
    at async mainAsync (C:\Users\Brian\AppData\Roaming\npm\node_modules\uvcc\dist\index.js:73:9) {
  errno: -5
}

Is their a driver setup step I'm missing or something?

I'm currently using Generic windows drivers rather than the logitech ones as described in this setup:
https://blog.logitech.com/2018/01/03/multi-camera-streaming-with-logitech-webcams-a-how-to-guide/

Please let me know if you need more information

Get error trying to do `uvcc set absolute_exposure_time` on C920 camera

kumar-macair:node-uvc-control galak$ uvcc set absolute_exposure_time 500
Error: Could not find a settable control named "absolute_exposure_time".
at CameraHelper.setValues (/usr/local/lib/node_modules/uvcc/dist/camera-helper.js:54:19)
at async CommandHandlers.execute (/usr/local/lib/node_modules/uvcc/dist/command-handlers.js:43:24)
at async CommandManager.execute (/usr/local/lib/node_modules/uvcc/dist/command-manager.js:71:28)
at async mainAsync (/usr/local/lib/node_modules/uvcc/dist/index.js:73:9)

LIBUSB_TRANSFER_STALL errno: 4

Hello,

I'm trying to get it work on MacBookPro with OSX 10.13.6, I did get a result for devices, but none for ranges and export (it give me empty {} resultes) and get commands give me this error message : error: { Error: LIBUSB_TRANSFER_STALL errno: 4 } }

Do I miss something ?

Setting UVCC autoWhiteBalance to 0 Getting LIBUSB_ERROR_IO

sudo uvcc devices

Optical Mouse [ vId: 0x458  / pId: 0x3a  ]
USB Keyboard [ vId: 0x4d9  / pId: 0x1702  ]
EHCI Host Controller [ vId: 0x1d6b  / pId: 0x2  ]
EHCI Host Controller [ vId: 0x1d6b  / pId: 0x2  ]
USB 2.0 Camera [ vId: 0xc45  / pId: 0x6366  ]

sudo uvcc --vendor 0xc45 --product 0x6366 set autoWhiteBalance 0

Error: LIBUSB_ERROR_IO
Screenshot from 2019-07-24 17-18-41

TypeError: Cannot read properties of undefined (reading 'descriptor')

Version:

❯❯❯ uvcc --version         
v5.0.2
❯❯❯ node --version
v17.3.0

(Note: M1 mac, arm64)

Error:

$ uvcc controls

WrappedError: Could create uvc-control object: {} ("TypeError: Cannot read properties of undefined (reading 'descriptor')")
    at CameraFactory.createWrappedError (file:///opt/homebrew/lib/node_modules/uvcc/dist/camera-factory.js:90:30)
    at CameraFactory.get (file:///opt/homebrew/lib/node_modules/uvcc/dist/camera-factory.js:74:43)
    at CommandManager.execute (file:///opt/homebrew/lib/node_modules/uvcc/dist/command-manager.js:73:47)
    at async mainAsync (file:///opt/homebrew/lib/node_modules/uvcc/dist/index.js:73:9) {
  innerError: TypeError: Cannot read properties of undefined (reading 'descriptor')
      at getInterfaceDescriptors (/opt/homebrew/lib/node_modules/uvcc/node_modules/uvc-control/index.js:375:26)
      at UVCControl.init (/opt/homebrew/lib/node_modules/uvcc/node_modules/uvc-control/index.js:85:25)
      at new UVCControl (/opt/homebrew/lib/node_modules/uvcc/node_modules/uvc-control/index.js:22:10)
      at CameraFactory.get (file:///opt/homebrew/lib/node_modules/uvcc/dist/camera-factory.js:54:28)
      at CommandManager.execute (file:///opt/homebrew/lib/node_modules/uvcc/dist/command-manager.js:73:47)
      at async mainAsync (file:///opt/homebrew/lib/node_modules/uvcc/dist/index.js:73:9)

Potential product (marketing) name versus product id differences

The uvcc compatibility list and examples have so far been based on the product name, but looking at various reports it seems the product id may vary within the advertised name. While I'm personally only working on the layers built on top of USB, finding differences is both enlightening and confusing.

Instead of per-name sub-directories, the ./examples/ may need to have per-id sub-directories (or sub-sub-directories?) with the output files, for comparison.

Examples:

HD Pro Webcam C920 as 1133:2093 captured by @joelpurra in https://github.com/joelpurra/uvcc/blob/v5.0.1/examples/logitech-c920/devices.json#L1-L8

HD Pro Webcam C920 as 1133:2194 captured by @galak in #20:

[
  {
    "name": "HD Pro Webcam C920",
    "vendor": 1133,
    "product": 2194,
    "address": 5
  }
]

Are there other recorded examples of differences?

uvcc commands does not respect Camera selection

[email protected]

I have two USB cameras connected, e.g.:

[
  {
    "name": "Logitech C930c",
    "vendor": 1133,
    "product": 2193,
    "address": 4
  },
  {
    "name": "Logitech BRIO",
    "vendor": 1133,
    "product": 2142,
    "address": 1
  }
]

I tried the following to control the second webcam (BRIO in this example):

❯❯❯ uvcc set --product 2142 absolute_zoom 170

But the first one (C930c) gets changed. None of --vendor, --product, --address works. I tested with other commands such as import, export, get, set, but all of them only interacts with the default (first) camera.

The new version of uvcc doesn't terminate

uvcc v5.0.1
node v17.0.1
MacOS 12.0

Any command of uvcc does not terminate right after printing something.

e.g.

> uvcc get absolute_zoom
150

It prints something, but the process doesn't terminate.
\

package errors after node/npm upgrade

After a recent node/npm upgrade, uvcc has stopped working for me. Simple commands like uvcc help work, but trying to change anything or get a list of devices fails, and looking through this output I can't tell why:

$ uvcc devices
FATAL ERROR:  
 1: 0x10a5eb70c node::Abort() [/usr/local/bin/node]
 2: 0x10a5ec73d node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 3: 0x10a5ec5a6 node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 4: 0x10a5b94a3 napi_open_callback_scope [/usr/local/bin/node]
 5: 0x10ec7f79a  [/usr/local/lib/node_modules/uvcc/node_modules/usb/prebuilds/darwin-x64+arm64/node.napi.node]
 6: 0x10ec91cec handleCompletion(Transfer*) [/usr/local/lib/node_modules/uvcc/node_modules/usb/prebuilds/darwin-x64+arm64/node.napi.node]
 7: 0x10ec85ca5 Napi::ThreadSafeFunction::CallJS(napi_env__*, napi_value__*, void*, void*) [/usr/local/lib/node_modules/uvcc/node_modules/usb/prebuilds/darwin-x64+arm64/node.napi.node]
 8: 0x10a5bb1d1 v8impl::(anonymous namespace)::ThreadSafeFunction::AsyncCb(uv_async_s*) [/usr/local/bin/node]
 9: 0x10c84da10 uv__async_io [/usr/local/opt/libuv/lib/libuv.1.dylib]
10: 0x10c85d773 uv__io_poll [/usr/local/opt/libuv/lib/libuv.1.dylib]
11: 0x10c84de46 uv_run [/usr/local/opt/libuv/lib/libuv.1.dylib]
12: 0x10a595990 node::Environment::CleanupHandles() [/usr/local/bin/node]
13: 0x10a595acc node::Environment::RunCleanup() [/usr/local/bin/node]
14: 0x10a51e15f node::FreeEnvironment(node::Environment*) [/usr/local/bin/node]
15: 0x10a62a343 node::NodeMainInstance::Run(node::EnvSerializeInfo const*) [/usr/local/bin/node]
16: 0x10a5b8270 node::Start(int, char**) [/usr/local/bin/node]
17: 0x7fff2040bf3d start [/usr/lib/system/libdyld.dylib]
18: 0x3 
Abort trap: 6

From looking at another issue, I tried uninstalling and re-installing with uvcc@latest, and it's still erroring.

More info for you:

$ node --version
v17.0.1
$ npm --version
8.1.0
$ npm list --global
/usr/local/lib
├── [email protected]
└── [email protected]

on MacOS Big Sur, v11.6

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.