uvc - Interface to UVC cameras using libuvc
package require tcluvc
uvc option ?arg ...?
This command provides several operations to interface UVC USB cameras using the infrastructure provided by libuvc and libusb which is available on common Linux, FreeBSD, and MacOSX platforms and sometimes found working on Android devices. option indicates what to carry out. Any unique abbreviation for option is acceptable. The valid options are:
uvc close devid
Closes the device identified by devid which has been opened before using uvc open.
uvc convmode devid ?flag?
Reports or modifies the conversion mode for frames acquired from the opened device identified by devid. Conversion mode 1 (on/true) performs frame format/color space conversions in the special UVC thread which controls the USB transfers, mode 0 (off/false) does this instead in the normal Tcl event loop. The default mode is 1.
Reports a three element list of statistic counters on the device identified by devid. The first element is the number of video frames received, the second the number of video frames processed with uvc image, and the third the number of video frames dropped.
Returns device information which can be used for uvc open as a list. Each device adds three elements to the list: the first element is the device name as a colon separated string with two or three fields being vendor ID (hexadecimal, 0x prefix is optional), product ID (hexadecimal, 0x prefix is optional), and bus/device numbers separated by a dot; the second and third list elements are the vendor name, and the product name. To open the device, its name (the colon separated string) must be used, the other two items are available for presentation purposes. If udev support is available (Linux specific), this list is refreshed on plug and unplug of devices. Otherwise, the list is a snapshot of suitable devices currently connected.
uvc format devid ?index fps?
Returns or changes the frame format of the device identified by devid. The optional parameter index is an integer number giving the index of the frame format returned in uvc listformats. The optional parameter fps is the frame rate. If omitted, the currently active index and frame rate are returned. Changing the frame format and rate is only possible if the device is not capturing images.
uvc image devid ?photoImage?
Copies the most recent captured image of the device devid into the photo image identified by photoImage and returns non-zero on success or zero if no data transfer has taken place. If photoImage is omitted, a four element list is returned with the first element being the image width, the second the image height, the third the number of bytes per pixel, and the last the image's RGB values with 3 bytes per pixel in red, green, blue order as a byte array. In this case an error is indicated by throwing an exception.
uvc info devid
Returns information on open devices. If devid is specified, a list of two elements is returned, the first being the device nameand the second the image callback command for that device, i.e. the same arguments which were used on uvc open. If devid is omitted, a list of devids, i.e. all currently opened devices is returned.
uvc listen ?callback?
Retrieves or sets the callback command called on plug and unplug of devices. When a device is plugged or unplugged that callback is invoked with two additional arguments: the type of event (add or remove) and the device name (see uvc devices for the naming convention) which was added or removed. Only usable if udev support is available.
uvc listformats devid
Returns a dictionary keyed by a format index as integer with the values being another dictionary with information about the frame size and rate of the respective frame format. The returned indices can be used in in uvc format to switch to another frame size and/or to change the frame rate.
uvc mirror devid ?x y?
Retrieves or sets flags to mirror captured images along the X or Y axis. Parameters x and y if specified must be boolean values.
uvc open devname callback
Opens the device with device name devname and establishes callback as command to be invoked on captured images and finally returns a devid, i.e. a handle to further deal with the device. An additional parameter is appended when callback is invoked: the devid of the device. For the format of devname see the description of uvc devices.
uvc orientation devid ?degrees?
Retrieves or sets the orientation of captured images regarding image rotation. degrees if specified must be an integer number.
uvc parameters devid ?key value ...?
Returns or changes device parameters for the device identified by devid given as key-value pairs, e.g. brightness 100 will change the brightness setting of captured images to the device dependent value 100. The command returns the current device parameters (after the potential change, when keys and values were given) as a key-value list which can be processed with array set or dict get.
uvc start devid
Starts capturing images of the device identified by devid. When an image is ready, the callback command set on uvc open is invoked.
uvc state devid
Returns the image capture state of the device identified by devid. The result is the string capture if the device is started, stopped if the device is stopped, or error if an error has been detected while image capture was active.
uvc stop devid
Stop capturing images of the device identified by devid.