Documentation ¶
Overview ¶
Package v4l is a facade to the Video4Linux video capture interface.
Index ¶
- Constants
- type Buffer
- func (b *Buffer) Len() int
- func (b *Buffer) Read(dst []byte) (int, error)
- func (b *Buffer) ReadAt(dst []byte, offset int64) (int, error)
- func (b *Buffer) ReadByte() (byte, error)
- func (b *Buffer) Seek(offset int64, whence int) (int64, error)
- func (b *Buffer) SeqNum() uint32
- func (b *Buffer) Size() int64
- type BufferInfo
- type ControlInfo
- type Device
- func (d *Device) BufferInfo() (BufferInfo, error)
- func (d *Device) Capture() (*Buffer, error)
- func (d *Device) Close()
- func (d *Device) ControlInfo(cid uint32) (ControlInfo, error)
- func (d *Device) DeviceInfo() (DeviceInfo, error)
- func (d *Device) GetConfig() (DeviceConfig, error)
- func (d *Device) GetControl(cid uint32) (int32, error)
- func (d *Device) ListConfigs() ([]DeviceConfig, error)
- func (d *Device) ListControls() ([]ControlInfo, error)
- func (d *Device) SetConfig(cfg DeviceConfig) error
- func (d *Device) SetControl(cid uint32, value int32) error
- func (d *Device) TurnOff()
- func (d *Device) TurnOn() error
- type DeviceConfig
- type DeviceInfo
- type Error
- type Frac
Constants ¶
const ( // Integer controls CtrlBrightness = 0x00980900 CtrlContrast = 0x00980901 CtrlSaturation = 0x00980902 CtrlHue = 0x00980903 CtrlGamma = 0x00980910 CtrlExposure = 0x00980911 CtrlGain = 0x00980913 CtrlWhiteBalance = 0x0098091a CtrlSharpness = 0x0098091b CtrlBacklightCompensation = 0x0098091c // Boolean controls CtrlHFlip = 0x00980914 CtrlVFlip = 0x00980915 CtrlAutoWhiteBalance = 0x0098090c CtrlAutoGain = 0x00980912 CtrlAutoHue = 0x00980919 CtrlAutoBrightness = 0x00980920 // Enums CtrlPowerLineFreq = 0x00980918 PowerLineFreqDisabled = 0 PowerLineFreq50Hz = 1 PowerLineFreq60Hz = 2 PowerLineFreqAuto = 3 // Buttons CtrlDoWhiteBalance = 0x0098090d )
Control IDs. Devices may have other controls than these, including custom (driver specific) ones.
const ( // ErrWrongDevice is returned by Open when attempting to open a file that is // not a V4L capture device. ErrWrongDevice = Error("not a V4L capture device") // ErrUnsupported indicates that an operation failed due to a limitation of // this library. ErrUnsupported = Error("unsupported device or operation") // ErrBufferGone is returned by methods of Buffer when the contents of the // buffer is no longer available. ErrBufferGone = Error("buffer contents not available") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
A Buffer holds the raw image data of a frame captured from a Device. It implements io.Reader, io.ByteReader, io.ReaderAt, and io.Seeker. A call to Capture, Close, or TurnOff on the corresponding Device may cause the contents of the buffer to go away.
func (*Buffer) Len ¶
Len returns the number of unread bytes in the buffer. If the data is no longer available, it returns 0.
func (*Buffer) Read ¶
Read reads up to len(dst) bytes into dst, and returns the number of bytes read, along with any error encountered.
func (*Buffer) ReadAt ¶
ReadAt reads up to len(dst) bytes into dst starting at the specified offset, and returns the number of bytes read, along with any error encountered. The seek offset is unaffected by ReadAt.
type BufferInfo ¶
type BufferInfo struct { // BufferSize is the number of bytes required to hold an image. For variable // length compressed formats, it's the maximum size an image may take up. BufferSize int // ImageStride is the distance in bytes between the leftmost pixels of // adjacent lines. ImageStride int }
A BufferInfo provides information about how image data is laid out in a buffer.
type ControlInfo ¶
type ControlInfo struct { // CID is the identifier of the control. (e.g. 0x00980900) CID uint32 // Name is the name of the control. (e.g. "Brightness") Name string // Type is the type of the control, one of "int", "bool", "enum", // or "button". // - The valid values of an integer control are determined by Min, Max, // and Step. // - A boolean control can only have the values 0 and 1, where 0 means // "disabled" and 1 means "enabled". // - Enums can only take values from a predefined set. (see Options) // - Buttons perform some action when pushed, and they don't have a value. // Reading the value of a button fails, while setting it to any value is // interpreted as a push. Type string // Min and Max specify the range of values the control can take, and Step is // the smallest change actually affecting the hardware. They are only // meaningful for integer type controls. Min int32 Max int32 Step int32 // Default is the default value of the control. Default int32 // Options is the list of valid values of an enum type control. For other // types it's nil. Options []struct { Value int32 Name string } }
A ControlInfo provides information about a control.
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
A Device represents a V4L capture device.
func Open ¶
Open opens the capture device named by path. If the file is not a capture device, it fails with ErrWrongDevice.
func (*Device) BufferInfo ¶
func (d *Device) BufferInfo() (BufferInfo, error)
BufferInfo returns information about how image data is laid out in a buffer. For the same device configuration it always returns the same value.
func (*Device) Capture ¶
Capture grabs the next frame, and returns a new Buffer holding the raw image data. The device must be turned on for Capture to succeed. A call to Capture may render the contents of previously captured buffers unavailable.
func (*Device) Close ¶
func (d *Device) Close()
Close closes the device, freeing all native resources associated with it. It stops any capture session in progress, and it may also render the contents of previously captured buffers unavailable.
func (*Device) ControlInfo ¶
func (d *Device) ControlInfo(cid uint32) (ControlInfo, error)
ControlInfo returns information about a control.
func (*Device) DeviceInfo ¶
func (d *Device) DeviceInfo() (DeviceInfo, error)
DeviceInfo returns information about the device.
func (*Device) GetConfig ¶
func (d *Device) GetConfig() (DeviceConfig, error)
GetConfig returns the current configuration of the device.
func (*Device) GetControl ¶
GetControl returns the current value of a control.
func (*Device) ListConfigs ¶
func (d *Device) ListConfigs() ([]DeviceConfig, error)
ListConfigs returns a slice of all valid configurations of the device. It may fail with ErrUnsupported.
func (*Device) ListControls ¶
func (d *Device) ListControls() ([]ControlInfo, error)
ListControls returns the ControlInfo for every control the device has.
func (*Device) SetConfig ¶
func (d *Device) SetConfig(cfg DeviceConfig) error
SetConfig configures the device according to cfg. The configuration actually applied may be different from what was requested, as drivers are allowed to adjust the parameters against hardware capabilities (or even completely ignore them). The configuration cannot be changed while the device is turned on.
func (*Device) SetControl ¶
SetControl sets the value of a control.
type DeviceConfig ¶
type DeviceConfig struct { // Format is the four-character code (FourCC) of the pixel format, with the // first character at the lowest byte. Format uint32 // Width and Height specify the image dimensions. Width int Height int // FPS specifies the frame rate. FPS Frac }
A DeviceConfig encapsulates the configuration of a capture device.
type DeviceInfo ¶
type DeviceInfo struct { // Path is the device path. (e.g. /dev/video0) Path string // DeviceName is the name of the device. (e.g. "Yoyodyne TV/FM") DeviceName string // BusInfo is the location of the device in the system. // (e.g. "PCI:0000:05:06.0") BusInfo string // DriverName is the name of the driver. (e.g. "bttv") DriverName string // DriverVersion contains the three components of the driver's version // number. (e.g. [3]int{1, 2, 3} for version 1.2.3) DriverVersion [3]int // Camera tells if the device is a camera. If false, then this is some other // kind of capture device, e.g. an analog TV tuner. Camera bool }
A DeviceInfo provides information about a capture device.
func FindDevices ¶
func FindDevices() []DeviceInfo
FindDevices returns the DeviceInfo for every capture device found in the system. The paths are always returned in absolute form.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
demos
|
|
streamcam
Command streamcam streams MJPEG from a V4L device over HTTP.
|
Command streamcam streams MJPEG from a V4L device over HTTP. |
viewcam
Command viewcam displays the video captured from a V4L device in a GTK-based GUI.
|
Command viewcam displays the video captured from a V4L device in a GTK-based GUI. |
fmt
|
|
mjpeg
Package mjpeg just defines the FourCC of the MJPEG format.
|
Package mjpeg just defines the FourCC of the MJPEG format. |
yuyv
Package yuyv provides support for the YUYV format.
|
Package yuyv provides support for the YUYV format. |