GithubHelp home page GithubHelp logo

libuvc / libuvc Goto Github PK

View Code? Open in Web Editor NEW
949.0 949.0 497.0 517 KB

a cross-platform library for USB video devices

Home Page: https://libuvc.github.io/

License: Other

C 92.90% Python 3.21% CMake 3.90%

libuvc's Introduction

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

Developing with libuvc

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

Happy hacking!

libuvc's People

Contributors

alexey-pelykh avatar avilleret avatar brunomarchand avatar chadrockey avatar cybercastle avatar d235j avatar dmikushin avatar ds-hwang avatar hipersayanx avatar ivadasz avatar jamesfidell avatar jbeich avatar jiaxianhua avatar joshvillbrandt avatar jwlodek avatar k-okada avatar kekiefer avatar ktossell avatar lobsteroh avatar mavalki avatar maxrd2 avatar mkassner avatar netman69 avatar nneonneo avatar saki4510t avatar stevecotton avatar stevenlovegrove avatar tarhan avatar umlaeute avatar yaochx 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  avatar  avatar  avatar  avatar  avatar

Watchers

 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

libuvc's Issues

Need help with call back function

Hi,
I am new to c and libuvc. I successfully run example.c and confused about call back function.
Actually i need to maintain a buffer , lets say of size 1000 frames, and whenever a user press a key I have to create a video of this buffer . Can someone please guide how can i achieve this ?

Sometimes preview freeze on some devices

Hello friends.
I use wrapper library (libuvc inside) with customization but Owner doesn't answered on request to help.
May be anyone will try to help me here, because it don't simple for my experience with libUVC

shortly: on old devices ( < 2017 year) preview freeze on high resolution.
I try to write it in details here: saki4510t/UVCCamera#195

I will be grateful for any help. Thanks

uvc_stop_streaming() hangs on Mac OS X

I originally detected it in my code but even in the attached example.c application, sometimes it exits but sometimes it just hangs in uvc_stop_streaming(). The backtraces from all the threads are included below. Interestingly an application which uses libuvc internally - oaCapture doesn't seem to have issues starting/stopping the stream (they're using libuvc 0.0.5 and so am I). Could you please take a look at this situation. It's a great library but this weird behavior is calling for some ugly workarounds (like running capture in separate process) which I think everybody would rather avoid. The SIGSTOP is coming from my Ctrl+C in LLDB. I'm using the DMK23U274 camera from TheImagingSource - USB 3.0 UVC.

(lldb) thread backtrace all
* thread #1: tid = 0x3a8e7, 0x00007fff8d3d3716 libsystem_kernel.dylib`__psynch_cvwait + 10, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x00007fff8d3d3716 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff8fca4c3b libsystem_pthread.dylib`_pthread_cond_wait + 727
    frame #2: 0x000000010000cd8b libuvc.dylib`uvc_stream_stop + 171
    frame #3: 0x000000010000c897 libuvc.dylib`uvc_stream_close + 23
    frame #4: 0x000000010000ccc9 libuvc.dylib`uvc_stop_streaming + 25
    frame #5: 0x0000000100000d2c a.out`main + 492
    frame #6: 0x00007fff8da195fd libdyld.dylib`start + 1

  thread #2: tid = 0x3a901, 0x00007fff8d3cfa1a libsystem_kernel.dylib`mach_msg_trap + 10, name = 'org.libusb.device-hotplug'
    frame #0: 0x00007fff8d3cfa1a libsystem_kernel.dylib`mach_msg_trap + 10
    frame #1: 0x00007fff8d3ced18 libsystem_kernel.dylib`mach_msg + 64
    frame #2: 0x00007fff93e6ef15 CoreFoundation`__CFRunLoopServiceMachPort + 181
    frame #3: 0x00007fff93e6e539 CoreFoundation`__CFRunLoopRun + 1161
    frame #4: 0x00007fff93e6de75 CoreFoundation`CFRunLoopRunSpecific + 309
    frame #5: 0x00007fff93f23811 CoreFoundation`CFRunLoopRun + 97
    frame #6: 0x00000001000551b9 libusb-1.0.0.dylib`___lldb_unnamed_function66$$libusb-1.0.0.dylib + 679
    frame #7: 0x00007fff8fca2899 libsystem_pthread.dylib`_pthread_body + 138
    frame #8: 0x00007fff8fca272a libsystem_pthread.dylib`_pthread_start + 137
    frame #9: 0x00007fff8fca6fc9 libsystem_pthread.dylib`thread_start + 13

  thread #3: tid = 0x3a902, 0x00007fff8d3d4662 libsystem_kernel.dylib`kevent64 + 10, queue = 'com.apple.libdispatch-manager'
    frame #0: 0x00007fff8d3d4662 libsystem_kernel.dylib`kevent64 + 10
    frame #1: 0x00007fff9164e421 libdispatch.dylib`_dispatch_mgr_invoke + 239
    frame #2: 0x00007fff9164e136 libdispatch.dylib`_dispatch_mgr_thread + 52

  thread #4: tid = 0x3a903, 0x00007fff8d3d494a libsystem_kernel.dylib`poll + 10
    frame #0: 0x00007fff8d3d494a libsystem_kernel.dylib`poll + 10
    frame #1: 0x000000010004dca1 libusb-1.0.0.dylib`___lldb_unnamed_function21$$libusb-1.0.0.dylib + 327
    frame #2: 0x000000010004e939 libusb-1.0.0.dylib`libusb_handle_events_timeout_completed + 127
    frame #3: 0x000000010004ea81 libusb-1.0.0.dylib`libusb_handle_events + 34
    frame #4: 0x000000010000b4f8 libuvc.dylib`_uvc_handle_events + 24
    frame #5: 0x00007fff8fca2899 libsystem_pthread.dylib`_pthread_body + 138
    frame #6: 0x00007fff8fca272a libsystem_pthread.dylib`_pthread_start + 137
    frame #7: 0x00007fff8fca6fc9 libsystem_pthread.dylib`thread_start + 13

External Buffers

Is there a way to pass an externally allocated buffer to hold the data when calling uvc_stream_get_frame?
I saw that the frame class has a member called library_owns_data (with comment that says "Set this field to zero if you are supplying the buffer"), but it seems like a new frame is returned with new allocated buffer anyway.

Thanks,
Roi

libuvc on FreeBSD - program hangs, _uvc_stream_callback never executes

Hi,

I'm having problems while running test.c and example.c on FreeBSD. The execution of a thread hangs on the _uvc_user_caller function in the following part:

while (strmh->running && last_seq == strmh->hold_seq)
{
      pthread_cond_wait(&strmh->cb_cond, &strmh->cb_mutex);
}

I traced the problem to the _uvc_stream_callback function which is almost never executed. I said almost because around 1 out of 30 times that I run the program the thread doesn't hang. The problem is that if _uvc_stream_callback is never executed, then _uvc_swap_buffers function is also not executed. As a consequence the value of strmh->hold_seq, that is compared in the while loop above, is never updated to:

strmh->hold_seq = strmh->seq;

and the pthread_cond_wait in the while loop causes the calling thread to block on the condition variable cond.

I already tried solution #16 but it did not solve my problem. Any ideas how can I solve this.

Any help will be very much appreciated.

uvc_get_device_list

hi, i am trying to access the list of available uvc devices (and ultimately call this from java) but I am not familiar with the *** notation on list. is this notation for accessing an array of uvc_device_t?

uvc_error_t uvc_get_device_list (uvc_context_t *ctx, uvc_device_t ***list )

Is list then holding the pointer to the first device handle? would anyone please be willing to share a brief snippet that shows how to access a device on the list once it has been obtained? thanks

Submission of patches

I'm using libuvc to support some UVC-ish astronomy cameras on OSX and have a number of patches to submit, eg:

  1. some trivial bugfix/typo corrections
  2. populate manufacturer and product strings
  3. add support for recognising these cameras (which is a bit hacky as the don't strictly adhere to the UVC spec. in terms of how they advertise themselves)
  4. add support for parsing frame-based formats
  5. add get & set auto focus
  6. recognise BY8 frame format
  7. add some basic USB1.1 support
  8. add support for bulk transfers
  9. moved uvc_get_format_descs to be public so users can find out what frame formats a camera supports
  10. probably a few other bits, too

It would be nice to get these back into the base sources. Would you like the patches, and if so how would you like the patches submitted?

James

Trouble with ISight on Macbook Pro

Thanks for the great library. I've recently been trying to use it to open an ISight camera on a Macbook Pro Retina (OSX 10.8) but have been having some trouble. The library works great for my other cameras. I guess the iSight is non-conformant...

Digging into it, it seems uvc_query_stream_ctrl always fails for the iSight, with the internal libusb_control_transfer returning -99. This error is ignored in libuvc until uvc_start_streaming which checks it. If I comment out this check, it gets further to

config_bytes_per_packet = devh->cur_ctrl.dwMaxPayloadTransferSize;

which is set to 0 because cur_ctrl hasn't been set properly because uvc_query_stream_ctrl is failing. This causes it to accept alt_idx==0 and die because endpoint_bytes_per_packet==0. To encourage it to get further, I can arbitrarily set config_bytes_per_packet to 128 which will then make it accept alt_idx==1 (I've played with other values too). With these hacks, it gets further but still dies when calling libusb_submit_transfer, returning UVC_ERROR_NOT_FOUND (-5).

I noticed the is_isight flag and tried modifying the code to make sure this is set for my model (05ac:8510), but it isn't yet reaching _uvc_iso_callback to have any effect.

Maybe you have some insight?

The debug output of libuvc when trying to open my iSight device is as follows (I added a few UVC_ENTER / UVC_EXIT calls):

[device.c:472] begin uvc_get_device_list
[device.c:528/uvc_get_device_list] non-UVC: 0
[device.c:528/uvc_get_device_list] non-UVC: 1
[device.c:528/uvc_get_device_list] non-UVC: 2
[device.c:528/uvc_get_device_list] non-UVC: 3
[device.c:528/uvc_get_device_list] non-UVC: 4
[device.c:528/uvc_get_device_list] non-UVC: 5
[device.c:572] begin uvc_ref_device
[device.c:577] end uvc_ref_device
[device.c:526/uvc_get_device_list] UVC: 6
[device.c:528/uvc_get_device_list] non-UVC: 7
[device.c:536] end uvc_get_device_list (0)
[device.c:572] begin uvc_ref_device
[device.c:577] end uvc_ref_device
[device.c:552] begin uvc_free_device_list
[device.c:588] begin uvc_unref_device
[device.c:596] end uvc_unref_device
[device.c:562] end uvc_free_device_list
[device.c:183] begin uvc_open
[device.c:186/uvc_open] libusb_open() = 0
[device.c:572] begin uvc_ref_device
[device.c:577] end uvc_ref_device
[device.c:270] begin uvc_get_device_info
[device.c:681] begin uvc_scan_control
[device.c:867] begin uvc_parse_vc
[device.c:734] begin uvc_parse_vc_header
[device.c:914] begin uvc_scan_streaming
[device.c:1054] begin uvc_parse_vs
[device.c:951] begin uvc_parse_vs_input_header
[device.c:956] end uvc_parse_vs_input_header (0)
[device.c:1074] end uvc_parse_vs (0)
[device.c:1054] begin uvc_parse_vs
[device.c:967] begin uvc_parse_vs_format_uncompressed
[device.c:986] end uvc_parse_vs_format_uncompressed (0)
[device.c:1074] end uvc_parse_vs (0)
[device.c:1054] begin uvc_parse_vs
[device.c:1003] begin uvc_parse_vs_frame_uncompressed
[device.c:1038] end uvc_parse_vs_frame_uncompressed (0)
[device.c:1074] end uvc_parse_vs (0)
[device.c:1054] begin uvc_parse_vs
[device.c:1003] begin uvc_parse_vs_frame_uncompressed
[device.c:1038] end uvc_parse_vs_frame_uncompressed (0)
[device.c:1074] end uvc_parse_vs (0)
[device.c:1054] begin uvc_parse_vs
[device.c:1003] begin uvc_parse_vs_frame_uncompressed
[device.c:1038] end uvc_parse_vs_frame_uncompressed (0)
[device.c:1074] end uvc_parse_vs (0)
[device.c:1054] begin uvc_parse_vs
[device.c:1003] begin uvc_parse_vs_frame_uncompressed
[device.c:1038] end uvc_parse_vs_frame_uncompressed (0)
[device.c:1074] end uvc_parse_vs (0)
[device.c:1054] begin uvc_parse_vs
[device.c:1003] begin uvc_parse_vs_frame_uncompressed
[device.c:1038] end uvc_parse_vs_frame_uncompressed (0)
[device.c:1074] end uvc_parse_vs (0)
[device.c:1054] begin uvc_parse_vs
[device.c:1003] begin uvc_parse_vs_frame_uncompressed
[device.c:1038] end uvc_parse_vs_frame_uncompressed (0)
[device.c:1074] end uvc_parse_vs (0)
[device.c:1054] begin uvc_parse_vs
[device.c:1003] begin uvc_parse_vs_frame_uncompressed
[device.c:1038] end uvc_parse_vs_frame_uncompressed (0)
[device.c:1074] end uvc_parse_vs (0)
[device.c:1054] begin uvc_parse_vs
[device.c:1074] end uvc_parse_vs (0)
[device.c:1054] begin uvc_parse_vs
[device.c:1074] end uvc_parse_vs (0)
[device.c:1054] begin uvc_parse_vs
[device.c:1074] end uvc_parse_vs (0)
[device.c:1054] begin uvc_parse_vs
[device.c:1074] end uvc_parse_vs (0)
[device.c:1054] begin uvc_parse_vs
[device.c:1074] end uvc_parse_vs (0)
[device.c:1054] begin uvc_parse_vs
[device.c:1074] end uvc_parse_vs (0)
[device.c:1054] begin uvc_parse_vs
[device.c:1074] end uvc_parse_vs (0)
[device.c:1054] begin uvc_parse_vs
[device.c:1074] end uvc_parse_vs (0)
[device.c:940] end uvc_scan_streaming (0)
[device.c:762] end uvc_parse_vc_header (0)
[device.c:897] end uvc_parse_vc (0)
[device.c:867] begin uvc_parse_vc
[device.c:776] begin uvc_parse_vc_input_terminal
[device.c:797] end uvc_parse_vc_input_terminal (0)
[device.c:897] end uvc_parse_vc (0)
[device.c:867] begin uvc_parse_vc
[device.c:897] end uvc_parse_vc (0)
[device.c:867] begin uvc_parse_vc
[device.c:811] begin uvc_parse_vc_processing_unit
[device.c:822] end uvc_parse_vc_processing_unit (0)
[device.c:897] end uvc_parse_vc (0)
[device.c:720] end uvc_scan_control (0)
[device.c:295] end uvc_get_device_info (0)
[device.c:611] begin uvc_claim_ifs
[device.c:648] end uvc_claim_ifs (0)
[device.c:229/uvc_open] libusb_submit_transfer() = 0
[device.c:241] end uvc_open (0)
[device.c:377] begin uvc_get_device_descriptor
[device.c:409] end uvc_get_device_descriptor (0)
[device.c:421] begin uvc_free_device_descriptor
[device.c:434] end uvc_free_device_descriptor
DEVICE CONFIGURATION (05ac:8510/[none]) ---
Status: idle
VideoControl:
bcdUVC: 0x0100
VideoStreaming(1):
bEndpointAddress: 130
Formats:
UncompressedFormat(1)
bits per pixel: 16
GUID: 5955593200001000800000aa00389b71
default frame: 5
aspect ration: 0x0
interlace flags: 00
copy protect: 00
FrameDescriptor(1)
capabilities: 00
size: 160x120
bit rate: 24576000-147456000
max frame size: 38400
default interval: 1/29
interval[0]: 1/29
interval[1]: 1/25
interval[2]: 1/23
interval[3]: 1/14
FrameDescriptor(2)
capabilities: 00
size: 176x144
bit rate: 24576000-147456000
max frame size: 50688
default interval: 1/29
interval[0]: 1/29
interval[1]: 1/25
interval[2]: 1/23
interval[3]: 1/14
FrameDescriptor(3)
capabilities: 00
size: 320x240
bit rate: 24576000-147456000
max frame size: 153600
default interval: 1/29
interval[0]: 1/29
interval[1]: 1/25
interval[2]: 1/23
interval[3]: 1/14
FrameDescriptor(4)
capabilities: 00
size: 352x288
bit rate: 24576000-147456000
max frame size: 202752
default interval: 1/29
interval[0]: 1/29
interval[1]: 1/25
interval[2]: 1/23
interval[3]: 1/14
FrameDescriptor(5)
capabilities: 00
size: 640x480
bit rate: 24576000-147456000
max frame size: 614400
default interval: 1/29
interval[0]: 1/29
interval[1]: 1/25
interval[2]: 1/23
interval[3]: 1/14
FrameDescriptor(6)
capabilities: 00
size: 480x360
bit rate: 24576000-147456000
max frame size: 345600
default interval: 1/29
interval[0]: 1/29
interval[1]: 1/25
interval[2]: 1/23
interval[3]: 1/14
FrameDescriptor(7)
capabilities: 00
size: 1280x720
bit rate: 24576000-147456000
max frame size: 1843200
default interval: 1/10
interval[0]: 1/10
END DEVICE CONFIGURATION
[stream.c:279] begin uvc_get_stream_ctrl_format_size
[stream.c:137] begin uvc_query_stream_ctrl
[stream.c:182] end uvc_query_stream_ctrl (-99)
[stream.c:137] begin uvc_query_stream_ctrl
[stream.c:182] end uvc_query_stream_ctrl (-99)
[stream.c:137] begin uvc_query_stream_ctrl
[stream.c:182] end uvc_query_stream_ctrl (-99)
[stream.c:351] end uvc_get_stream_ctrl_format_size (0)
[stream.c:520] begin uvc_start_streaming
[stream.c:137] begin uvc_query_stream_ctrl
[stream.c:182] end uvc_query_stream_ctrl (-99)
[device.c:1245] begin _uvc_status_callback
[device.c:1253/_uvc_status_callback] not processing/resubmitting, status = 1
[device.c:1254] end _uvc_status_callback
[stream.c:713] end uvc_start_streaming (-5)
uvc_start_iso_streaming: Not found (-5)
[device.c:1109] begin uvc_close
[device.c:662] begin uvc_release_ifs
[device.c:667] end uvc_release_ifs
[device.c:588] begin uvc_unref_device
[device.c:596] end uvc_unref_device
[device.c:1083] begin uvc_free_devh
[device.c:315] begin uvc_free_device_info
[device.c:355] end uvc_free_device_info
[device.c:1097] end uvc_free_devh
[device.c:1124] end uvc_close
[device.c:588] begin uvc_unref_device
[device.c:596] end uvc_unref_device

Thanks for your time,
Steve

Shouldn't struct uvc_format_desc have a member enum uvc_frame_format?

Maybe I'm being silly here, but shouldn't the struct uvc_format_desc have a member enum uvc_frame_format? I'm trying to implement a function like "find me a suitable format for this and that resolution". The return values of this function should then be the input to uvc_get_stream_ctrl_format_size().

I've found the function uvc_get_format_descs() (which is not in the doxygen documentation, btw.) to get me a list of formats and resolutions available for a camera, but I can't map the GUID in its return values to the enum uvc_frame_format required by uvc_get_stream_ctrl_format_size.

What am I missing?

example.c ends in a segfault

I am trying to use a Logitech C310 camera for an application I am working on. I am curious if people else have successfully run example.c as is.

I downloaded the code as instructed on my linux machine. I moved the example.c code into the build directory and compiled it with this:
gcc example.c -o exampleprog -luvc
(Originally there was an access denied problem so I am running it as a root user, but that does not seem be the issue. )

When running the code it ends in,Segmentation fault (core dumped). However, when i reduce the parameters such as image size to 160x120, or fps (to 10) and sleep time (to 1 sec). Then the code will complete. I need the larger image for my application so I would appreciate advice on this.

Is the camera not set up properly or something else I could be missing...
Any advice or solutions for this?

Thank you-
RLS

UPDATE: I just noticed this print out when the program runs- could it be related?
UVC initialized
Device found
unsupported descriptor subtype: 13
unsupported descriptor subtype: 13
Device opened
DEVICE CONFIGURATION (046d:081b/D447D130) ---

Synchronized Capture Across Multiple Devices

Hi,
I would like to utilize many webcams and capture frames from each one in a synchronized fashion. Is this possible to do this with USB wecbams? And if so can you point me in the right direction in the code where actual frame requests / triggers occur?

Thank you for any help you may have!

Multi camera support

I got single camera to work. I am trying to get two cameras to stream at the same time. I tried creating one context two devices, two context one for each device, and moving two devices onto two different threads. It seems none of these works. The second device will never pass uvc_open() although the first one works just fine. Does this library support multiple devices simultaneous streaming? If so, what is the proper way to do it? Thank~!

Building with jpeg support

I am building and extending libuvc_ros which depends on libuvc. I can get libuvc to compile and install, when configuring with cmake it even says it is "Building libuvc with JPEG support.". However when I want to use the libraries function uvc_mjpeg2rgb it complains it is not defined. This makes sense since in the header LIBUVC_HAS_JPEG is not defined. How can this be fixed so that LIBUVC_HAS_JPEG is defined and the function uvc_mjpeg2rgb can be called?

License?

I cannot find a License file. What are the terms of use, and contribution?

LIBUSB_INCLUDE_DIR build errors with Debian 7.7

I have libusb-1.0-0-dev installed, but running cmake gives this error:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LIBUSB_INCLUDE_DIR
   used as include directory in directory /tmp/uv/libuvc-master
LIBUSB_LIBRARY_NAMES
    linked by target "uvc" in directory /tmp/uv/libuvc-master

-- Configuring incomplete, errors occurred!

Additional Pixel Format Options

I'm having trouble capturing from a camera that provides data in the YUV 4:2:0 format (I420p) or Y16. It seems that the capture parameters are not accepted, probably because I am unable to set the correct pixel format in libuvc. The uvc_frame_format enum doesn't seem to include those formats. Is there a way to add this to libuvc?

Contact

Hi,

I couldn't seem to find your contact info so feel free to take down my info and then remove this. I have used your code to make a android framework for connecting a uvc camera to a phone/tablet (very slightly modified with also a very slightly modified libusb). It was important to me that the system to user space so it would work on non rooted/modified devices.

I wanted to talk to you about 2 things, the first is about contributing back memory leak fixes that I will now be working on. Android JNI C instances have a very small heap so even small memory leaks per frame add up relatively quickly so although it will run for hours on the desktop i'm seeing about 2-3 mins on a tablet. As i go about updating to you latest version and tracking down some of these issues it would be great to get those fixes back in the official version.

The second thing would be a broader discussion of whether you want to make your library android compatible. This would involve relatively minor modifications. Things like when "#define android" have messages sent to android LOG instead of stdio/stderr, some extra includes when that flag is present and the addition of a file descriptor parameter to a bunch of functions (since in android you cant "open" the device in C you have to pass in a file descriptor and then pas it down to the libusb open() call and then set the libusb object file descriptor to the one provided rather than a new one)

anyway, keep up the good work and feel free to contact me at
[email protected]

Is there something missing in the installation of libuvc

I am interested in installing the libuvc package for python.

I went to the page at https://github.com/pupil-labs/libuvc and followed the instructions at the bottom.

Here is the following data:
OS: MS Windows 7 (64 (bit)
Python: 3.4.4 (64 bit)
Opencv: 3.2.0
libusb: 1.0.19.10905, from usb0.getVersion() = major= 1, minor=0, micro=19, nano=10905, rc=b'', describe=b'http://libusb.info = 1.0.19.10905
CMake: 3.8.0-rc2

I looked at https://github.com/pupil-labs/pyuvc/blob/master/WINDOWS_USER.md and this does not apply since I have Windows 7 and not Window 8.

Here is the output from the cmake program. Using MSVC2015.

The C compiler identification is MSVC 19.0.24215.1
The CXX compiler identification is MSVC 19.0.24215.1
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
No build type selected, default to Release
No target type selected, default to shared library
Building libuvc with JPEG support.
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
JPEG_LIBRARY_NAMES
    linked by target "uvc" in directory C:/Python34/libuvc
LIBUSB_INCLUDE_DIR
   used as include directory in directory C:/Python34/libuvc
   used as include directory in directory C:/Python34/libuvc
LIBUSB_LIBRARY_NAMES
    linked by target "uvc" in directory C:/Python34/libuvc
PTHREAD_INCLUDE_DIR
   used as include directory in directory C:/Python34/libuvc
   used as include directory in directory C:/Python34/libuvc
PTHREAD_LIBRARY_NAMES
    linked by target "uvc" in directory C:/Python34/libuvc

Configuring incomplete, errors occurred!
See also "C:/Python34/libuvc/CMakeFiles/CMakeOutput.log".

Have I missed something?
Thank you for your assistance
Remarks:
I have Windows 7 and not a Developer so the md files were irrelevant.
I have the pre-requisites listed at https://github.com/pupil-labs/libuvc/blob/master/INSTALL_WINDOWS.md
Even though I am not a 'developer' as in the md file, I still downloaded "libjpeg-turbo64" and set up the correct environment variables in the path.

Even though I am not a Win8 user, I did notice that the requirement to download download and install libusbk 3.0.7.0 at https://sourceforge.net/projects/libusbk/files/libusbK-release/3.0.7.0/libusbK-3.0.7.0-setup.exe/download for Window 8 caused my Symantec end point protection anti-virus program reported this as having the following issues:

* WS.Reputation.1
* There is strong evidence that this file is untrustworthy.
* This file has been seen by hundreds of Symantec users.
* Symantec has known about this file for more than 1 year.
* There is strong evidence that this file is untrustworthy.

There is no evidence of other anti-virus/anti-malware/anti-spybot on my computer programs detecting this problem.

Some trouble installing libuvc

-- checking for module 'libjpeg'
-- package 'libjpeg' not found
-- Building libuvc with JPEG support.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/exbot/libuvc/build
I can't find the 'libjpeg' package,I don't know how to fix it,should I install some sofeware before I do it?Thank you

Trouble installing libuvc

I have tried to install libuvc. I downloaded libuvc-master.
Using the GUI version of CMake, I am still getting the following errors.

The C compiler identification is MSVC 19.0.24215.1
The CXX compiler identification is MSVC 19.0.24215.1
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
No build type selected, default to Release
No target type selected, default to shared library
Building libuvc with JPEG support.
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
JPEG_LIBRARY_NAMES
    linked by target "uvc" in directory C:/Python34/libuvc-master
LIBUSB_INCLUDE_DIR
   used as include directory in directory C:/Python34/libuvc-master
   used as include directory in directory C:/Python34/libuvc-master
LIBUSB_LIBRARY_NAMES
    linked by target "uvc" in directory C:/Python34/libuvc-master
PTHREAD_INCLUDE_DIR
   used as include directory in directory C:/Python34/libuvc-master
   used as include directory in directory C:/Python34/libuvc-master
PTHREAD_LIBRARY_NAMES
    linked by target "uvc" in directory C:/Python34/libuvc-master

Configuring incomplete, errors occurred!
See also "C:/Python34/libusb-master/CMakeFiles/CMakeOutput.log".

What are these values? Are they environment values? Where are they supposed to be set?

JPEG_LIBRARY_NAMES, LIBUSB_INCLUDE_DIR, PTHREAD_INCLUDE_DIR, PTHREAD_LIBRARY_NAMES

The C:/Python34/libusb-master/CMakeFiles/CMakeOutput.log is attached. But there is nothing extraordinary as there is no evidence of errors.
cmakeoutput.log.txt

My environment:

OS: Windows 7, 64-bit
CMake: 3.8.0rc2
Compiler: MSVC 2015 version 19.0.24215.1 64-bit
Python: 3.4, 64-bit

I am just one step closer to getting a successful compile. Any assistance would be grateful.

Thank you,
Anthony, Sydney NSW

About libuvc resolution set

Hi all
libuvc with libusb, the resolution of the equipment acquired with VLC not get the same resolution , the resolution of the device is set to 1920 * 960, libuvc obtained is 1280 * 720,But is not the same bitrate setting you are 8M, libuvc acquired only 2M, libuvc have not provided initialize the device resolution and bitrate of API

glut integration and segmentation fault errors

I would like to know how to use both libuvc and glut in the same application.
I set a capture callback function using uvc_stream_start() and then set a
display callback function using glutDisplayfunc(), where I read the values set
in the other function. I am getting random segmentation fault errors in the libuvc library
and I do not know if they are caused because memory can be accessed from different
threads simultaneously. Some times the program works and some others does not.

Should I include a mutex mechanism somehow? Should I use other way to get the frames, such as invoking uvc_stream_get_frame() in the glut loop? It would be great if you could provide me an example on how to do things correctly.

CMake Error: install TARGETS given target "uvc_static" which does not exist

-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: /usr/bin/x86_64-pc-linux-gnu-gcc
-- Check for working C compiler: /usr/bin/x86_64-pc-linux-gnu-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/x86_64-pc-linux-gnu-g++
-- Check for working CXX compiler: /usr/bin/x86_64-pc-linux-gnu-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: x86_64-pc-linux-gnu-pkg-config (found version "0.29.2") 
-- Checking for module 'libusb-1.0'
--   Found libusb-1.0, version 1.0.21
-- Checking for module 'libjpeg'
--   Found libjpeg, version 1.5.2
-- Building libuvc with JPEG support.
CMake Error at CMakeLists.txt:95 (install):
  install TARGETS given target "uvc_static" which does not exist in this
  directory.


-- <<< Gentoo configuration >>>
Build type      Gentoo
Install path    /usr
Compiler flags:
C               -march=core-avx2 -O2 -pipe
C++             -march=core-avx2 -O2 -pipe
Linker flags:
Executable      -Wl,-O1 -Wl,--as-needed
Module          -Wl,-O1 -Wl,--as-needed
Shared          -Wl,-O1 -Wl,--as-needed

-- Configuring incomplete, errors occurred!

UVC 1.5

Is version 1.5 of the class specification already supported or, if not, is it planned? At present it appears only version 1.1. is supported; is that right?

libuvc on Windows

Has anyone successfully streamed webcam images from this library on Windows?

I've done the necessary porting to make it compile, and installed WinUSB drivers (as per libusb), but claiming the interface when I want to stream returns an ERROR_NOT_SUPPORTED and if I hack to pick an interface that claims correctly, I get an ERROR_PIPE.

This is a Logitech C270 camera, running the example.cpp and test.cpp, and works perfectly on Linux using the same computer.

Thanks!
-SJ

New Release

The latest release was tagged in 2014 and quite some development has happened since then.
Especially, libuvc_ros' master branch currently does not build with a released version of libuvc because it misses the uvc_find_devices function.

It would be great to have a new version tag for this library!

Multiple streams on same device

Theoretical implementation question. If the library were to support a device with multiple control and streaming interfaces, how would the lib need to adapt?

Why is there no uninstall rule?

The Makefile does not contain an uninstall target or such. I would like to avoid tracking down all installed files by hand.

Bulk Transfer results in LIBUSB_TRANSFER_TIMED_OUT

Occasionally upon connecting to the device and opening a stream, I only get LIBUSB_TRANSFER_TIMED_OUT inside _uvc_stream_callback.

I can only make this go away by reconnecting the device.

My device has a blinking LED when the transfer is working, and it's not blinking in this state.

Any ideas why this would happen?

This might not really be a libuvc issue, it might be bugginess in the hardware or Android OS.
I am acutally using https://github.com/saki4510t/UVCCamera which has modified this library.

Excessive use of realloc() in _uvc_populate_frame() ( stream.c )

While working through how to make our code exclusively use externally allocated data buffers, I came across this one ..

In _uvc_populate_frame(), the code only calls realloc() when the buffer isn't big enough.

However, the data_bytes field in the uvc_frame_t structure is always updated to the currently being processed frame size, whether or not realloc() has been called.

This didn't seem an obvious issue at first .. OK the first buffer may be huge, with a small amount of data actually in it, but next time around, using the same frame/buffer, if the received frame is bigger than the last recieved frame, then realloc() will be called, thus reducing the size of the buffer, even though the buffer is actually big enough to hold the data.
This results in frequent calls to realloc() .. which can result in fragmentation of the memory pool.

The uvc_frame_t structure should probably have two elements, one for the actual size of the data buffer, and another for how many bytes are actually used.
That way, the buffer could be enlarged only when needed.

Our plan was to always supply a 2K buffer, as most of the frames are between 500 bytes to 2K.
Then allow realloc() to be used for the I-frames which are generally much larger.
In my initial testing, this became obvious, as realloc() was being called for around 50% of the received frames.

Also , on targets where CPU resources are limited, calling realloc() frequently will increase the CPU load, and may ultimately result in missed frames or worse.

Disable auto white balance temperature

I am trying to disable the auto white balance temperature on my Logitech C920 camera and set it to a fixed value. I can control other settings without any problems (i.e. disabling auto focus or auto exposure), but when I call "uvc_set_white_balance_temperature_auto" with the parameter "temperature_auto" set to 0, it always returns UVC_PIPE_ERROR.

Has anyone else had the same problem? I know my camera supports this feature (I can make the changes with v4l2-ctl), but for some reason I cannot get it to work.

note on udev rules

The readme could use a note on udev rules for linux. A simple (awfully permissive) rule:

'SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", GROUP="plugdev", MODE="0664

two lines in terminal:

echo 'SUBSYSTEM=="usb",  ENV{DEVTYPE}=="usb_device", GROUP="plugdev", MODE="0664"' | sudo tee /etc/udev/rules.d/10-libuvc.rules 
sudo udevadm trigger

asynchronous/callback vs synchronous/polling

i am getting great performance out of the library for streaming (i think i am using synchronous) and i am now trying to push it closer to the framerates my high-speed camera is capable of (according to specs). i would love to get frames more often (even if they are duplicates of previous ones). anyone have experience with grabbing frames in asynchronous mode? any examples much obliged.

Streaming problem [fixed]

I had a piece of code using libuvc on a Ubuntu 14 computer. The code is working perfectly. I also have a laptop with Ubuntu 14, and the same config and the same code is not working.

libUVC has troubles to stream the data from my device.

After some research I found out that this is due to characteristics specific of your OS and hardware. In order to fix that, you can try to change the constant "LIBUVC_NUM_TRANSFER_BUFS" defined in /include/libuvc/libuvc_internal.h at line 216. Changing from 100 to 10 and rebuild the lib fixed my problem.

High resolution image capture

Is it possible to utilize a cameras full (i.e. 8MP) resolution for image capture with this library? It appears that "one-shot image capture" is on the roadmap but hasn't yet been developed.

I would appreciate any guidance on this issue.

Hang & crash on close

Hi,

I've just started trying to utilize this library as part of one of my projects. The issue I'm running into is that the program hangs (in debug) or crashes if just running when the library is disconnecting. This happens between the pthread_join and libusb_exito n lines 151 and 152 of init.c. (I've manually built both libuvc and libusbx from git)

  if (ctx->own_usb_ctx) {
    pthread_kill(ctx->handler_thread, SIGINT);
    pthread_join(ctx->handler_thread, NULL);
    libusb_exit(ctx->usb_ctx);
  }

This is part of the code I'm using - so far I've just opened the device and queried the device descriptor, and then closing it like this:

    uvc_close(devh);
    uvc_unref_device(dev);
    uvc_exit(ctx);

From what I can see it looks like it's waiting 60 seconds for the libusb timeout to expire and after that quits... Before I write my own context handler and such I was wondering if you had any insight that would save me time?

Thanks!

Morgan

Implement population of capture_time

Hi, looking through the code I noticed that capture_time never get properly populated. IMHO ideally this should be the SOE as in v4l2's uvcvideo module.

Any reason for this? Would this be a lot of work?

I m new to this library and I plan to write a python wrapper similar to this one: https://github.com/pupil-labs/pyv4l2 so that one can get cross platform uvc access from python.

How to get brightness while streaming without affecting preivew?

I am doing some tests using libuvc on my camera device. My purpose is to get the brightness of each frame. I am using pthread to start a preivew
pthread_create(&preview_thread, NULL, preview_func, (void *)this);
and in preview_func I use a callback to get preview frame
uvc_error_t result = uvc_start_streaming_bandwidth(devh, ctrl, preview_frame_callback, (void *)this, Bandwidth, 0);
In preview_frame_callback, after copy frame to UI interface, I try to get brightness like this
`void preview_frame_callback(uvc_frame_t *frame, void *vptr) {

//do copy frame to UI
int16_t value;
uvc_get_brightness(devh, &value, 0x81)
}`
It get brightness successfully, but doing this also make the preview looks strange.The preview looks like a combination of two adjacent frame.
If I remove the uvc_get_brightness line, the preview works fine.
So how could I get brightness after a frame comes in?

Question: Force bulk transfer

Hi,
Some cameras have alt settings with tremendously oversized packet sizes and I would like to not use iso transfers in this case.

Is is possible to force bulk transfer?
(I tried forcing bulk transfers in stream.c but libusb_submit_transfer fails with 'Entity not found.' .)

Any pointers would be very appreciated.

compile errors

i now get compile errors on mac osx

$ make && make install
Scanning dependencies of target uvc
[ 10%] Building C object CMakeFiles/uvc.dir/src/ctrl.c.o
[ 20%] Building C object CMakeFiles/uvc.dir/src/ctrl-gen.c.o
[ 30%] Building C object CMakeFiles/uvc.dir/src/device.c.o
[ 40%] Building C object CMakeFiles/uvc.dir/src/diag.c.o
[ 50%] Building C object CMakeFiles/uvc.dir/src/frame.c.o
[ 60%] Building C object CMakeFiles/uvc.dir/src/init.c.o
[ 70%] Building C object CMakeFiles/uvc.dir/src/stream.c.o
[ 80%] Building C object CMakeFiles/uvc.dir/src/misc.c.o
[ 90%] Building C object CMakeFiles/uvc.dir/src/frame-mjpeg.c.o
make[2]: *** No rule to make target `/usr/local/lib/libjpeg.dylib', needed by `libuvc.dylib'.  Stop.
make[1]: *** [CMakeFiles/uvc.dir/all] Error 2
make: *** [all] Error 2

any suggestions. i have /usr/local/lib/libjpeg.dylib which is an alias pointing to -> ../Cellar/jpeg/8d/lib/libjpeg.dylib . tx a bunch

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.