removed instant update stuff from stream
This commit is contained in:
parent
280b3327bf
commit
dd86398394
2 changed files with 14 additions and 23 deletions
20
main.go
20
main.go
|
@ -2,7 +2,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"image"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -58,24 +57,7 @@ func (server Server) stream(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
mat := stream.GetStreamInstant()
|
mat := stream.IMReadCurrentColor()
|
||||||
|
|
||||||
diff := gocv.NewMat()
|
|
||||||
mat.CopyTo(&diff)
|
|
||||||
gocv.CvtColor(diff, &diff, gocv.ColorBGRAToGray)
|
|
||||||
gocv.GaussianBlur(diff, &diff, image.Point{X: 21, Y: 21}, 0, 0, gocv.BorderReflect)
|
|
||||||
|
|
||||||
go stream.SaveStreamInstant(mat)
|
|
||||||
|
|
||||||
if stream.PreviousInstantPathExists() {
|
|
||||||
previous := stream.IMReadPrevious()
|
|
||||||
|
|
||||||
gocv.GaussianBlur(previous, &previous, image.Point{X: 21, Y: 21}, 0, 0, gocv.BorderReflect)
|
|
||||||
|
|
||||||
gocv.AbsDiff(previous, diff, &diff)
|
|
||||||
|
|
||||||
gocv.Threshold(diff, &diff, 25, 255, gocv.ThresholdBinary)
|
|
||||||
}
|
|
||||||
|
|
||||||
jpg, err := gocv.IMEncode(".jpg", mat)
|
jpg, err := gocv.IMEncode(".jpg", mat)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
17
stream.go
17
stream.go
|
@ -51,10 +51,19 @@ func (s Stream) Update() {
|
||||||
}
|
}
|
||||||
go gocv.IMWrite(s.GetCurrentColorInstantPath(), mat)
|
go gocv.IMWrite(s.GetCurrentColorInstantPath(), mat)
|
||||||
|
|
||||||
grey := gocv.NewMat()
|
currentGrey := gocv.NewMat()
|
||||||
gocv.CvtColor(mat, &grey, gocv.ColorBGRAToGray)
|
gocv.CvtColor(mat, ¤tGrey, gocv.ColorBGRAToGray)
|
||||||
gocv.GaussianBlur(grey, &grey, image.Point{X: 21, Y: 21}, 0, 0, gocv.BorderReflect)
|
gocv.GaussianBlur(currentGrey, ¤tGrey, image.Point{X: 21, Y: 21}, 0, 0, gocv.BorderReflect)
|
||||||
go s.SaveStreamInstant(grey)
|
go s.SaveStreamInstant(currentGrey)
|
||||||
|
|
||||||
|
if !s.PreviousInstantPathExists() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
diff := gocv.NewMat()
|
||||||
|
previousGrey := s.IMReadPrevious()
|
||||||
|
gocv.AbsDiff(previousGrey, currentGrey, &diff)
|
||||||
|
gocv.Threshold(diff, &diff, 10, 255, gocv.ThresholdBinary)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateInterval calls Update() every interval
|
// UpdateInterval calls Update() every interval
|
||||||
|
|
Loading…
Add table
Reference in a new issue