diff --git a/cmd/rv/main.go b/cmd/rv/main.go index da6d2415..ef529b54 100644 --- a/cmd/rv/main.go +++ b/cmd/rv/main.go @@ -120,7 +120,7 @@ const ( // Turbidity sensor constants. const ( - k1, k2 = 8, 8 // Block size, must be divisible by the size template with no remainder. + k1, k2 = 4, 4 // Block size, must be divisible by the size template with no remainder. filterSize = 3 // Sobel filter size. scale = 1.0 // Amount of scale applied to sobel filter values. alpha = 1.0 // Paramater for contrast equation. @@ -148,7 +148,7 @@ func NewTurbidityProbe(log logger.Logger, delay time.Duration) (*turbidityProbe, // Create the turbidity sensor. standard := gocv.IMRead("../../turbidity/images/template.jpg", gocv.IMReadGrayScale) - template := gocv.IMRead("../../turbidity/images/template.jpg", gocv.IMReadGrayScale) + template := gocv.IMRead("../../turbidity/images/icon.jpg", gocv.IMReadGrayScale) ts, err := turbidity.NewTurbiditySensor(template, standard, k1, k2, filterSize, scale, alpha, log) if err != nil { log.Error("failed create turbidity sensor", "error", err.Error()) @@ -161,12 +161,14 @@ func NewTurbidityProbe(log logger.Logger, delay time.Duration) (*turbidityProbe, // scores of a video to the the turbidity probe. func (tp *turbidityProbe) Write(p []byte) (int, error) { tp.buffer.Write(p) - select { - case <-tp.ticker.C: - go tp.turbidityCalculation(p) - default: - return len(p), nil - } + go func() { + select { + case <-tp.ticker.C: + tp.turbidityCalculation(p) + default: + return + } + }() return len(p), nil } diff --git a/turbidity/images/template.jpg b/turbidity/images/template.jpg index d6165d76..3c577d1b 100644 Binary files a/turbidity/images/template.jpg and b/turbidity/images/template.jpg differ