mirror of https://bitbucket.org/ausocean/av.git
Fixed range issues with gocv
This commit is contained in:
parent
e3252ed4bb
commit
88b9b58d18
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build !nocv
|
||||||
// +build !nocv
|
// +build !nocv
|
||||||
|
|
||||||
// What it does:
|
// What it does:
|
||||||
|
@ -93,8 +94,8 @@ func main() {
|
||||||
|
|
||||||
// now find contours
|
// now find contours
|
||||||
contours := gocv.FindContours(imgThresh, gocv.RetrievalExternal, gocv.ChainApproxSimple)
|
contours := gocv.FindContours(imgThresh, gocv.RetrievalExternal, gocv.ChainApproxSimple)
|
||||||
for _, c := range contours {
|
for i := 0; i < contours.Size(); i++ {
|
||||||
area := gocv.ContourArea(c)
|
area := gocv.ContourArea(contours.At(i))
|
||||||
if area < float64(minArea) {
|
if area < float64(minArea) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -104,7 +105,7 @@ func main() {
|
||||||
|
|
||||||
//gocv.DrawContours(&img, contours, i, statusColor, 2)
|
//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)
|
gocv.Rectangle(&img, rect, color.RGBA{0, 0, 255, 0}, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build !nocv
|
||||||
// +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.
|
// Find contours and reject ones with a small area.
|
||||||
var contours [][]image.Point
|
var contours [][]image.Point
|
||||||
allContours := gocv.FindContours(imgDelta, gocv.RetrievalExternal, gocv.ChainApproxSimple)
|
allContours := gocv.FindContours(imgDelta, gocv.RetrievalExternal, gocv.ChainApproxSimple)
|
||||||
for _, c := range allContours {
|
for i := 0; i < allContours.Size(); i++ {
|
||||||
if gocv.ContourArea(c) > m.area {
|
if gocv.ContourArea(allContours.At(i)) > m.area {
|
||||||
contours = append(contours, c)
|
contours = append(contours, allContours.At(i).ToPoints())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build !nocv
|
||||||
// +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.
|
// Find contours and reject ones with a small area.
|
||||||
var contours [][]image.Point
|
var contours [][]image.Point
|
||||||
allContours := gocv.FindContours(imgDelta, gocv.RetrievalExternal, gocv.ChainApproxSimple)
|
allContours := gocv.FindContours(imgDelta, gocv.RetrievalExternal, gocv.ChainApproxSimple)
|
||||||
for _, c := range allContours {
|
|
||||||
if gocv.ContourArea(c) > m.area {
|
for i := 0; i < allContours.Size(); i++ {
|
||||||
contours = append(contours, c)
|
if gocv.ContourArea(allContours.At(i)) > m.area {
|
||||||
|
contours = append(contours, allContours.At(i).ToPoints())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue