Skip to content

Commit

Permalink
pr review
Browse files Browse the repository at this point in the history
  • Loading branch information
Emerald-Z committed Jul 22, 2024
1 parent 2e4836a commit f7b4c8c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
5 changes: 1 addition & 4 deletions oceanprefilter/oceanprefilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,7 @@ func run(ctx context.Context, rc RunConfig, trigger *atomic.Bool, currImg *atomi
// this function is where the decision happens
isTriggered, err := MakeInference(img, rc)
if err != nil {
rc.logger.Infow("inference error", "error", err.Error())
if rc.motionTrigger {
isTriggered = true
}
return errors.Errorf("inference error: %q", err)
}
if isTriggered {
triggerCount = triggerCountdown
Expand Down
9 changes: 6 additions & 3 deletions oceanprefilter/prefilter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (
)

func TestXGBoostInference(t *testing.T) {
f, _ := os.Open("test_data/2288.jpg")
f, err := os.Open("test_data/2288.jpg")
test.That(t, err, test.ShouldBeNil)
defer f.Close()
img, _, err := image.Decode(f)
test.That(t, err, test.ShouldBeNil)
Expand Down Expand Up @@ -44,7 +45,8 @@ func TestSplitData(t *testing.T) {
continue
}
fp := filepath.Join(dir, file.Name())
f, _ := os.Open(fp)
f, err := os.Open(fp)
test.That(t, err, test.ShouldBeNil)
defer f.Close()
img, _, err := image.Decode(f)
test.That(t, err, test.ShouldBeNil)
Expand All @@ -56,7 +58,8 @@ func TestSplitData(t *testing.T) {
Max: image.Point{X: 580, Y: 480},
}
rc.ExcludedZone = &rect
linePoints, _ := findHorizonLine(img)
linePoints, err := findHorizonLine(img)
test.That(t, err, test.ShouldBeNil)
cropY := int(math.Max(float64(linePoints[0].Y), float64(linePoints[1].Y)))

_, err = splitUpImageConst(img, rc.ExcludedZone, cropY, 80, 200)
Expand Down
5 changes: 2 additions & 3 deletions oceanprefilter/utils.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package oceanprefilter

import (
"fmt"
"image"
"image/draw"
"math"
Expand Down Expand Up @@ -63,10 +62,10 @@ func splitUpImageConst(img image.Image, exZone *image.Rectangle, yValue, h, w in
return nil, errors.New("input image to split up is nil")
}
if h <= 0 {
return nil, fmt.Errorf("height must be greater than 0, got %v", h)
return nil, errors.Errorf("height must be greater than 0, got %v", h)
}
if w <= 0 {
return nil, fmt.Errorf("width must be greater than 0, got %v", w)
return nil, errors.Errorf("width must be greater than 0, got %v", w)
}

// Crop the image from yValue to img.Bounds().Max.Y
Expand Down

0 comments on commit f7b4c8c

Please sign in to comment.