av/cmd/rv/probe_test.go

64 lines
1.8 KiB
Go

/*
DESCRIPTION
Testing function for turbidity probe.
AUTHORS
Russell Stanley <russell@ausocean.org>
LICENSE
Copyright (C) 2021-2022 the Australian Ocean Lab (AusOcean)
It is free software: you can redistribute it and/or modify them
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
It is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
in gpl.txt. If not, see http://www.gnu.org/licenses.
*/
package main
import (
"io"
"io/ioutil"
"testing"
"time"
"bitbucket.org/ausocean/utils/logger"
"gopkg.in/natefinch/lumberjack.v2"
)
// TestProbe reads a given video file and writes the sharpness and contrast scores to a turbidity probe.
func TestProbe(t *testing.T) {
// Create lumberjack logger.
fileLog := &lumberjack.Logger{
Filename: logPath,
MaxSize: logMaxSize,
MaxBackups: logMaxBackup,
MaxAge: logMaxAge,
}
log := logger.New(logVerbosity, io.MultiWriter(fileLog), logSuppress)
transformMatrix := []float64{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
ts, err := NewTurbidityProbe(*log, time.Microsecond, transformMatrix)
if err != nil {
t.Fatalf("failed to create turbidity probe")
}
video, err := ioutil.ReadFile("logo.h264")
if err != nil {
t.Fatalf("failed to read file: %v", err)
}
_, err = ts.Write(video)
if err != nil {
t.Fatalf("failed to write sharpness and contrast: %v", err)
}
t.Logf("contrast: %v, sharpness: %v\n", ts.contrast, ts.sharpness)
}