From 68d4bd5593fe1c47ecd40873f8711e0fd262bcbe Mon Sep 17 00:00:00 2001 From: Russell Stanley Date: Mon, 7 Feb 2022 16:14:07 +1030 Subject: [PATCH] decrease template size --- cmd/rv/main.go | 18 ++++++++++-------- turbidity/images/template.jpg | Bin 22444 -> 2286 bytes 2 files changed, 10 insertions(+), 8 deletions(-) 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 d6165d769bbb15ee36b5291d799253df22812b66..3c577d1b74d8edb41bc25be073ce4510225306d4 100644 GIT binary patch literal 2286 zcmbtWdpHy7AAe^q+my^Lw?h}>xSTF>zn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