Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSDK-8017: linting action #9

Merged
merged 60 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
8de33fb
added unit tests
dhritinaidu Jul 12, 2024
e43ec36
added linting action and fixed linting issues
dhritinaidu Jul 12, 2024
fe4a9ad
added a timeout to lint yml
dhritinaidu Jul 12, 2024
6ca5232
Merge pull request #8 from dhritinaidu/unittests
dhritinaidu Jul 12, 2024
0924387
trying to fix timeout
dhritinaidu Jul 15, 2024
c43673d
trying to fix lint github action
dhritinaidu Jul 15, 2024
5ced2cc
trying to fix dependencies
dhritinaidu Jul 15, 2024
af0ee9f
runnning linter on docker container
dhritinaidu Jul 15, 2024
b27de39
running linter on docker container
dhritinaidu Jul 15, 2024
d62585f
trying to fix lint errors
dhritinaidu Jul 15, 2024
8d4e236
trying to fix go set up
dhritinaidu Jul 15, 2024
0c33128
trying to fix go set up
dhritinaidu Jul 15, 2024
9f97185
trying to fix VCS linting issue
dhritinaidu Jul 15, 2024
ca57379
trying to fix VCS linting issue pt 2
dhritinaidu Jul 15, 2024
1ed25a1
trying to fix VCS linting issue pt 2
dhritinaidu Jul 15, 2024
09de4d4
trying to fix VCS linting issue pt 3
dhritinaidu Jul 15, 2024
f49a182
trying to fix VCS linting issue pt 4
dhritinaidu Jul 15, 2024
d262fee
trying to fix VCS linting issue pt 5
dhritinaidu Jul 15, 2024
86fd372
trying to fix VCS linting issue pt 5
dhritinaidu Jul 15, 2024
d9f7320
trying to fix VCS linting issue pt 6
dhritinaidu Jul 15, 2024
ebd8136
trying to fix VCS linting issue pt 7
dhritinaidu Jul 15, 2024
446da7a
trying to fix VCS linting issue pt 8
dhritinaidu Jul 15, 2024
2cecd4b
trying to fix VCS linting issue pt 9
dhritinaidu Jul 15, 2024
375360b
trying to fix VCS linting issue pt 10
dhritinaidu Jul 15, 2024
7bb45c3
trying make lint
dhritinaidu Jul 16, 2024
223d65f
added golangci-lint to docker image
dhritinaidu Jul 18, 2024
da6ef0e
Merge branch 'main' into RSDK-8017-docker-img-update
bhaney Jul 18, 2024
d2bc5e3
Merge pull request #10 from viamrobotics/RSDK-8017-docker-img-update
dhritinaidu Jul 18, 2024
10f4ea0
added linting action and fixed linting issues
dhritinaidu Jul 12, 2024
ac8e49c
added a timeout to lint yml
dhritinaidu Jul 12, 2024
0747746
trying to fix timeout
dhritinaidu Jul 15, 2024
9e3f196
trying to fix lint github action
dhritinaidu Jul 15, 2024
501a9fd
trying to fix dependencies
dhritinaidu Jul 15, 2024
e4d49c3
runnning linter on docker container
dhritinaidu Jul 15, 2024
f26b226
running linter on docker container
dhritinaidu Jul 15, 2024
19f74db
trying to fix lint errors
dhritinaidu Jul 15, 2024
5f63d2a
trying to fix go set up
dhritinaidu Jul 15, 2024
aaf8090
trying to fix go set up
dhritinaidu Jul 15, 2024
0867026
trying to fix VCS linting issue
dhritinaidu Jul 15, 2024
dde6c56
trying to fix VCS linting issue pt 2
dhritinaidu Jul 15, 2024
11b0771
trying to fix VCS linting issue pt 2
dhritinaidu Jul 15, 2024
1da1dbf
trying to fix VCS linting issue pt 3
dhritinaidu Jul 15, 2024
319c4af
trying to fix VCS linting issue pt 4
dhritinaidu Jul 15, 2024
d5ba46a
trying to fix VCS linting issue pt 5
dhritinaidu Jul 15, 2024
6801572
trying to fix VCS linting issue pt 5
dhritinaidu Jul 15, 2024
3a35714
trying to fix VCS linting issue pt 6
dhritinaidu Jul 15, 2024
92d74d8
trying to fix VCS linting issue pt 7
dhritinaidu Jul 15, 2024
c95be9f
trying to fix VCS linting issue pt 8
dhritinaidu Jul 15, 2024
a8f8d95
trying to fix VCS linting issue pt 9
dhritinaidu Jul 15, 2024
6feb479
trying to fix VCS linting issue pt 10
dhritinaidu Jul 15, 2024
8c59c2b
trying make lint
dhritinaidu Jul 16, 2024
4e6daa2
added timeout to lint
dhritinaidu Jul 18, 2024
8a66ff8
fixed makefile conflict
dhritinaidu Jul 18, 2024
50f9fad
trying to fix VCS error
dhritinaidu Jul 18, 2024
bbe55a2
go mod tidy
dhritinaidu Jul 18, 2024
13a93ab
fixing go version
dhritinaidu Jul 18, 2024
361b606
testing make lint
dhritinaidu Jul 19, 2024
c1ac4cc
testing make lint without make test
dhritinaidu Jul 19, 2024
75d59d8
adding make test back in
dhritinaidu Jul 19, 2024
e6baa64
added path to make test
dhritinaidu Jul 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: golangci-lint
on:
push:
branches:
- main
- master
pull_request:
branches:
- main

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ docker-amd64-ci: BUILD_PUSH = --push
docker-amd64-ci:
$(BUILD_CMD)

# Test target for running Go tests
test:
go test ./oceanprefilter

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/pkg/errors v0.9.1
go.viam.com/rdk v0.28.0
go.viam.com/utils v0.1.79
gocv.io/x/gocv v0.36.1
gocv.io/x/gocv v0.37.0
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,8 @@ go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 h1:WJhcL4p
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
gocv.io/x/gocv v0.36.1 h1:6XkEaPOk7h/umjy+MXgSEtSeCIgcPJhccUjrJFhjdTY=
gocv.io/x/gocv v0.36.1/go.mod h1:lmS802zoQmnNvXETpmGriBqWrENPei2GxYx5KUxJsMA=
gocv.io/x/gocv v0.37.0 h1:sISHvnApErjoJodz1Dxb8UAkFdITOB3vXGslbVu6Knk=
gocv.io/x/gocv v0.37.0/go.mod h1:lmS802zoQmnNvXETpmGriBqWrENPei2GxYx5KUxJsMA=
goji.io v2.0.2+incompatible h1:uIssv/elbKRLznFUy3Xj4+2Mz/qKhek/9aZQDUMae7c=
goji.io v2.0.2+incompatible/go.mod h1:sbqFwrtqZACxLBTQcdgVjFh54yGVCvwq8+w49MVMMIk=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU=
Expand Down
51 changes: 0 additions & 51 deletions oceanprefilter/histogram_compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package oceanprefilter
import (
"fmt"
"image"
"image/draw"
"math"

"github.com/pkg/errors"
Expand Down Expand Up @@ -113,15 +112,6 @@ func histogramTrigger(oldHist, newHist Histogram, thresh float64) bool {
return trigger
}

func convertToFloat64(uint8Slice []uint8) []float64 {
float64Slice := make([]float64, len(uint8Slice))

for i, v := range uint8Slice {
float64Slice[i] = float64(v)
}
return float64Slice
}

func createGrayHistograms(pic image.Image) []Histogram {
hists := make([]Histogram, 0, 1)
img := toGray(pic)
Expand All @@ -136,47 +126,6 @@ func createGrayHistograms(pic image.Image) []Histogram {
return hists
}

func createColorHistograms(pic image.Image) []Histogram {
hists := make([]Histogram, 0, 3)
img := image.NewRGBA(pic.Bounds())
if rgbaImg, ok := pic.(*image.RGBA); ok {
img = rgbaImg
} else {
draw.Draw(img, pic.Bounds(), pic, pic.Bounds().Min, draw.Src)
}
rPix := []float64{}
gPix := []float64{}
bPix := []float64{}
for x := 0; x < img.Bounds().Dx(); x++ {
for y := 0; y < img.Bounds().Dy(); y++ {
c := img.RGBAAt(x, y)
rPix = append(rPix, float64(c.R))
gPix = append(gPix, float64(c.G))
bPix = append(bPix, float64(c.B))
}
}
hists = append(hists, Hist(32, 0, 256, rPix)) // 32 bin, 8 values in each bin in 255 total
hists = append(hists, Hist(32, 0, 256, gPix)) // 32 bin, 8 values in each bin in 255 total
hists = append(hists, Hist(32, 0, 256, bPix)) // 32 bin, 8 values in each bin in 255 total
return hists
}

// basicCompare compares two histograms and returns a measure of their difference
func basicCompare(hist1, hist2 Histogram) float64 {
var sum float64
for i := range hist1.Buckets {
diff := hist1.Buckets[i].Count - hist2.Buckets[i].Count
if diff < 0 {
diff = -diff
}
sum += float64(diff)
}
// Normalize the difference based on the number of pixels
totalPixels := float64(hist1.Count + hist2.Count) // hist2 has the same number of pixels
score := sum / totalPixels
return score
}

// histogramToECDF converts a histogram to an empirical cumulative distribution function (ECDF)
// Assumes histogram bins are evenly distributed over the data range
func histogramToECDF(hist Histogram) []float64 {
Expand Down
31 changes: 0 additions & 31 deletions oceanprefilter/ml_filtering.go

This file was deleted.

1 change: 0 additions & 1 deletion oceanprefilter/oceanprefilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ type runConfig struct {
detector vision.Service
chosenLabels map[string]float64
frequency float64
minConfidence float64
threshold float64
excludedZone *image.Rectangle
motionTrigger bool
Expand Down
Loading