mechcamera

package
v0.0.0-...-a3e6692 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: CC0-1.0 Imports: 13 Imported by: 0

Documentation

Overview

Package mechcamera distributes available camera names along with shutterbug-to-camera associations to clients and receives camera association requests from clients.

Index

Constants

View Source
const (
	// Uni implies no stitching. A single camera occupies the whole view.
	Uni = Stitching(iota)

	// Bi is two overlapping cameras. Both cameras occupy the whole view.
	Bi

	// BiPartial is a partial overlapping of one camera by another. The rear
	// camera occupies the whole view. The closest occupies a smaller rectangle.
	BiPartial

	// Tri is three overlapping cameras. All three cameras occupy the whole
	// view.
	Tri

	// TriPartial is a partial overlapping of one camera by two others. The rear
	// camera occupies the whole view. The two closer cameras occupy mutually
	// exclusive smaller rectangles.
	TriPartial

	// Quad is four overlapping cameras. All four cameras occupy the whole view.
	Quad

	// QuadPartial is a partial overlapping of one camera by three others. The
	// rear camera occupies the whole view. The three closer cameras occupy
	// mutually exclusive smaller rectangles.
	QuadPartial
)

Variables

This section is empty.

Functions

func NewCameraHandleFunc

func NewCameraHandleFunc(
	reg Registry,
	shutterbugs mechshutterbug.Containser,
) http.HandlerFunc

NewCameraHandleFunc creates a HTTP request handler which allows clients to interface with the camera registry.

The handler upgrades the HTTP request to a websocket. The websocket's first ever incoming message should be a valid shutterbug.

Types

type Associations

type Associations struct {
	Cameras   []string // In farthest to closest stacking order.
	Stitching Stitching
}

func (Associations) IsPartial

func (a Associations) IsPartial(camera string) bool

IsPartial reports whether the given camera has a partial camera status in this association.

func (Associations) Key

func (a Associations) Key() string

Key can be used as a unique key in, for example, a cache of stitched images for this exact combination of cameras and stitching.

func (Associations) StitchWithCPU

func (a Associations) StitchWithCPU(
	s *wiregl.CPUStitcher, vp ...wiregl.Pixels,
) wiregl.PixelData

StitchWithCPU the given images where each image corresponds to the view from the camera with the same index in the associations.

In the case of a single camera just return the camera's pixel data unmodified.

type AssociationsSchema

type AssociationsSchema struct {
	Cameras   []string `json:"cameras"`
	Stitching string   `json:"stitching"`
}

type RegAsc

type RegAsc struct {
	Associated []string `json:"associated"`
	Registered []string `json:"registered"`
	Stitching  string   `json:"stitching"`
}

type Registry

type Registry struct {
	Logger *log.Logger
	// contains filtered or unexported fields
}

Registry is a register of currently available cameras by name and shutterbug to camera associations.

When the registered cameras or associated cameras state changes the new state is sent out to clients connected to the registry.

It also receives the new shutterbug/camera association requests from the connected clients and stores them in a queue.

func NewRegistry

func NewRegistry(l *log.Logger) Registry

NewRegistry constructs a new Registry.

func (Registry) AllAssociatedCameras

func (r Registry) AllAssociatedCameras() []string

AllAssociatedCameras to any shutterbug.

func (Registry) AllAssociatedShutterbugs

func (r Registry) AllAssociatedShutterbugs() []string

AllAssociatedShutterbugs to any camera.

func (Registry) Associate

func (r Registry) Associate(a ShutterbugAssociations) bool

Associate a shutterbug with the given cameras overwriting any existing associations.

Return false and do nothing if any of the given cameras are not registered.

func (Registry) Associated

func (r Registry) Associated(shutterbug string) []string

Associated cameras to the shutterbug.

func (Registry) AssociatedShutterbugs

func (r Registry) AssociatedShutterbugs(camera string) []string

AssociatedShutterbugs is the shutterbugs associated with the camera.

func (Registry) Associations

func (r Registry) Associations(shutterbug string) (Associations, bool)

Associations of the shutterbug if the shutterbug has any. Return false if there are no associations.

func (Registry) Contains

func (r Registry) Contains(camera string) bool

Contains is true if the given camera is registered.

func (Registry) Deregister

func (r Registry) Deregister(cameras ...string)

Deregister the cameras with the given names and disassociate them from any shutterbugs.

func (Registry) Disassociate

func (r Registry) Disassociate(camera string)

Disassociate the given camera from any associated shutterbugs.

func (Registry) DisassociateShutterbug

func (r Registry) DisassociateShutterbug(shutterbug string)

DisassociateShutterbug clears the given shutterbug's associations.

func (Registry) IsPartial

func (r Registry) IsPartial(camera string) bool

IsPartial is true if the given camera is associated with any shutterbug in a partial capacity, that is, it is placed non first in any shutterbug's list of associated cameras and the association uses a partial stitching.

func (Registry) Pop

Pop an association request from the front of the association requests queue.

func (Registry) Register

func (r Registry) Register(cameras ...string)

Register the cameras with the given names.

func (Registry) Registered

func (r Registry) Registered() []string

Registered cameras.

func (Registry) RemoveShutterbug

func (r Registry) RemoveShutterbug(shutterbug string)

RemoveShutterbug from the registry disassociating it from any cameras and closing the associated HTTP request handlers using that shutterbug.

func (Registry) Watch

func (r Registry) Watch() <-chan struct{}

Watch the association request queue.

The returned watch channel is closed already if the queue is not empty, else it is closed when the next association request is added.

type ShutterbugAssociations

type ShutterbugAssociations struct {
	Cameras    []string // In farthest to closest stacking order.
	Shutterbug string
	Stitching  Stitching
}

ShutterbugAssociations between a shutterbug and some cameras.

type Stitching

type Stitching uint

func StitchingFromString

func StitchingFromString(s string) (Stitching, error)

func (Stitching) ExpectedCams

func (s Stitching) ExpectedCams() int

func (Stitching) String

func (s Stitching) String() string

Jump to

Keyboard shortcuts

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