Git Product home page Git Product logo

uvc's Introduction

uvc

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

  print('zoom: ${camera.zoom.current}');

  camera.zoom.current = 225;
  camera.close();

  uvc.dispose();
}

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

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

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;

To get the zoom current value:

print('zoom: ${camera.zoom.current}');

To set the zoom current value:

camera.zoom.current = 225;

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

uvc.dispose();

To get the range of valid values for zoom:

final min = camera.zoom.min;
final max = camera.zoom.max;

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;

Controls

Pan

camera.pan.current;

Tilt

camera.tilt.current;

Zoom

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

camera.zoom.current;
camera.zoom.defaultValue;
camera.zoom.max;
camera.zoom.min;
camera.zoom.resolution;

Backlight Compensation

camera.backlightCompensation.current;

Focus

camera.zoom.current;

Focus (auto)

camera.focusAuto.current;

Powerline Frequency

camera.powerlineFrequency.current;

Debugging

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

final uvc = UvcLib(debugLogging: true);

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

final uvc = UvcLib(debugLoggingLibUsb: true);

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 Flattr or Patreon.

uvc's People

Contributors

larryaasen avatar mend-bolt-for-github[bot] avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

uvc's Issues

Cannot start example

In a newly created project I have added the dependency and copy uvc_example.dart, but when I start it, it gives me:

Syncing files to device macOS...
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: uvc: libusb dynamic library not found: Invalid argument(s): Failed to load dynamic library '/Users/azlekov/Library/Containers/app.dodi.uvcPoc/Data/libusb-1.0.27/libusb-1.0.0.dylib': dlopen(/Users/azlekov/Library/Containers/app.dodi.uvcPoc/Data/libusb-1.0.27/libusb-1.0.0.dylib, 0x0001): tried: '/Users/azlekov/Library/Containers/app.dodi.uvcPoc/Data/libusb-1.0.27/libusb-1.0.0.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/azlekov/Library/Containers/app.dodi.uvcPoc/Data/libusb-1.0.27/libusb-1.0.0.dylib' (no such file), '/Users/azlekov/Library/Containers/app.dodi.uvcPoc/Data/libusb-1.0.27/libusb-1.0.0.dylib' (no such file)
#0      UvcLib._loadLibrary (package:uvc/src/uvc_lib.dart:127:7)
#1      new UvcLib (package:uvc/src/uvc_lib.dart:22:19)
#2      main (package:uvc_poc/main.dart:4:15)
#3      _runMain.<anonymous closure> (dart:ui/hooks.dart:301:23)
#4      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#5      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

I'm using Mac Studio M1

What I'm doing wrong?

And a question, is there a way to capture image from UVC camera with this library?

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.