diff --git a/exp/gocv-exp/main.go b/exp/gocv-exp/main.go index 4cbcf6a8..086390c7 100644 --- a/exp/gocv-exp/main.go +++ b/exp/gocv-exp/main.go @@ -1,3 +1,4 @@ +//go:build !nocv // +build !nocv // What it does: @@ -93,8 +94,8 @@ func main() { // now find contours contours := gocv.FindContours(imgThresh, gocv.RetrievalExternal, gocv.ChainApproxSimple) - for _, c := range contours { - area := gocv.ContourArea(c) + for i := 0; i < contours.Size(); i++ { + area := gocv.ContourArea(contours.At(i)) if area < float64(minArea) { continue } @@ -104,7 +105,7 @@ func main() { //gocv.DrawContours(&img, contours, i, statusColor, 2) - rect := gocv.BoundingRect(c) + rect := gocv.BoundingRect(contours.At(i)) gocv.Rectangle(&img, rect, color.RGBA{0, 0, 255, 0}, 1) } diff --git a/filter/knn.go b/filter/knn.go index abc8eb83..18b612e4 100644 --- a/filter/knn.go +++ b/filter/knn.go @@ -1,3 +1,4 @@ +//go:build !nocv // +build !nocv /* @@ -117,9 +118,9 @@ func (m *KNN) Detect(img *gocv.Mat) bool { // Find contours and reject ones with a small area. var contours [][]image.Point allContours := gocv.FindContours(imgDelta, gocv.RetrievalExternal, gocv.ChainApproxSimple) - for _, c := range allContours { - if gocv.ContourArea(c) > m.area { - contours = append(contours, c) + for i := 0; i < allContours.Size(); i++ { + if gocv.ContourArea(allContours.At(i)) > m.area { + contours = append(contours, allContours.At(i).ToPoints()) } } diff --git a/filter/mog.go b/filter/mog.go index f7ef6dbd..c3b15a93 100644 --- a/filter/mog.go +++ b/filter/mog.go @@ -1,3 +1,4 @@ +//go:build !nocv // +build !nocv /* @@ -117,9 +118,10 @@ func (m *MOG) Detect(img *gocv.Mat) bool { // Find contours and reject ones with a small area. var contours [][]image.Point allContours := gocv.FindContours(imgDelta, gocv.RetrievalExternal, gocv.ChainApproxSimple) - for _, c := range allContours { - if gocv.ContourArea(c) > m.area { - contours = append(contours, c) + + for i := 0; i < allContours.Size(); i++ { + if gocv.ContourArea(allContours.At(i)) > m.area { + contours = append(contours, allContours.At(i).ToPoints()) } }