video

package
v0.0.0-...-a41b70d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(frame *image.RGBA, wg *sync.WaitGroup)

VideoHandler is a handler for video streams. A handler should do its work and return as fast as possible. If a handler needs to modify the given frame in any way, it should first make a copy of it as the given frame is shared by all handlers (concurrently).

Even if you are not modifying the given frame but you are doing some expensive image processing, it might be better to copy it internally and return ASAP, deferring the processing to a separate goroutine (you might need to queue frames).

After doing its work, a VideoHandler must call wg.Done() before returning.

type Video

type Video struct {
	// contains filtered or unexported fields
}

Video handles starting a robot's video stream, receiving and decoding the data from it and sending to all registered VideoHandlers and stopping the video stream. The decoding relies on GoCV (https://gocv.io).

func New

func New(control *control.Control) (*Video, error)

New creates a new Video instance. The control parameter is used to start stop the video stream and setup the video connection address.

func (*Video) StartStream

func (v *Video) StartStream(videoHandler Handler) (int, error)

StartStream starts the video stream (if it has not started yet) and starts sending video frames to the given videoHandler. It returns a positive int token (used to stop the stream when needed) and a nil error on success and a non-nil error on failure.

func (*Video) StopStream

func (v *Video) StopStream(token int) error

StopStream stops sending frames to the VideoHandler associated with the given token and remove it from the list of VideoHandlers. If it is the last VideoHandler in the list, the robot's video stream is stopped.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL