Skip to content
norma-corePublic
forked from libuvc/libuvc

About

a cross-platform library for USB video devices

Resources

Stars

2 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

libuvc (Enhanced Fork)

This is a fork of libuvc with additional timestamp enhancements.

Enhancements in This Fork

Additional Timestamp Fields

  • capture_boottime_finished: Monotonic timestamp (CLOCK_BOOTTIME) in nanoseconds when frame capture completes
  • capture_realtime_finished: Wall-clock timestamp (CLOCK_REALTIME) in nanoseconds when frame capture completes

These additional timestamps complement the existing capture_time_finished field, providing:

  • Monotonic time reference that accounts for system suspend/resume (CLOCK_BOOTTIME)
  • Wall-clock time for absolute timestamp correlation (CLOCK_REALTIME)
  • Improved frame timing precision for applications requiring accurate temporal synchronization

The new fields are automatically populated in all frame operations and conversions.


Original libuvc Description

libuvc is a cross-platform library for USB video devices, built atop libusb. It enables fine-grained control over USB video devices exporting the standard USB Video Class (UVC) interface, enabling developers to write drivers for previously unsupported devices, or just access UVC devices in a generic fashion.

Getting and Building libuvc

Prerequisites: You will need libusb and CMake installed.

To build, you can just run these shell commands:

git clone https://github.com/libuvc/libuvc
cd libuvc
mkdir build
cd build
cmake ..
make && sudo make install

and you're set! If you want to change the build configuration, you can edit CMakeCache.txt in the build directory, or use a CMake GUI to make the desired changes.

There is also BUILD_EXAMPLE and BUILD_TEST options to enable the compilation of example and uvc_test programs. To use them, replace the cmake .. command above with cmake .. -DBUILD_TEST=ON -DBUILD_EXAMPLE=ON. Then you can start them with ./example and ./uvc_test respectively. Note that you need OpenCV to build the later (for displaying image).

LIBUVC_INSTALL (on by default) generates the install rules. A project that uses libuvc with add_subdirectory() and builds libusb itself, providing it as a target of its own, has to turn it off: libuvc's installed CMake package could not refer to that target.

Two tuning options control how much data is queued for a stream, and are left at their defaults when unset:

  • LIBUVC_PACKETS_PER_TRANSFER_MAX (default 32): maximum number of isochronous packets in one USB transfer. If starting a stream fails with submiturb failed, errno=12 (ENOMEM), as is common on Android, lower it, e.g. cmake .. -DLIBUVC_PACKETS_PER_TRANSFER_MAX=8.
  • LIBUVC_NUM_TRANSFER_BUFS (default 100, 20 on macOS): number of transfers queued at once.

Examples

Linux/macOS:

  • src/example.c finds the first UVC camera, prints its descriptors and streams from it for 10 seconds. Built by default (BUILD_EXAMPLE).
  • src/test.cxx shows the camera's frames in an OpenCV window (Linux only, broken on macOS). Built with -DBUILD_TEST=ON; needs OpenCV.

Android:

  • examples/android shows the camera's frames in an app. It uses Android APIs to find the camera, request permission and get a file descriptor, then opens the camera with uvc_wrap(). See its README for what integrating libuvc there involves.

Developing with libuvc

The documentation for libuvc can currently be found at https://libuvc.github.io/.

Happy hacking!

About

a cross-platform library for USB video devices

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages