Documentation
¶
Index ¶
- Variables
- type AEMode
- type ControlInterface
- type Device
- func (dev *Device) Close() error
- func (dev *Device) ControlInterface() *ControlInterface
- func (dev *Device) Descriptor() (*DeviceDescriptor, error)
- func (dev *Device) GetAddress() uint8
- func (dev *Device) GetBusNumber() uint8
- func (dev *Device) GetStream(format FrameFormat, width, height, fps int) (*Stream, error)
- func (dev *Device) IsClosed() bool
- func (dev *Device) IsIdle() bool
- func (dev *Device) Open() error
- func (dev *Device) Ref()
- func (dev *Device) SetAEMode(mode AEMode) error
- func (dev *Device) StreamInterfaces() (ifs []*StreamInterface)
- func (dev *Device) Unref()
- type DeviceDescriptor
- type ErrorType
- type FormatDescriptor
- type Frame
- type FrameDescriptor
- type FrameFormat
- type Stream
- type StreamCtrl
- type StreamInterface
- type UVC
- type VSDescSubType
Constants ¶
This section is empty.
Variables ¶
var ( ErrDeviceClosed = errors.New("device closed") ErrDeviceNotFound = errors.New("device not found") )
var (
ErrStreamClosed = errors.New("stream closed")
)
Functions ¶
This section is empty.
Types ¶
type ControlInterface ¶
type ControlInterface struct { BcdUVC uint16 Number uint8 EndpointAddress uint8 ClockFrequency uint32 // contains filtered or unexported fields }
VideoControl interface.
func (*ControlInterface) String ¶
func (i *ControlInterface) String() string
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
func (*Device) Close ¶
Close closes a device. Ends any stream that's in progress. The device handle and frame structures will be invalidated.
func (*Device) ControlInterface ¶
func (dev *Device) ControlInterface() *ControlInterface
func (*Device) Descriptor ¶
func (dev *Device) Descriptor() (*DeviceDescriptor, error)
func (*Device) GetAddress ¶
GetAddress gets the number assigned to the device within its bus.
func (*Device) GetBusNumber ¶
GetBusNumber gets the number of the bus to which the device is attached.
func (*Device) GetStream ¶
func (dev *Device) GetStream(format FrameFormat, width, height, fps int) (*Stream, error)
GetStream gets a negotiated streaming control block for some common parameters.
func (*Device) StreamInterfaces ¶
func (dev *Device) StreamInterfaces() (ifs []*StreamInterface)
type DeviceDescriptor ¶
type DeviceDescriptor struct { VendorID uint16 ProductID uint16 BcdUVC uint16 SerialNumber string Manufacturer string Product string }
func (*DeviceDescriptor) String ¶
func (d *DeviceDescriptor) String() string
type ErrorType ¶
type ErrorType C.enum_uvc_error
const ( SUCCESS ErrorType = C.UVC_SUCCESS ERROR_IO ErrorType = C.UVC_ERROR_IO ERROR_INVALID_PARAM ErrorType = C.UVC_ERROR_INVALID_PARAM ERROR_ACCESS ErrorType = C.UVC_ERROR_ACCESS ERROR_NO_DEVICE ErrorType = C.UVC_ERROR_NO_DEVICE ERROR_NOT_FOUND ErrorType = C.UVC_ERROR_NOT_FOUND ERROR_BUSY ErrorType = C.UVC_ERROR_BUSY ERROR_TIMEOUT ErrorType = C.UVC_ERROR_TIMEOUT ERROR_OVERFLOW ErrorType = C.UVC_ERROR_OVERFLOW ERROR_PIPE ErrorType = C.UVC_ERROR_PIPE ERROR_INTERRUPTED ErrorType = C.UVC_ERROR_INTERRUPTED ERROR_NO_MEM ErrorType = C.UVC_ERROR_NO_MEM ERROR_NOT_SUPPORTED ErrorType = C.UVC_ERROR_NOT_SUPPORTED ERROR_INVALID_DEVICE ErrorType = C.UVC_ERROR_INVALID_DEVICE ERROR_INVALID_MODE ErrorType = C.UVC_ERROR_INVALID_MODE ERROR_CALLBACK_EXISTS ErrorType = C.UVC_ERROR_CALLBACK_EXISTS ERROR_OTHER ErrorType = C.UVC_ERROR_OTHER )
type FormatDescriptor ¶
type FormatDescriptor struct { // Type of image stream, such as JPEG or uncompressed. Subtype VSDescSubType // Identifier of this format within the VS interface's format list FormatIndex uint8 NumFrameDescriptors uint8 // BPP for uncompressed stream BitsPerPixel uint8 // Flags for JPEG stream Flags uint8 DefaultFrameIndex uint8 AspectRatioX uint8 AspectRatioY uint8 InterlaceFlags uint8 CopyProtect uint8 VariableSize uint8 // contains filtered or unexported fields }
device format descriptor. A "format" determines a stream's image type (e.g., raw YUYV or JPEG), and includes many "frame" configurations.
func (*FormatDescriptor) FrameDescriptors ¶
func (d *FormatDescriptor) FrameDescriptors() (descs []*FrameDescriptor)
func (*FormatDescriptor) String ¶
func (d *FormatDescriptor) String() string
type Frame ¶
type Frame struct { // Width of image in pixels Width int // Height of image in pixels Height int // Pixel data format FrameFormat FrameFormat // Number of bytes per horizontal line (undefined for compressed format) Step int // Frame number (may skip, but is strictly monotonically increasing) Sequence uint32 // Estimate of system time when the device started capturing the image CaptureTime time.Time // Is the data buffer owned by the library? // If true, the data buffer can be arbitrarily reallocated by frame conversion functions. // If false, the data buffer will not be reallocated or freed by the library. LibraryOwned bool // Metadata for this frame if available Metadata []byte // contains filtered or unexported fields }
Frame is an image frame received from the UVC device. It implements io.Reader.
type FrameDescriptor ¶
type FrameDescriptor struct { // Type of frame, such as JPEG frame or uncompressed frame Subtype VSDescSubType // Index of the frame within the list of specs available for this format FrameIndex uint8 Capabilities uint8 // Image width Width uint16 // Image height Height uint16 // Bitrate of corresponding stream at minimal frame rate MinBitRate uint32 // Bitrate of corresponding stream at maximal frame rate MaxBitRate uint32 // Maximum number of bytes for a video frame MaxVideoFrameBufferSize uint32 // Default frame interval (in 100ns units) DefaultFrameInterval uint32 // Minimum frame interval for continuous mode (100ns units) MinFrameInterval uint32 // Maximum frame interval for continuous mode (100ns units) MaxFrameInterval uint32 // Granularity of frame interval range for continuous mode (100ns) FrameIntervalStep uint32 // Frame intervals FrameIntervalType uint8 // Number of bytes per line BytesPerLine uint32 // Available frame rates, zero-terminated (in 100ns units) Intervals []uint32 // contains filtered or unexported fields }
Frame descriptor. A "frame" is a configuration of a streaming format for a particular image size at one of possibly several available frame rates.
func (*FrameDescriptor) String ¶
func (d *FrameDescriptor) String() string
type FrameFormat ¶
type FrameFormat C.enum_uvc_frame_format
const ( FRAME_FORMAT_UNKNOWN FrameFormat = C.UVC_FRAME_FORMAT_UNKNOWN // Any supported format FRAME_FORMAT_ANY FrameFormat = C.UVC_FRAME_FORMAT_ANY FRAME_FORMAT_UNCOMPRESSED FrameFormat = C.UVC_FRAME_FORMAT_UNCOMPRESSED FRAME_FORMAT_COMPRESSED FrameFormat = C.UVC_FRAME_FORMAT_COMPRESSED // YUYV/YUV2/YUV422: YUV encoding with one luminance value per pixel and // one UV (chrominance) pair for every two pixels. FRAME_FORMAT_YUYV FrameFormat = C.UVC_FRAME_FORMAT_YUYV FRAME_FORMAT_UYVY FrameFormat = C.UVC_FRAME_FORMAT_UYVY // 24-bit RGB FRAME_FORMAT_RGB FrameFormat = C.UVC_FRAME_FORMAT_RGB FRAME_FORMAT_BGR FrameFormat = C.UVC_FRAME_FORMAT_BGR // Motion-JPEG (or JPEG) encoded images FRAME_FORMAT_MJPEG FrameFormat = C.UVC_FRAME_FORMAT_MJPEG // H.264 encoded images FRAME_FORMAT_H264 FrameFormat = C.UVC_FRAME_FORMAT_H264 // Greyscale images FRAME_FORMAT_GRAY8 FrameFormat = C.UVC_FRAME_FORMAT_GRAY8 FRAME_FORMAT_GRAY16 FrameFormat = C.UVC_FRAME_FORMAT_GRAY16 // Raw colour mosaic images FRAME_FORMAT_BY8 FrameFormat = C.UVC_FRAME_FORMAT_BY8 FRAME_FORMAT_BA81 FrameFormat = C.UVC_FRAME_FORMAT_BA81 FRAME_FORMAT_SGRBG8 FrameFormat = C.UVC_FRAME_FORMAT_SGRBG8 FRAME_FORMAT_SGBRG8 FrameFormat = C.UVC_FRAME_FORMAT_SGBRG8 FRAME_FORMAT_SRGGB8 FrameFormat = C.UVC_FRAME_FORMAT_SRGGB8 FRAME_FORMAT_SBGGR8 FrameFormat = C.UVC_FRAME_FORMAT_SBGGR8 // Number of formats understood FRAME_FORMAT_COUNT FrameFormat = C.UVC_FRAME_FORMAT_COUNT )
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
func (*Stream) Ctrl ¶
func (s *Stream) Ctrl() *StreamCtrl
type StreamCtrl ¶
type StreamCtrl struct { Hint uint16 FormatIndex uint8 FrameIndex uint8 FrameInterval uint32 KeyFrameRate uint16 PFrameRate uint16 CompQuality uint16 CompWindowSize uint16 Delay uint16 MaxVideoFrameSize uint32 MaxPayloadTransferSize uint32 ClockFrequency uint32 FramingInfo uint8 PreferredVersion uint8 MinVersion uint8 MaxVersion uint8 InterfaceNumber uint8 }
func (*StreamCtrl) String ¶
func (sc *StreamCtrl) String() string
type StreamInterface ¶
type StreamInterface struct { // Interface number Number uint8 // USB endpoint to use when communicating with this interface EndpointAddress uint8 TerminalLink uint8 // contains filtered or unexported fields }
VideoStream interface.
func (*StreamInterface) FormatDescriptors ¶
func (i *StreamInterface) FormatDescriptors() (descs []*FormatDescriptor)
func (*StreamInterface) String ¶
func (i *StreamInterface) String() string
type UVC ¶
type UVC struct {
// contains filtered or unexported fields
}
func (*UVC) Exit ¶
func (uvc *UVC) Exit()
Exit closes the UVC context, shutting down any active devices.
func (*UVC) FindDevice ¶
FindDevice finds a device identified by vendor vid, product pid and/or serial number sn.
func (*UVC) GetDevices ¶
type VSDescSubType ¶
type VSDescSubType C.enum_uvc_vs_desc_subtype
VideoStreaming interface descriptor subtype.
const ( VS_UNDEFINED VSDescSubType = C.UVC_VS_UNDEFINED VS_INPUT_HEADER VSDescSubType = C.UVC_VS_INPUT_HEADER VS_OUTPUT_HEADER VSDescSubType = C.UVC_VS_OUTPUT_HEADER VS_STILL_IMAGE_FRAME VSDescSubType = C.UVC_VS_STILL_IMAGE_FRAME VS_FORMAT_UNCOMPRESSED VSDescSubType = C.UVC_VS_FORMAT_UNCOMPRESSED VS_FRAME_UNCOMPRESSED VSDescSubType = C.UVC_VS_FRAME_UNCOMPRESSED VS_FORMAT_MJPEG VSDescSubType = C.UVC_VS_FORMAT_MJPEG VS_FRAME_MJPEG VSDescSubType = C.UVC_VS_FRAME_MJPEG VS_FORMAT_MPEG2TS VSDescSubType = C.UVC_VS_FORMAT_MPEG2TS VS_FORMAT_DV VSDescSubType = C.UVC_VS_FORMAT_DV VS_COLORFORMAT VSDescSubType = C.UVC_VS_COLORFORMAT VS_FORMAT_FRAME_BASED VSDescSubType = C.UVC_VS_FORMAT_FRAME_BASED VS_FRAME_FRAME_BASED VSDescSubType = C.UVC_VS_FRAME_FRAME_BASED VS_FORMAT_STREAM_BASED VSDescSubType = C.UVC_VS_FORMAT_STREAM_BASED )