libuvc is a library that supports enumeration, control and streaming for USB Video Class (UVC) devices, such as consumer webcams.
Features
Roadmap
- Bulk-mode image capture
- One-shot image capture
- Improved support for standard settings
- Support for "extended" (vendor-defined) settings
Misc.
The
source code can be found at https://github.com/ktossell/libuvc. To build the library, install libusb 1.0+ and run:
$ git clone https:
$ cd libuvc
$ mkdir build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ make && make install
Example
In this example, libuvc is used to acquire images in a 30 fps, 640x480 YUV stream from a UVC device such as a standard webcam.
#include "libuvc/libuvc.h"
#include <stdio.h>
if (!bgr) {
printf("unable to allocate bgr frame!");
return;
}
if (ret) {
return;
}
}
int main(int argc, char **argv) {
uvc_context_t *ctx;
uvc_device_t *dev;
uvc_device_handle_t *devh;
if (res < 0) {
return res;
}
puts("UVC initialized");
ctx, &dev,
0, 0, NULL);
if (res < 0) {
} else {
puts("Device found");
if (res < 0) {
} else {
puts("Device opened");
devh, &ctrl,
640, 480, 30
);
if (res < 0) {
} else {
if (res < 0) {
} else {
puts("Streaming...");
sleep(10);
puts("Done streaming.");
}
}
puts("Device closed");
}
uvc_unref_device(dev);
}
puts("UVC exited");
return 0;
}