added additional comments

This commit is contained in:
Russell Stanley 2022-01-12 12:25:58 +10:30
parent 556efa7f00
commit 8bfebec9df
2 changed files with 12 additions and 6 deletions

View File

@ -1,5 +1,5 @@
//go:build !ignore //go:build !nocv
// +build !ignore // +build !nocv
/* /*
DESCRIPTION DESCRIPTION

View File

@ -1,3 +1,6 @@
//go:build !nocv
// +build !nocv
/* /*
DESCRIPTION DESCRIPTION
Testing functions for the turbidity sensor using images from Testing functions for the turbidity sensor using images from
@ -36,11 +39,13 @@ import (
) )
const ( const (
nImages = 13 // Number of images to test. (Max 13) nImages = 10 // Number of images to test. (Max 13)
nSamples = 10 // Number of samples for each image. (Max 10) nSamples = 1 // Number of samples for each image. (Max 10)
increment = 2.5 // Increment of the turbidity level. increment = 2.5 // Increment of the turbidity level.
) )
// TestImages will read a library of test images and calculate the sharpness and contrast scores.
// A plot of the results will be generated and stored in the plots directory.
func TestImages(t *testing.T) { func TestImages(t *testing.T) {
const ( const (
k1, k2 = 8, 8 k1, k2 = 8, 8
@ -63,12 +68,12 @@ func TestImages(t *testing.T) {
ts, err := NewTurbiditySensor(template, standard, k1, k2, filterSize, scale, alpha) ts, err := NewTurbiditySensor(template, standard, k1, k2, filterSize, scale, alpha)
if err != nil { if err != nil {
t.Fatal("could not create turbidity sensor: %w", err) t.Fatalf("could not create turbidity sensor: %v", err)
} }
results, err := NewResults(nImages) results, err := NewResults(nImages)
if err != nil { if err != nil {
t.Fatal("could not create results: %w", err) t.Fatalf("could not create results: %v", err)
} }
// Score each image by calculating the average score from camera burst. // Score each image by calculating the average score from camera burst.
@ -92,6 +97,7 @@ func TestImages(t *testing.T) {
t.Logf("Contrast: %v", results.Contrast) t.Logf("Contrast: %v", results.Contrast)
} }
// plotResults plots sharpness and contrast scores against the level of almond milk in the container
func plotResults(x, sharpness, contrast []float64) error { func plotResults(x, sharpness, contrast []float64) error {
err := plotToFile( err := plotToFile(
"Results", "Results",