2022-01-13 04:08:30 +03:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2022-01-07 07:12:15 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-01-13 04:08:30 +03:00
|
|
|
"io"
|
2022-01-10 06:47:52 +03:00
|
|
|
"io/ioutil"
|
2022-01-07 07:12:15 +03:00
|
|
|
"testing"
|
2022-01-13 04:08:30 +03:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"bitbucket.org/ausocean/utils/logger"
|
|
|
|
"gopkg.in/natefinch/lumberjack.v2"
|
2022-01-10 06:47:52 +03:00
|
|
|
)
|
2022-01-07 07:12:15 +03:00
|
|
|
|
2022-01-13 04:08:30 +03:00
|
|
|
// TestProbe reads a given video file and writes the sharpness and contrast scores to a turbidity probe.
|
2022-01-11 07:05:53 +03:00
|
|
|
func TestProbe(t *testing.T) {
|
2022-01-13 04:08:30 +03:00
|
|
|
// Create lumberjack logger.
|
|
|
|
fileLog := &lumberjack.Logger{
|
|
|
|
Filename: logPath,
|
|
|
|
MaxSize: logMaxSize,
|
|
|
|
MaxBackups: logMaxBackup,
|
|
|
|
MaxAge: logMaxAge,
|
|
|
|
}
|
|
|
|
log := logger.New(logVerbosity, io.MultiWriter(fileLog), logSuppress)
|
2022-04-11 02:53:40 +03:00
|
|
|
transformMatrix := []float64{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
|
2022-01-07 07:12:15 +03:00
|
|
|
|
2022-04-11 02:53:40 +03:00
|
|
|
ts, err := NewTurbidityProbe(*log, time.Microsecond, transformMatrix)
|
2022-01-13 04:08:30 +03:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("failed to create turbidity probe")
|
|
|
|
}
|
2022-01-11 07:05:53 +03:00
|
|
|
video, err := ioutil.ReadFile("logo.h264")
|
2022-01-10 06:47:52 +03:00
|
|
|
if err != nil {
|
2022-01-11 07:05:53 +03:00
|
|
|
t.Fatalf("failed to read file: %v", err)
|
2022-01-10 06:47:52 +03:00
|
|
|
}
|
2022-01-07 07:12:15 +03:00
|
|
|
|
2022-01-11 07:05:53 +03:00
|
|
|
_, err = ts.Write(video)
|
2022-01-10 06:47:52 +03:00
|
|
|
if err != nil {
|
2022-01-11 07:05:53 +03:00
|
|
|
t.Fatalf("failed to write sharpness and contrast: %v", err)
|
2022-01-10 06:47:52 +03:00
|
|
|
}
|
2022-01-11 07:05:53 +03:00
|
|
|
t.Logf("contrast: %v, sharpness: %v\n", ts.contrast, ts.sharpness)
|
2022-01-07 07:12:15 +03:00
|
|
|
}
|