Documentation
¶
Overview ¶
Package videosource provides a set of tools for working with video sources using gocv.
Index ¶
- Constants
- func CorrectRectangle(i Image, rect image.Rectangle) (result image.Rectangle)
- func GetBaseFilename(t time.Time, saveDirectory string, name string, title string, ...) string
- func GetImageFilename(t time.Time, saveDirectory string, name string, title string, ...) string
- func GetVideoFilename(t time.Time, saveDirectory string, name string, fileType string, portable bool) (filename string)
- func RectAddHeight(i Image, rect image.Rectangle, height int) (result image.Rectangle)
- func RectAddWidth(i Image, rect image.Rectangle, width int) (result image.Rectangle)
- func RectOverlap(rect1 image.Rectangle, rect2 image.Rectangle) (percentage1 int, percentage2 int)
- func RectPadded(i Image, rect image.Rectangle, paddingPercent int) (result image.Rectangle)
- func RectRect(i Image, rect image.Rectangle) (result image.Rectangle)
- func RectRelative(i Image, child image.Rectangle, parent image.Rectangle) (result image.Rectangle)
- func RectScale(i Image, rect image.Rectangle, scale float64) (result image.Rectangle)
- func RectSquare(i Image, rect image.Rectangle) (result image.Rectangle)
- func SaveImage(img Image, t time.Time, saveDirectory string, jpegQuality int, name string, ...) (savePath string)
- func SavePreview(img Image, t time.Time, saveDirectory string, name string, title string, ...) (savePath string)
- type BaseVideo
- type Color
- type ColorThickness
- type ConnectionStatus
- type FaceInfo
- type FileSource
- type FrameStats
- type FrameStatsCombo
- type IPCamSource
- type Image
- func (i *Image) ChangeQuality(percent int) Image
- func (i *Image) Cleanup()
- func (i *Image) Clone() *Image
- func (i *Image) CreatedTime() time.Time
- func (i *Image) EncodedQuality(percent int) []byte
- func (i *Image) GetRegion(rect image.Rectangle) (region Image)
- func (i *Image) Height() int
- func (i *Image) IsFilled() bool
- func (i *Image) Ref() *Image
- func (i *Image) ScaleToWidth(width int) Image
- func (i *Image) Width() int
- type ImageByCreatedTime
- type MotionInfo
- type ObjectInfo
- type ProcessedImage
- func (p *ProcessedImage) Cleanup()
- func (p *ProcessedImage) Clone() *ProcessedImage
- func (p *ProcessedImage) CreatedTime() time.Time
- func (p ProcessedImage) Face(index int) *Image
- func (p *ProcessedImage) HasFace() bool
- func (p *ProcessedImage) HasMotion() bool
- func (p *ProcessedImage) HasObject() bool
- func (p *ProcessedImage) HighlightedAll() *Image
- func (p *ProcessedImage) HighlightedFace() *Image
- func (p *ProcessedImage) HighlightedMotion() *Image
- func (p *ProcessedImage) HighlightedObject() *Image
- func (p ProcessedImage) Motion(index int) *Image
- func (p ProcessedImage) Object(index int) *Image
- func (p *ProcessedImage) Ref() *ProcessedImage
- type ProcessedImageByCreatedTime
- type ProcessedImageByFaceLen
- type ProcessedImageByFacePercent
- type ProcessedImageByObjLen
- type ProcessedImageByObjPercent
- type SourceType
- type VideoReader
- func (v *VideoReader) GetConnectionStatus() ConnectionStatus
- func (v *VideoReader) GetFrameStatsOutput() (result *FrameStats)
- func (v *VideoReader) GetFrameStatsSource() (result *FrameStats)
- func (v *VideoReader) GetOutputStatsSub() (result *pubsubmutex.Subscriber[*FrameStats])
- func (v *VideoReader) GetSourceStatsSub() (result *pubsubmutex.Subscriber[*FrameStats])
- func (v *VideoReader) GetSourceType() SourceType
- func (v *VideoReader) GetStatsOutput(timeoutMs int) (result *FrameStats)
- func (v *VideoReader) GetStatsSource(timeoutMs int) (result *FrameStats)
- func (v *VideoReader) SetQuality(percent int)
- func (v *VideoReader) SetSpeed(speed float64)
- func (v *VideoReader) Start() <-chan Image
- func (v *VideoReader) Stop()
- func (v *VideoReader) Wait()
- type VideoSource
- type VideoStats
- func (v *VideoStats) AddAccepted()
- func (v *VideoStats) AddDropped()
- func (v *VideoStats) Close()
- func (v *VideoStats) GetFrameStats() *FrameStats
- func (v *VideoStats) GetStats(timeoutMs int) (result *FrameStats)
- func (v *VideoStats) GetStatsSub() (result *pubsubmutex.Subscriber[*FrameStats])
- func (v *VideoStats) Start()
- type VideoWriter
- func (v *VideoWriter) Close()
- func (v *VideoWriter) GetFrameStats() (result *FrameStats)
- func (v *VideoWriter) GetStats(timeoutMs int) (result *FrameStats)
- func (v *VideoWriter) GetStatsSub() (result *pubsubmutex.Subscriber[*FrameStats])
- func (v *VideoWriter) IsDone() bool
- func (v *VideoWriter) Send(img ProcessedImage)
- func (v *VideoWriter) Start()
- func (v *VideoWriter) Trigger()
- func (v *VideoWriter) Wait()
Constants ¶
const ( ActivityImage = 0 ActivityMotion = 1 ActivityObject = 2 ActivityFace = 3 )
VideoWriter constants
Variables ¶
This section is empty.
Functions ¶
func CorrectRectangle ¶
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 ¶
RectAddHeight will add height to the rect as evenly as possible
func RectAddWidth ¶
RectAddWidth will add width to the rect as evenly as possible
func RectOverlap ¶
RectOverlap returns the rectangle's percentage overlapped by the other
func RectPadded ¶
RectPadded returns a padded rectangle
func RectRelative ¶
RectRelative returns a relative rectangle given child and parent rectangles
func RectSquare ¶
RectSquare will return a square that fits within the Image i
Types ¶
type BaseVideo ¶
type BaseVideo struct {
// contains filtered or unexported fields
}
BaseVideo contains common video source info
func NewBaseVideo ¶
func NewBaseVideo(name string, sourceType SourceType) *BaseVideo
NewBaseVideo creates a new BaseVideo
func (*BaseVideo) GetConnectionStatus ¶ added in v1.18.0
func (b *BaseVideo) GetConnectionStatus() (status ConnectionStatus)
GetConnectionStatus implements interface
func (*BaseVideo) GetSourceType ¶ added in v1.18.0
func (b *BaseVideo) GetSourceType() (sourceType SourceType)
GetSourceType implements interface
func (*BaseVideo) Initialize ¶
Initialize implements interface
type ColorThickness ¶
func NewColorThickness ¶
func NewColorThickness(color string, thickness int) *ColorThickness
type ConnectionStatus ¶ added in v1.18.0
type ConnectionStatus int
ConnectionStatus defines the state of the connection
const ( Disconnected ConnectionStatus = iota Connecting Connected )
type FaceInfo ¶
type FaceInfo struct {
Rect image.Rectangle
Percentage int
HighlightInfo ColorThickness
}
FaceInfo contains the face information
func NewFaceInfo ¶
func NewFaceInfo(rect image.Rectangle, colorThickness ColorThickness) *FaceInfo
NewFaceInfo creates a new FaceInfo
type FileSource ¶
type FileSource struct {
BaseVideo
// contains filtered or unexported fields
}
FileSource is a file source
func NewFileSource ¶
func NewFileSource(name string, filename string) *FileSource
NewFileSource creates a new FileSource
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 FrameStats ¶
type FrameStats struct {
AcceptedTotal int
AcceptedPerSecond int
DroppedTotal int
DroppedPerSecond int
}
func (FrameStats) String ¶ added in v1.5.0
func (f FrameStats) String() string
type FrameStatsCombo ¶
type FrameStatsCombo struct {
In FrameStats
Out FrameStats
}
type IPCamSource ¶
type IPCamSource struct {
BaseVideo
// contains filtered or unexported fields
}
IPCamSource is a ipcam source
func NewIPCamSource ¶
func NewIPCamSource(name string, url string) *IPCamSource
NewIPCamSource creates a new IPCamSource
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
func (*IPCamSource) SetCaptureTimeoutMs ¶ added in v1.18.0
func (i *IPCamSource) SetCaptureTimeoutMs(captureTimeoutMs int)
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image contains an image
func (*Image) ChangeQuality ¶
ChangeQuality will return a copy of the Image with the quality set to percent
func (*Image) CreatedTime ¶
func (*Image) EncodedQuality ¶
EncodedQuality returns a JPEG byte array with the given quality percentage
func (*Image) ScaleToWidth ¶
ScaleToWidth will return a copy of the Image to scale given the width
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 MotionInfo ¶
type MotionInfo struct {
Rect image.Rectangle
HighlightInfo ColorThickness
}
MotionInfo contains the motion information
func NewMotionInfo ¶
func NewMotionInfo(rect image.Rectangle, colorThickness ColorThickness) *MotionInfo
NewMotionInfo creates a new MotionInfo
func (*MotionInfo) Ref ¶
func (m *MotionInfo) Ref() *MotionInfo
Ref will create a copy and reference the underlying SharedMat
type ObjectInfo ¶
type ObjectInfo struct {
Rect image.Rectangle
Description string
Percentage int
HighlightInfo ColorThickness
}
ObjectInfo contains the object information
func NewObjectInfo ¶
func NewObjectInfo(rect image.Rectangle, colorThickness ColorThickness) *ObjectInfo
NewObjectInfo creates a new ObjectInfo
func (*ObjectInfo) Ref ¶
func (o *ObjectInfo) Ref() *ObjectInfo
Ref will create a copy and reference the underlying SharedMat
type ProcessedImage ¶
type ProcessedImage struct {
Original Image
Motions []MotionInfo
Objects []ObjectInfo
Faces []FaceInfo
}
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) CreatedTime ¶ added in v1.9.0
func (p *ProcessedImage) CreatedTime() time.Time
func (ProcessedImage) Face ¶
func (p ProcessedImage) Face(index int) *Image
func (*ProcessedImage) HasFace ¶
func (p *ProcessedImage) HasFace() bool
func (*ProcessedImage) HasMotion ¶
func (p *ProcessedImage) HasMotion() bool
func (*ProcessedImage) HasObject ¶
func (p *ProcessedImage) HasObject() bool
func (*ProcessedImage) HighlightedAll ¶
func (p *ProcessedImage) HighlightedAll() *Image
func (*ProcessedImage) HighlightedFace ¶
func (p *ProcessedImage) HighlightedFace() *Image
func (*ProcessedImage) HighlightedMotion ¶
func (p *ProcessedImage) HighlightedMotion() *Image
func (*ProcessedImage) HighlightedObject ¶
func (p *ProcessedImage) HighlightedObject() *Image
func (ProcessedImage) Motion ¶
func (p ProcessedImage) Motion(index int) *Image
func (ProcessedImage) Object ¶
func (p ProcessedImage) Object(index int) *Image
func (*ProcessedImage) Ref ¶
func (p *ProcessedImage) Ref() *ProcessedImage
Ref will create a copy and reference the underlying SharedMat
type ProcessedImageByCreatedTime ¶
type ProcessedImageByCreatedTime []ProcessedImage
ProcessedImageByCreatedTime sorting ascending order
func (ProcessedImageByCreatedTime) Len ¶
func (b ProcessedImageByCreatedTime) Len() int
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 (b ProcessedImageByFacePercent) Len() int
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 (b ProcessedImageByObjPercent) Len() int
func (ProcessedImageByObjPercent) Less ¶
func (b ProcessedImageByObjPercent) Less(i, j int) bool
func (ProcessedImageByObjPercent) Swap ¶
func (b ProcessedImageByObjPercent) Swap(i, j int)
type SourceType ¶ added in v1.18.0
type SourceType int
SourceType defines the type of the source
const ( UnknownType SourceType = iota FileSourceType IPCamSourceType )
type VideoReader ¶
type VideoReader struct {
MaxSourceFps int
MaxOutputFps int
Quality int
Speed float64
DropTimeoutMs 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) GetConnectionStatus ¶ added in v1.18.0
func (v *VideoReader) GetConnectionStatus() ConnectionStatus
func (*VideoReader) GetFrameStatsOutput ¶ added in v1.5.0
func (v *VideoReader) GetFrameStatsOutput() (result *FrameStats)
GetFrameStatsOutput returns the FrameStats directly
func (*VideoReader) GetFrameStatsSource ¶ added in v1.5.0
func (v *VideoReader) GetFrameStatsSource() (result *FrameStats)
GetFrameStatsSource returns the FrameStats directly
func (*VideoReader) GetOutputStatsSub ¶ added in v1.1.1
func (v *VideoReader) GetOutputStatsSub() (result *pubsubmutex.Subscriber[*FrameStats])
GetOutputStatsSub returns the subscriber
func (*VideoReader) GetSourceStatsSub ¶ added in v1.1.1
func (v *VideoReader) GetSourceStatsSub() (result *pubsubmutex.Subscriber[*FrameStats])
GetSourceStatsSub returns the subscriber
func (*VideoReader) GetSourceType ¶ added in v1.18.0
func (v *VideoReader) GetSourceType() SourceType
func (*VideoReader) GetStatsOutput ¶
func (v *VideoReader) GetStatsOutput(timeoutMs int) (result *FrameStats)
GetStatsOutput returns the FrameStats using pubsub
func (*VideoReader) GetStatsSource ¶
func (v *VideoReader) GetStatsSource(timeoutMs int) (result *FrameStats)
GetStatsSource returns the FrameStats using pubsub
func (*VideoReader) SetQuality ¶
func (v *VideoReader) SetQuality(percent int)
SetQuality sets the Image quality
func (*VideoReader) SetSpeed ¶ added in v1.16.0
func (v *VideoReader) SetSpeed(speed float64)
SetSpeed sets the speed of playback. Must be set prior to start.
type VideoSource ¶
type VideoSource interface {
GetName() string
Initialize() (ok bool)
Cleanup()
ReadImage() (done bool, image Image)
GetConnectionStatus() (status ConnectionStatus)
GetSourceType() (sourceType SourceType)
}
VideoSource interface for setting up and reading images
type VideoStats ¶
type VideoStats struct {
// contains filtered or unexported fields
}
VideoStats contains video statistics
func (*VideoStats) AddAccepted ¶
func (v *VideoStats) AddAccepted()
AddAccepted adds an accepted image
func (*VideoStats) Close ¶ added in v1.5.0
func (v *VideoStats) Close()
func (*VideoStats) GetFrameStats ¶ added in v1.5.0
func (v *VideoStats) GetFrameStats() *FrameStats
GetFrameStats returns the FrameStats directly
func (*VideoStats) GetStats ¶
func (v *VideoStats) GetStats(timeoutMs int) (result *FrameStats)
GetStats returns the FrameStats using pubsub
func (*VideoStats) GetStatsSub ¶ added in v1.5.0
func (v *VideoStats) GetStatsSub() (result *pubsubmutex.Subscriber[*FrameStats])
GetStatsSub returns the subscriber
func (*VideoStats) Start ¶ added in v1.5.0
func (v *VideoStats) Start()
type VideoWriter ¶
type VideoWriter struct {
PortableWidth int
// contains filtered or unexported fields
}
VideoWriter writes Images
func NewVideoWriter ¶
func NewVideoWriter(name string, saveDirectory string, codec string, fileType string, bufferSeconds int, maxPreSec int, timeoutSec int, maxSec int, outFps int, savePreview bool, savePortable bool, saveFull 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) GetFrameStats ¶ added in v1.5.0
func (v *VideoWriter) GetFrameStats() (result *FrameStats)
GetFrameStats returns the FrameStats directly
func (*VideoWriter) GetStats ¶
func (v *VideoWriter) GetStats(timeoutMs int) (result *FrameStats)
GetStats returns the FrameStats using pubsub
func (*VideoWriter) GetStatsSub ¶ added in v1.5.0
func (v *VideoWriter) GetStatsSub() (result *pubsubmutex.Subscriber[*FrameStats])
GetStatsSub returns the subscriber
func (*VideoWriter) IsDone ¶ added in v1.9.0
func (v *VideoWriter) IsDone() bool