adding variable to choose how many frames to skip before filtering

This commit is contained in:
Ella Pietraroia 2020-01-02 14:45:59 +10:30 committed by Scott
parent b39a440105
commit 6f16f68611
3 changed files with 35 additions and 2 deletions

View File

@ -139,8 +139,9 @@ func (m *MOGFilter) Write(f []byte) (int, error) {
}
// Write to destination, past 4 frames then current frame.
for _, h := range m.hold {
for i, h := range m.hold {
_, err := m.dst.Write(h)
m.hold[i] = nil
if err != nil {
return 0, err
}
@ -149,5 +150,4 @@ func (m *MOGFilter) Write(f []byte) (int, error) {
hfCount = 0
return m.dst.Write(f)
}
}

View File

@ -273,11 +273,19 @@ 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.

View File

@ -344,6 +344,7 @@ 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 {
@ -365,6 +366,20 @@ 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 {
@ -694,6 +709,16 @@ 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)