uvc 1.2.0 copy "uvc: ^1.2.0" to clipboard
uvc: ^1.2.0 copied to clipboard

A Dart package for controlling UVC compliant webcams on macOS and Windows.

GitHub main workflow codecov pub package GitHub Stars Buy me a coffee

A Dart package for controlling UVC compliant webcams.

You can find more information about UVC USB devices here on Wikipedia.

Platform Support #

Android iOS MacOS Web Linux Windows

Example #

import 'package:uvc/uvc.dart';

void main() {
  final uvc = UvcLib(); // Load the libusb library

  final camera = UVCControl(vendorId: 0x1532, productId: 0x0E05);

  final value = camera.zoom.min;
  camera.zoom.current = value == null ? 225 : value + 1;

  camera.close();

  uvc.dispose();
}
copied to clipboard

Usage #

First, add uvc as a dependency in your pubspec.yaml file. Then run dart pub get or flutter pub get.

Next, you need to instantiate the UvcLib class which will open and setup the libusb library for use in the app.

final uvc = UvcLib();
copied to clipboard

To open a camera and start controlling it, you must use UVCControl. Include the vendor ID and product ID of the camera to control.

final camera = UVCControl(vendorId: 0x1532, productId: 0x0E05);
copied to clipboard

To find a list of cameras with their IDs, you can use:

final uvcDevices = uvc.getDevices(onlyUvcDevices: true);
final device = uvcDevices.first;
final vendorId = device.deviceDescriptor.vendorId;
final productId = device.deviceDescriptor.productId;
copied to clipboard

To get the zoom current value:

final value = camera.zoom.current;
copied to clipboard

To set the zoom current value:

camera.zoom.current = 225;
copied to clipboard

Close the camera when you are done.

camera.close();
copied to clipboard

It is always a good idea to unload the library when you are done using it.

uvc.dispose();
copied to clipboard

To get the range of valid values for zoom:

final min = camera.zoom.min;
final max = camera.zoom.max;
copied to clipboard

To use the pan or tilt values, just use the same code as zoom, but substitute the name pan and tilt for zoom:

camera.pan.current;
camera.pan.min;
camera.tilt.current;
camera.tilt.min;
copied to clipboard

Controls #

Pan #

camera.pan.current;
copied to clipboard

Tilt #

camera.tilt.current;
copied to clipboard

Zoom #

final camera = UVCControl(vendorId: 0x1532, productId: 0x0E05);

camera.zoom.current;
camera.zoom.defaultValue;
camera.zoom.max;
camera.zoom.min;
camera.zoom.resolution;
copied to clipboard

Backlight Compensation #

camera.backlightCompensation.current;
copied to clipboard

Brightness #

camera.brightness.current;
copied to clipboard

Contrast #

camera.contrast.current;
copied to clipboard

Saturation #

camera.contrast.saturation;
copied to clipboard

Sharpness #

camera.contrast.sharpness;
copied to clipboard

White Balance #

camera.contrast.whitebalance;
copied to clipboard

Focus #

camera.zoom.current;
copied to clipboard

Focus (auto) #

camera.focusAuto.current;
copied to clipboard

Powerline Frequency #

camera.powerlineFrequency.current;
copied to clipboard

Debugging #

You can enable logging in UvcLib for troubleshooting. Just pass true to debugLogging when creating UvcLib.

final uvc = UvcLib(debugLogging: true);
copied to clipboard

You can also enable libusb logging in UvcLib for troubleshooting. Just pass true to debugLoggingLibUsb when creating UvcLib.

final uvc = UvcLib(debugLoggingLibUsb: true);
copied to clipboard

libusb #

This uvc package utilizes the libusb library via Dart FFI and it is included as a dependency with the libusb Dart package.

Contributing #

All comments and pull requests are welcome.

Donations / Sponsor #

Please sponsor or donate to the creator of uvc on Patreon.

2
likes
140
points
32
downloads

Publisher

verified publisherlarryaasen.com

Weekly Downloads

2024.09.05 - 2025.03.20

A Dart package for controlling UVC compliant webcams on macOS and Windows.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

convert, equatable, ffi, libusb

More

Packages that depend on uvc