Documentation
¶
Overview ¶
Package livecapture provides a way to capture images from a live camera. It is a port of the live-capture script in cmd/.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var SupportedCameraFormats = []CameraFormat{ FormatYUYV422, FormatMJPG, }
SupportedCameraFormats is the list of supported camera formats.
var SupportedImageFormats = []ImageFormat{ FormatBMP, FormatJPG, FormatPNG, }
SupportedImageFormats is the list of supported image formats.
Functions ¶
func IsSupported ¶
IsSupported returns whether the given string is a supported camera format.
Types ¶
type Camera ¶
type Camera struct {
// Path is the path to the camera device.
Path string
// Size is the size of the camera image.
Size image.Point
// Format is the format of the camera image.
Format CameraFormat
// FrameRate is the frame rate of the camera.
FrameRate int
}
Camera describes the options for a camera.
type CameraFormat ¶
type CameraFormat string
CameraFormat describes the format of a camera image.
const ( FormatYUYV422 CameraFormat = "yuyv422" FormatMJPG CameraFormat = "mjpg" )
type Capture ¶
type Capture struct {
// contains filtered or unexported fields
}
Capture describes a live-captured camera.
func NewCapture ¶
func NewCapture(opts CaptureOpts) (*Capture, error)
NewCapture creates a new stopped camera.
func (*Capture) Snapshot ¶
Snapshot takes a snapshot from the camera and returns it. It is safe to call this method concurrently.
func (*Capture) SnapshotToFile ¶
SnapshotToFile takes a snapshot from the camera and writes it to the given file.
type CaptureOpts ¶
type CaptureOpts struct {
// Camera is the camera to capture from.
Camera
// ImagePath is the path to the image captured by the camera.
// It will be continuously updated as the camera captures images.
// It is recommended to use a BMP file in /run/user/1000 so that there's
// minimum overhead in writing and reading the image.
ImagePath string
// FilterArgs are the arguments to pass to FFmpeg to filter the camera
// image.
FilterArgs []string
// Image2Args are the arguments to pass to FFmpeg to add arguments to the
// written image.
Image2Args []string
}
CaptureOpts describes the options for a live-captured camera.
type ImageFormat ¶
type ImageFormat string
ImageFormat describes the format of an image.
const ( FormatBMP ImageFormat = "bmp" FormatJPG ImageFormat = "jpg" FormatPNG ImageFormat = "png" )