/usr/share/doc/libuvc-dev/apiref/index.html is in libuvc-doc 0.0.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libuvc: libuvc: a cross-platform library for USB video devices</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">libuvc
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',false,false,'search.php','Search');
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">libuvc: a cross-platform library for USB video devices </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p><b>libuvc</b> is a library that supports enumeration, control and streaming for USB Video Class (UVC) devices, such as consumer webcams.</p>
<h1><a class="anchor" id="features"></a>
Features</h1>
<ul>
<li>UVC device <a class="el" href="group__device.html">discovery and management</a> API </li>
<li><a class="el" href="group__streaming.html">Video streaming</a> (device to host) with asynchronous/callback and synchronous/polling modes </li>
<li>Read/write access to standard <a class="el" href="group__ctrl.html">device settings</a> </li>
<li><a class="el" href="group__frame.html">Conversion</a> between various formats: RGB, YUV, JPEG, etc. </li>
<li>Tested on Mac and Linux, portable to Windows and some BSDs</li>
</ul>
<h1><a class="anchor" id="roadmap"></a>
Roadmap</h1>
<ul>
<li>Bulk-mode image capture </li>
<li>One-shot image capture </li>
<li>Improved support for standard settings </li>
<li>Support for "extended" (vendor-defined) settings</li>
</ul>
<h1><a class="anchor" id="misc"></a>
Misc.</h1>
<p><code>The</code> source code can be found at <a href="https://github.com/ktossell/libuvc">https://github.com/ktossell/libuvc</a>. To build the library, install <a href="http://libusb.org/">libusb</a> 1.0+ and run:</p>
<div class="fragment"><div class="line">$ git clone https:<span class="comment">//github.com/ktossell/libuvc.git</span></div><div class="line">$ cd libuvc</div><div class="line">$ mkdir build</div><div class="line">$ cd build</div><div class="line">$ cmake -DCMAKE_BUILD_TYPE=Release ..</div><div class="line">$ make && make install</div></div><!-- fragment --><h1><a class="anchor" id="Example"></a>
Example</h1>
<p>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.</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include "libuvc/libuvc.h"</span></div><div class="line"><span class="preprocessor">#include <stdio.h></span></div><div class="line"></div><div class="line"><span class="comment">/* This callback function runs once per frame. Use it to perform any</span></div><div class="line"><span class="comment"> * quick processing you need, or have it put the frame into your application's</span></div><div class="line"><span class="comment"> * input queue. If this function takes too long, you'll start losing frames. */</span></div><div class="line"><span class="keywordtype">void</span> cb(<a class="code" href="structuvc__frame.html">uvc_frame_t</a> *frame, <span class="keywordtype">void</span> *ptr) {</div><div class="line"> <a class="code" href="structuvc__frame.html">uvc_frame_t</a> *bgr;</div><div class="line"> <a class="code" href="group__diag.html#ga4ac5c3ab3d8ab4d405dee4e5968d7da5">uvc_error_t</a> ret;</div><div class="line"></div><div class="line"> <span class="comment">/* We'll convert the image from YUV/JPEG to BGR, so allocate space */</span></div><div class="line"> bgr = <a class="code" href="group__frame.html#gaf7e8f1bcf3150a167302350a30f4aed5">uvc_allocate_frame</a>(frame-><a class="code" href="structuvc__frame.html#a212466559efbd277bd1b74dc8384b7b2">width</a> * frame-><a class="code" href="structuvc__frame.html#a5b89ea77dd8d5f53b269611023d7de81">height</a> * 3);</div><div class="line"> <span class="keywordflow">if</span> (!bgr) {</div><div class="line"> printf(<span class="stringliteral">"unable to allocate bgr frame!"</span>);</div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">/* Do the BGR conversion */</span></div><div class="line"> ret = <a class="code" href="group__frame.html#gaef12599cf6acb2378e2c5701fcd0215b">uvc_any2bgr</a>(frame, bgr);</div><div class="line"> <span class="keywordflow">if</span> (ret) {</div><div class="line"> <a class="code" href="group__diag.html#gae121ad3636e456a0559a864e43f1f38d">uvc_perror</a>(ret, <span class="stringliteral">"uvc_any2bgr"</span>);</div><div class="line"> <a class="code" href="group__frame.html#gaae9f26de47387e439b9a29e50a75fe78">uvc_free_frame</a>(bgr);</div><div class="line"> <span class="keywordflow">return</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">/* Call a user function:</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * my_type *my_obj = (*my_type) ptr;</span></div><div class="line"><span class="comment"> * my_user_function(ptr, bgr);</span></div><div class="line"><span class="comment"> * my_other_function(ptr, bgr->data, bgr->width, bgr->height);</span></div><div class="line"><span class="comment"> */</span></div><div class="line"></div><div class="line"> <span class="comment">/* Call a C++ method:</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * my_type *my_obj = (*my_type) ptr;</span></div><div class="line"><span class="comment"> * my_obj->my_func(bgr);</span></div><div class="line"><span class="comment"> */</span></div><div class="line"></div><div class="line"> <span class="comment">/* Use opencv.highgui to display the image:</span></div><div class="line"><span class="comment"> * </span></div><div class="line"><span class="comment"> * cvImg = cvCreateImageHeader(</span></div><div class="line"><span class="comment"> * cvSize(bgr->width, bgr->height),</span></div><div class="line"><span class="comment"> * IPL_DEPTH_8U,</span></div><div class="line"><span class="comment"> * 3);</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * cvSetData(cvImg, bgr->data, bgr->width * 3); </span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * cvNamedWindow("Test", CV_WINDOW_AUTOSIZE);</span></div><div class="line"><span class="comment"> * cvShowImage("Test", cvImg);</span></div><div class="line"><span class="comment"> * cvWaitKey(10);</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * cvReleaseImageHeader(&cvImg);</span></div><div class="line"><span class="comment"> */</span></div><div class="line"></div><div class="line"> <a class="code" href="group__frame.html#gaae9f26de47387e439b9a29e50a75fe78">uvc_free_frame</a>(bgr);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv) {</div><div class="line"> uvc_context_t *ctx;</div><div class="line"> uvc_device_t *dev;</div><div class="line"> uvc_device_handle_t *devh;</div><div class="line"> <a class="code" href="structuvc__stream__ctrl.html">uvc_stream_ctrl_t</a> ctrl;</div><div class="line"> <a class="code" href="group__diag.html#ga4ac5c3ab3d8ab4d405dee4e5968d7da5">uvc_error_t</a> res;</div><div class="line"></div><div class="line"> <span class="comment">/* Initialize a UVC service context. Libuvc will set up its own libusb</span></div><div class="line"><span class="comment"> * context. Replace NULL with a libusb_context pointer to run libuvc</span></div><div class="line"><span class="comment"> * from an existing libusb context. */</span></div><div class="line"> res = <a class="code" href="group__init.html#ga7fe8755994cdad6cd8dfc31be053e807">uvc_init</a>(&ctx, NULL);</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (res < 0) {</div><div class="line"> <a class="code" href="group__diag.html#gae121ad3636e456a0559a864e43f1f38d">uvc_perror</a>(res, <span class="stringliteral">"uvc_init"</span>);</div><div class="line"> <span class="keywordflow">return</span> res;</div><div class="line"> }</div><div class="line"></div><div class="line"> puts(<span class="stringliteral">"UVC initialized"</span>);</div><div class="line"></div><div class="line"> <span class="comment">/* Locates the first attached UVC device, stores in dev */</span></div><div class="line"> res = <a class="code" href="group__device.html#ga03a47cf340e03fafdca15cfc35620922">uvc_find_device</a>(</div><div class="line"> ctx, &dev,</div><div class="line"> 0, 0, NULL); <span class="comment">/* filter devices: vendor_id, product_id, "serial_num" */</span></div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (res < 0) {</div><div class="line"> <a class="code" href="group__diag.html#gae121ad3636e456a0559a864e43f1f38d">uvc_perror</a>(res, <span class="stringliteral">"uvc_find_device"</span>); <span class="comment">/* no devices found */</span></div><div class="line"> } <span class="keywordflow">else</span> {</div><div class="line"> puts(<span class="stringliteral">"Device found"</span>);</div><div class="line"></div><div class="line"> <span class="comment">/* Try to open the device: requires exclusive access */</span></div><div class="line"> res = <a class="code" href="group__device.html#gaeffc1f5cf48884e620a17f225c0a027c">uvc_open</a>(dev, &devh);</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (res < 0) {</div><div class="line"> <a class="code" href="group__diag.html#gae121ad3636e456a0559a864e43f1f38d">uvc_perror</a>(res, <span class="stringliteral">"uvc_open"</span>); <span class="comment">/* unable to open device */</span></div><div class="line"> } <span class="keywordflow">else</span> {</div><div class="line"> puts(<span class="stringliteral">"Device opened"</span>);</div><div class="line"></div><div class="line"> <span class="comment">/* Print out a message containing all the information that libuvc</span></div><div class="line"><span class="comment"> * knows about the device */</span></div><div class="line"> <a class="code" href="group__diag.html#gabd8c71d63c4ee393426d2132dff38e8a">uvc_print_diag</a>(devh, stderr);</div><div class="line"></div><div class="line"> <span class="comment">/* Try to negotiate a 640x480 30 fps YUYV stream profile */</span></div><div class="line"> res = <a class="code" href="group__streaming.html#gaeda0eee0ea2452abdc60d148cd460f25">uvc_get_stream_ctrl_format_size</a>(</div><div class="line"> devh, &ctrl, <span class="comment">/* result stored in ctrl */</span></div><div class="line"> <a class="code" href="group__streaming.html#gga8b1b5b1d9d6db8b896dd595134b8199bafbbf5380975eade27e8ac7a5b7803209">UVC_FRAME_FORMAT_YUYV</a>, <span class="comment">/* YUV 422, aka YUV 4:2:2. try _COMPRESSED */</span></div><div class="line"> 640, 480, 30 <span class="comment">/* width, height, fps */</span></div><div class="line"> );</div><div class="line"></div><div class="line"> <span class="comment">/* Print out the result */</span></div><div class="line"> <a class="code" href="group__diag.html#gade2fbd6e884f23d774a27f1fa5ff433d">uvc_print_stream_ctrl</a>(&ctrl, stderr);</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (res < 0) {</div><div class="line"> <a class="code" href="group__diag.html#gae121ad3636e456a0559a864e43f1f38d">uvc_perror</a>(res, <span class="stringliteral">"get_mode"</span>); <span class="comment">/* device doesn't provide a matching stream */</span></div><div class="line"> } <span class="keywordflow">else</span> {</div><div class="line"> <span class="comment">/* Start the video stream. The library will call user function cb:</span></div><div class="line"><span class="comment"> * cb(frame, (void*) 12345)</span></div><div class="line"><span class="comment"> */</span></div><div class="line"> res = <a class="code" href="group__streaming.html#ga1125277422bd2002b404b2a02103759c">uvc_start_streaming</a>(devh, &ctrl, cb, 12345, 0);</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (res < 0) {</div><div class="line"> <a class="code" href="group__diag.html#gae121ad3636e456a0559a864e43f1f38d">uvc_perror</a>(res, <span class="stringliteral">"start_streaming"</span>); <span class="comment">/* unable to start stream */</span></div><div class="line"> } <span class="keywordflow">else</span> {</div><div class="line"> puts(<span class="stringliteral">"Streaming..."</span>);</div><div class="line"></div><div class="line"> <a class="code" href="group__ctrl.html#gaa583133ed035c141c42061d5c13a36bf">uvc_set_ae_mode</a>(devh, 1); <span class="comment">/* e.g., turn on auto exposure */</span></div><div class="line"></div><div class="line"> sleep(10); <span class="comment">/* stream for 10 seconds */</span></div><div class="line"></div><div class="line"> <span class="comment">/* End the stream. Blocks until last callback is serviced */</span></div><div class="line"> <a class="code" href="group__streaming.html#ga87302788bcdea097dd6894504a6bcf5f">uvc_stop_streaming</a>(devh);</div><div class="line"> puts(<span class="stringliteral">"Done streaming."</span>);</div><div class="line"> }</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">/* Release our handle on the device */</span></div><div class="line"> <a class="code" href="group__device.html#ga415617d94994b8f4a794cf25c947570c">uvc_close</a>(devh);</div><div class="line"> puts(<span class="stringliteral">"Device closed"</span>);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">/* Release the device descriptor */</span></div><div class="line"> uvc_unref_device(dev);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">/* Close the UVC context. This closes and cleans up any existing device handles,</span></div><div class="line"><span class="comment"> * and it closes the libusb context if one was not provided. */</span></div><div class="line"> <a class="code" href="group__init.html#gabb43dac8f0cf8598afabc9cf207643f8">uvc_exit</a>(ctx);</div><div class="line"> puts(<span class="stringliteral">"UVC exited"</span>);</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line">}</div><div class="line"></div></div><!-- fragment --> </div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Sep 29 2017 21:37:42 for libuvc by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
|