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 (
|
||||
"encoding/json"
|
||||
"image"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
|
@ -58,24 +57,7 @@ func (server Server) stream(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
mat := stream.GetStreamInstant()
|
||||
|
||||
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)
|
||||
}
|
||||
mat := stream.IMReadCurrentColor()
|
||||
|
||||
jpg, err := gocv.IMEncode(".jpg", mat)
|
||||
if err != nil {
|
||||
|
|
17
stream.go
17
stream.go
|
@ -51,10 +51,19 @@ func (s Stream) Update() {
|
|||
}
|
||||
go gocv.IMWrite(s.GetCurrentColorInstantPath(), mat)
|
||||
|
||||
grey := gocv.NewMat()
|
||||
gocv.CvtColor(mat, &grey, gocv.ColorBGRAToGray)
|
||||
gocv.GaussianBlur(grey, &grey, image.Point{X: 21, Y: 21}, 0, 0, gocv.BorderReflect)
|
||||
go s.SaveStreamInstant(grey)
|
||||
currentGrey := gocv.NewMat()
|
||||
gocv.CvtColor(mat, ¤tGrey, gocv.ColorBGRAToGray)
|
||||
gocv.GaussianBlur(currentGrey, ¤tGrey, image.Point{X: 21, Y: 21}, 0, 0, gocv.BorderReflect)
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue