mirror of https://bitbucket.org/ausocean/av.git
back to no testing
This commit is contained in:
parent
4b28558924
commit
b0dd41dcf0
|
@ -48,10 +48,9 @@ type MOGFilter struct {
|
|||
windows []*gocv.Window
|
||||
hold [][]byte
|
||||
hf int
|
||||
hfCount int
|
||||
}
|
||||
|
||||
var hfCount int = 0
|
||||
|
||||
// NewMOGFilter returns a pointer to a new MOGFilter struct.
|
||||
func NewMOGFilter(dst io.WriteCloser, area, threshold float64, history int, debug bool, hf int) *MOGFilter {
|
||||
bs := gocv.NewBackgroundSubtractorMOG2WithParams(history, threshold, false)
|
||||
|
@ -61,7 +60,7 @@ func NewMOGFilter(dst io.WriteCloser, area, threshold float64, history int, debu
|
|||
windows = []*gocv.Window{gocv.NewWindow("MOG: Bounding boxes"), gocv.NewWindow("MOG: Motion")}
|
||||
}
|
||||
hold := make([][]byte, hf-1)
|
||||
return &MOGFilter{dst, area, &bs, k, debug, windows, hold, hf}
|
||||
return &MOGFilter{dst, area, &bs, k, debug, windows, hold, hf, 0}
|
||||
}
|
||||
|
||||
// Implements io.Closer.
|
||||
|
@ -80,13 +79,13 @@ func (m *MOGFilter) Close() error {
|
|||
// Write applies the motion filter to the video stream. Only frames with motion
|
||||
// are written to the destination encoder, frames without are discarded.
|
||||
func (m *MOGFilter) Write(f []byte) (int, error) {
|
||||
if hfCount < (m.hf - 1) {
|
||||
m.hold[hfCount] = f
|
||||
hfCount++
|
||||
if m.hfCount < (m.hf - 1) {
|
||||
m.hold[m.hfCount] = f
|
||||
m.hfCount++
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
hfCount = 0
|
||||
m.hfCount = 0
|
||||
img, err := gocv.IMDecode(f, gocv.IMReadColor)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("image can't be decoded: %w", err)
|
||||
|
|
|
@ -273,19 +273,11 @@ type Config struct {
|
|||
Width uint // Width defines the input video width Raspivid input.
|
||||
Bitrate uint // Bitrate specifies the bitrate for constant bitrate in kbps.
|
||||
|
||||
<<<<<<< HEAD
|
||||
HorizontalFlip bool // HorizontalFlip flips video horizontally for Raspivid input.
|
||||
VerticalFlip bool // VerticalFlip flips video vertically for Raspivid input.
|
||||
Filters []int // Defines the methods of filtering to be used in between lexing and encoding.
|
||||
FilterFrames int // Sets the number of frames that are held before the filter is used (on the nth frame)
|
||||
PSITime int // Sets the time between a packet being sent.
|
||||
=======
|
||||
HorizontalFlip bool // HorizontalFlip flips video horizontally for Raspivid input.
|
||||
VerticalFlip bool // VerticalFlip flips video vertically for Raspivid input.
|
||||
Filter int // Defines the method of filtering to be used in between lexing and encoding.
|
||||
FilterFrames int // Sets the number of frames that are held before the filter is used (on the nth frame)
|
||||
PSITime int // Sets the time between a packet being sent
|
||||
>>>>>>> d097308e... adding variable to choose how many frames to skip before filtering
|
||||
|
||||
// Ring buffer parameters.
|
||||
RBMaxElements int // The maximum possible number of elements in ring buffer.
|
||||
|
|
|
@ -344,7 +344,6 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.
|
|||
|
||||
r.encoders = multiWriter(encoders...)
|
||||
|
||||
<<<<<<< HEAD
|
||||
l := len(r.cfg.Filters)
|
||||
r.filters = []filter.Filter{filter.NewNoOp(r.encoders)}
|
||||
if l != 0 {
|
||||
|
@ -366,20 +365,7 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.
|
|||
}
|
||||
dst = r.filters[i]
|
||||
}
|
||||
=======
|
||||
switch r.cfg.Filter {
|
||||
case config.FilterNoOp:
|
||||
r.filter = filter.NewNoOp(r.encoders)
|
||||
case config.FilterMOG:
|
||||
r.filter = filter.NewMOGFilter(r.encoders, mogMinArea, mogThreshold, mogHistory, r.cfg.ShowWindows, r.cfg.FilterFrames)
|
||||
case config.FilterVariableFPS:
|
||||
r.filter = filter.NewVariableFPSFilter(r.encoders, minFPS, filter.NewMOGFilter(r.encoders, mogMinArea, mogThreshold, mogHistory, r.cfg.ShowWindows, r.cfg.FilterFrames))
|
||||
case config.FilterKNN:
|
||||
r.filter = filter.NewKNNFilter(r.encoders, knnMinArea, knnThreshold, knnHistory, knnKernel, r.cfg.ShowWindows)
|
||||
|
||||
default:
|
||||
panic("Undefined Filter")
|
||||
>>>>>>> d097308e... adding variable to choose how many frames to skip before filtering
|
||||
}
|
||||
|
||||
switch r.cfg.Input {
|
||||
|
@ -709,16 +695,6 @@ func (r *Revid) Update(vars map[string]string) error {
|
|||
r.cfg.Logger.Log(logger.Warning, pkg+"invalid FilterFrames var", "value", value)
|
||||
break
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
r.cfg.Filter = v
|
||||
case "FilterFrames":
|
||||
v, err := strconv.Atoi(value)
|
||||
if err != nil || v < 0 {
|
||||
r.cfg.Logger.Log(logger.Warning, pkg+"invalid FilterFrames var", "value", value)
|
||||
break
|
||||
}
|
||||
>>>>>>> d097308e... adding variable to choose how many frames to skip before filtering
|
||||
r.cfg.FilterFrames = v
|
||||
case "PSITime":
|
||||
v, err := strconv.Atoi(value)
|
||||
|
|
Loading…
Reference in New Issue