videosource

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActivityImage  = 0
	ActivityMotion = 1
	ActivityObject = 2
	ActivityFace   = 3
)

VideoWriter constants

Variables

This section is empty.

Functions

func CorrectRectangle

func CorrectRectangle(i Image, rect image.Rectangle) (result image.Rectangle)

CorrectRectangle will fix a rectangle to fit within the Image i

func GetBaseFilename

func GetBaseFilename(t time.Time, saveDirectory string, name string, title string, percentage string) string

GetBaseFilename will return a formatted base filename with current date time

func GetImageFilename

func GetImageFilename(t time.Time, saveDirectory string, name string, title string, percentage string) string

GetImageFilename will return an image filename

func GetVideoFilename

func GetVideoFilename(t time.Time, saveDirectory string, name string, fileType string, portable bool) (filename string)

GetVideoFilename will return a video filename

func RectAddHeight

func RectAddHeight(i Image, rect image.Rectangle, height int) (result image.Rectangle)

RectAddHeight will add height to the rect as evenly as possible

func RectAddWidth

func RectAddWidth(i Image, rect image.Rectangle, width int) (result image.Rectangle)

RectAddWidth will add width to the rect as evenly as possible

func RectOverlap

func RectOverlap(rect1 image.Rectangle, rect2 image.Rectangle) (percentage1 int, percentage2 int)

RectOverlap returns the rectangle's percentage overlapped by the other

func RectPadded

func RectPadded(i Image, rect image.Rectangle, paddingPercent int) (result image.Rectangle)

RectPadded returns a padded rectangle

func RectRect

func RectRect(i Image, rect image.Rectangle) (result image.Rectangle)

RectRect will return a rectangle that fits within the Image i

func RectRelative

func RectRelative(i Image, child image.Rectangle, parent image.Rectangle) (result image.Rectangle)

RectRelative returns a relative rectangle given child and parent rectangles

func RectSquare

func RectSquare(i Image, rect image.Rectangle) (result image.Rectangle)

RectSquare will return a square that fits within the Image i

func SaveImage

func SaveImage(img Image, t time.Time, saveDirectory string, jpegQuality int, name string, title string, percentage string) (savePath string)

SaveImage will save an Image

func SavePreview

func SavePreview(img Image, t time.Time, saveDirectory string, name string, title string, percentage string) (savePath string)

SavePreview will save a smaller Image

Types

type BaseVideo

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

BaseVideo contains common video source info

func NewBaseVideo

func NewBaseVideo(name string) *BaseVideo

NewBaseVideo creates a new BaseVideo

func (*BaseVideo) Cleanup

func (b *BaseVideo) Cleanup()

Cleanup implements interface

func (*BaseVideo) GetName

func (b *BaseVideo) GetName() string

GetName implements interface

func (*BaseVideo) Initialize

func (b *BaseVideo) Initialize() (ok bool)

Initialize implements interface

func (*BaseVideo) ReadImage

func (b *BaseVideo) ReadImage() (done bool, image Image)

ReadImage implements interface

type Color

type Color int

Color represents a color

const (
	Blue Color = iota
	Purple
	Green
	Red
	White
)

Color Constants

func StringToColor

func StringToColor(name string) Color

StringToColor returns a Color

func (Color) GetRGBA

func (c Color) GetRGBA() color.RGBA

GetRGBA returns the color rgba

func (Color) String

func (c Color) String() string

type FaceInfo

type FaceInfo struct {
	Face       Image
	Percentage int
}

FaceInfo contains the face information

func NewFaceInfo

func NewFaceInfo(img Image) *FaceInfo

NewFaceInfo creates a new FaceInfo

func (*FaceInfo) Cleanup

func (f *FaceInfo) Cleanup()

Cleanup will cleanup the FaceInfo

func (*FaceInfo) Clone

func (f *FaceInfo) Clone() *FaceInfo

Clone will clone the FaceInfo

func (*FaceInfo) Ref

func (f *FaceInfo) Ref() *FaceInfo

Ref will reference the FaceInfo and underlying SharedMat

type FileSource

type FileSource struct {
	BaseVideo
	// contains filtered or unexported fields
}

FileSource is a file source

func (*FileSource) Cleanup

func (f *FileSource) Cleanup()

Cleanup implements interface

func (*FileSource) Initialize

func (f *FileSource) Initialize() (ok bool)

Initialize implements interface

func (*FileSource) ReadImage

func (f *FileSource) ReadImage() (done bool, image Image)

ReadImage implements interface

type IPCamSource

type IPCamSource struct {
	BaseVideo
	// contains filtered or unexported fields
}

IPCamSource is a ipcam source

func (*IPCamSource) Cleanup

func (i *IPCamSource) Cleanup()

Cleanup implements interface

func (*IPCamSource) Initialize

func (i *IPCamSource) Initialize() (ok bool)

Initialize implements interface

func (*IPCamSource) ReadImage

func (i *IPCamSource) ReadImage() (done bool, image Image)

ReadImage implements interface

type Image

type Image struct {
	SharedMat   *sharedmat.SharedMat
	CreatedTime time.Time
}

Image contains an image

func NewImage

func NewImage(mat gocv.Mat) *Image

NewImage creates a new Image

func (*Image) ChangeQuality

func (i *Image) ChangeQuality(percent int)

ChangeQuality will change the Image quality to percent param

func (*Image) Cleanup

func (i *Image) Cleanup() (filled bool, closed bool)

Cleanup will cleanup the Image

func (*Image) Clone

func (i *Image) Clone() *Image

Clone will clone the Image

func (*Image) EncodedQuality

func (i *Image) EncodedQuality(percent int) []byte

EncodedQuality returns a JPEG byte array with the given quality percentage

func (*Image) GetRegion

func (i *Image) GetRegion(rect image.Rectangle) (region Image)

GetRegion will return a new Image per rectangle parameter

func (*Image) Height

func (i *Image) Height() int

Height returns the Image height or -1

func (*Image) IsFilled added in v1.6.0

func (i *Image) IsFilled() bool

IsFilled checks the underlying image not empty

func (*Image) Ref

func (i *Image) Ref() *Image

Ref will reference the Image and underlying SharedMat

func (*Image) ScaleToWidth

func (i *Image) ScaleToWidth(width int) Image

ScaleToWidth will return a copy of the Image to scale given the width

func (*Image) Width

func (i *Image) Width() int

Width returns the Image width or -1

type ImageByCreatedTime

type ImageByCreatedTime []Image

ImageByCreatedTime sorting ascending order

func (ImageByCreatedTime) Len

func (b ImageByCreatedTime) Len() int

func (ImageByCreatedTime) Less

func (b ImageByCreatedTime) Less(i, j int) bool

func (ImageByCreatedTime) Swap

func (b ImageByCreatedTime) Swap(i, j int)

type ImageList

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

ImageList is a list of Images

func NewImageList

func NewImageList() *ImageList

NewImageList creates a new ImageList

func (*ImageList) Len

func (i *ImageList) Len() int

Len returns the length

func (*ImageList) Pop

func (i *ImageList) Pop() (popped Image)

Pop will pop off the list

func (*ImageList) Push

func (i *ImageList) Push(img Image)

Push will push onto the list

func (*ImageList) Set

func (i *ImageList) Set(imgs []Image)

Set sets the list

type ObjectInfo

type ObjectInfo struct {
	Object      Image
	Description string
	Percentage  int
}

ObjectInfo contains the object information

func NewObjectInfo

func NewObjectInfo(img Image) *ObjectInfo

NewObjectInfo creates a new ObjectInfo

func (*ObjectInfo) Cleanup

func (o *ObjectInfo) Cleanup()

Cleanup will cleanup the ObjectInfo

func (*ObjectInfo) Clone

func (o *ObjectInfo) Clone() *ObjectInfo

Clone will clone the ObjectInfo

func (*ObjectInfo) Ref

func (o *ObjectInfo) Ref() *ObjectInfo

Ref will reference the ObjectInfo and underlying SharedMat

type ProcessedImage

type ProcessedImage struct {
	Original          Image
	HighlightedMotion Image
	HighlightedObject Image
	HighlightedFace   Image
	Motions           []Image
	MotionRects       []image.Rectangle
	Objects           []ObjectInfo
	ObjectRects       []image.Rectangle
	Faces             []FaceInfo
	FaceRects         []image.Rectangle
}

ProcessedImage is the result of running through the processes

func NewProcessedImage

func NewProcessedImage(original Image) *ProcessedImage

NewProcessedImage creates a new ProcessedImage

func (*ProcessedImage) Cleanup

func (p *ProcessedImage) Cleanup()

Cleanup will cleanup the ProcessedImage

func (*ProcessedImage) Clone

func (p *ProcessedImage) Clone() *ProcessedImage

Clone will clone the ProcessedImage

func (*ProcessedImage) Ref

func (p *ProcessedImage) Ref() *ProcessedImage

Ref will reference the ProcessedImage and underlying SharedMats

type ProcessedImageByCreatedTime

type ProcessedImageByCreatedTime []ProcessedImage

ProcessedImageByCreatedTime sorting ascending order

func (ProcessedImageByCreatedTime) Len

func (ProcessedImageByCreatedTime) Less

func (b ProcessedImageByCreatedTime) Less(i, j int) bool

func (ProcessedImageByCreatedTime) Swap

func (b ProcessedImageByCreatedTime) Swap(i, j int)

type ProcessedImageByFaceLen

type ProcessedImageByFaceLen []ProcessedImage

ProcessedImageByFaceLen sorting descending order

func (ProcessedImageByFaceLen) Len

func (b ProcessedImageByFaceLen) Len() int

func (ProcessedImageByFaceLen) Less

func (b ProcessedImageByFaceLen) Less(i, j int) bool

func (ProcessedImageByFaceLen) Swap

func (b ProcessedImageByFaceLen) Swap(i, j int)

type ProcessedImageByFacePercent

type ProcessedImageByFacePercent []ProcessedImage

ProcessedImageByFacePercent sorting descending order

func (ProcessedImageByFacePercent) Len

func (ProcessedImageByFacePercent) Less

func (b ProcessedImageByFacePercent) Less(i, j int) bool

func (ProcessedImageByFacePercent) Swap

func (b ProcessedImageByFacePercent) Swap(i, j int)

type ProcessedImageByObjLen

type ProcessedImageByObjLen []ProcessedImage

ProcessedImageByObjLen sorting descending order

func (ProcessedImageByObjLen) Len

func (b ProcessedImageByObjLen) Len() int

func (ProcessedImageByObjLen) Less

func (b ProcessedImageByObjLen) Less(i, j int) bool

func (ProcessedImageByObjLen) Swap

func (b ProcessedImageByObjLen) Swap(i, j int)

type ProcessedImageByObjPercent

type ProcessedImageByObjPercent []ProcessedImage

ProcessedImageByObjPercent sorting descending order

func (ProcessedImageByObjPercent) Len

func (ProcessedImageByObjPercent) Less

func (b ProcessedImageByObjPercent) Less(i, j int) bool

func (ProcessedImageByObjPercent) Swap

func (b ProcessedImageByObjPercent) Swap(i, j int)

type ProcessedImageFpsChan

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

ProcessedImageFpsChan will notify caller via ProcessedImage channel at given fps

func NewProcessedImageFpsChan

func NewProcessedImageFpsChan(outFps int) *ProcessedImageFpsChan

NewProcessedImageFpsChan creates a new ProcessedImageFpsChan

func (*ProcessedImageFpsChan) Close

func (p *ProcessedImageFpsChan) Close()

Close notified by caller that input stream is done/closed

func (*ProcessedImageFpsChan) Send

Send ProcessedImage to channel

func (*ProcessedImageFpsChan) Start

func (p *ProcessedImageFpsChan) Start() chan ProcessedImage

Start runs the channel

func (*ProcessedImageFpsChan) Wait

func (p *ProcessedImageFpsChan) Wait()

Wait until done

type RingBufferImage

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

RingBufferImage is a ring buffer for Image

func NewRingBufferImage

func NewRingBufferImage(maxLen int) *RingBufferImage

NewRingBufferImage creates a new RingBufferImage with maxLen

func (*RingBufferImage) Len

func (r *RingBufferImage) Len() int

Len returns the length of the ring

func (*RingBufferImage) Pop

func (r *RingBufferImage) Pop() (popped Image)

Pop will pop off the ring an Image. Check for valid image.

func (*RingBufferImage) PopAll

func (r *RingBufferImage) PopAll() (popped []Image)

PopAll will pop off all on the ring. Check for valid image.

func (*RingBufferImage) Push

func (r *RingBufferImage) Push(img Image) (popped Image)

Push will push onto the ring the Image and return any popped Image

func (*RingBufferImage) Ready

func (r *RingBufferImage) Ready() <-chan bool

Ready returns the internal ready chan for checking ready to pop

func (*RingBufferImage) SortByCreatedTime

func (r *RingBufferImage) SortByCreatedTime()

SortByCreatedTime sorts the ring buffer

type RingBufferProcessedImage

type RingBufferProcessedImage struct {
	IsSortByContent bool
	// contains filtered or unexported fields
}

RingBufferProcessedImage is a ring buffer for ProcessedImage

func NewRingBufferProcessedImage

func NewRingBufferProcessedImage(maxLen int) *RingBufferProcessedImage

NewRingBufferProcessedImage creates a new RingBufferProcessedImage

func (*RingBufferProcessedImage) Len

func (r *RingBufferProcessedImage) Len() int

Len returns the length of the ring

func (*RingBufferProcessedImage) Pop

func (r *RingBufferProcessedImage) Pop() (popped ProcessedImage)

Pop will pop off the ring an ProcessedImage. Check for valid image.

func (*RingBufferProcessedImage) PopAll

func (r *RingBufferProcessedImage) PopAll() (popped []ProcessedImage)

PopAll will pop off all on the ring. Check for valid image.

func (*RingBufferProcessedImage) Push

Push will push onto the ring the ProcessedImage and return any popped ProcessedImage

func (*RingBufferProcessedImage) Ready

func (r *RingBufferProcessedImage) Ready() <-chan bool

Ready returns the internal ready chan for checking ready to pop

func (*RingBufferProcessedImage) SortByContent

func (r *RingBufferProcessedImage) SortByContent()

SortByContent sorts the ring buffer

func (*RingBufferProcessedImage) SortByCreatedTime

func (r *RingBufferProcessedImage) SortByCreatedTime()

SortByCreatedTime sorts the ring buffer

type VideoReader

type VideoReader struct {
	SourceStats *VideoStats
	OutputStats *VideoStats

	MaxSourceFps int
	MaxOutputFps int
	Quality      int
	// contains filtered or unexported fields
}

VideoReader reads a VideoSource

func NewVideoReader

func NewVideoReader(videoSource VideoSource, maxSourceFps int, maxOutputFps int) *VideoReader

NewVideoReader creates a new VideoReader

func (*VideoReader) SetQuality

func (v *VideoReader) SetQuality(percent int)

SetQuality sets the Image quality

func (*VideoReader) Start

func (v *VideoReader) Start() <-chan Image

Start runs the processes

func (*VideoReader) Stop

func (v *VideoReader) Stop()

Stop will stop the processes

func (*VideoReader) Wait

func (v *VideoReader) Wait()

Wait for done

type VideoSource

type VideoSource interface {
	GetName() string
	Initialize() (ok bool)
	Cleanup()
	ReadImage() (done bool, image Image)
}

VideoSource interface for setting up and reading images

func NewFileSource

func NewFileSource(name string, filename string) VideoSource

NewFileSource creates a new FileSource

func NewIPCamSource

func NewIPCamSource(name string, url string) VideoSource

NewIPCamSource creates a new IPCamSource

type VideoStats

type VideoStats struct {
	AcceptedTotal     int
	AcceptedPerSecond int
	DroppedTotal      int
	DroppedPerSecond  int
	// contains filtered or unexported fields
}

VideoStats contains video statistics

func NewVideoStats

func NewVideoStats() *VideoStats

NewVideoStats creates a new VideoStats

func (*VideoStats) AddAccepted

func (v *VideoStats) AddAccepted()

AddAccepted adds an accepted image

func (*VideoStats) AddDropped

func (v *VideoStats) AddDropped()

AddDropped adds a dropped image

func (*VideoStats) Cleanup

func (v *VideoStats) Cleanup()

Cleanup the VideoStats

type VideoWriter

type VideoWriter struct {
	VideoStats *VideoStats

	PortableWidth int
	// contains filtered or unexported fields
}

VideoWriter writes Images

func NewVideoWriter

func NewVideoWriter(name string, saveDirectory string, codec string, fileType string,
	maxPreSec int, timeoutSec int, maxSec int, outFps int, savePreview bool, savePortable bool, activityType int) *VideoWriter

NewVideoWriter creates a new VideoWriter

func (*VideoWriter) Close

func (v *VideoWriter) Close()

Close notified by caller that input stream is done/closed

func (*VideoWriter) Send

func (v *VideoWriter) Send(img ProcessedImage)

Send Image to write

func (*VideoWriter) Start

func (v *VideoWriter) Start()

Start runs the processes

func (*VideoWriter) Trigger added in v1.9.0

func (v *VideoWriter) Trigger()

Trigger to start recording

func (*VideoWriter) Wait

func (v *VideoWriter) Wait()

Wait until done

Jump to

Keyboard shortcuts

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