import "mind/core/framework/drivers/media"

Package media provides an API for interfacing with media devices eg. camera.


const (
    FrameWidth  = 1280
    FrameHeight = 720

func Available

func Available() bool

Available returns whether driver is available or not.

func Close

func Close() (err error)

Close closes media driver.

func SnapshotJPEG

func SnapshotJPEG(location string, quality int) (err error)

SnapshotJPEG writes a camera snapshot to location. Compression used is JPEG 4:2:0 baseline format with the given quality. Quality range is 1 to 100 where 100 is highest quality. Location must be an absolute path.

func SnapshotRGBA

func SnapshotRGBA() *image.RGBA

SnapshotRGBA returns a RGBA image from camera with size FrameWidth x FrameHeight. This function is slower than SnapshotYCbCr since it redraws the whole image after snapshot to convert it from YCbCr to RGBA.

func SnapshotYCbCr

func SnapshotYCbCr() *image.YCbCr

SnapshotYCbCr returns a 4:2:0 Y'CbCr 8-bit image from camera with size FrameWidth x FrameHeight. See for further infomation.

func Start

func Start() (err error)

Start starts media driver.

func StartVideoRecording

func StartVideoRecording(location string) (err error)

StartVideoRecording starts recording an MP4 video to location. Compression format is H264 with a bitrate of 5000 Kbps and frame size of video is 1280x720. Location must be an absolute path. StopVideoRecording must be called after recording is finished, otherwise the video file might get corrupted.

func StopVideoRecording

func StopVideoRecording(location string) (err error)

StopVideoRecording stops the video recording process. Location must be an absolute path.