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
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue