removed instant update stuff from stream

This commit is contained in:
BroodjeAap 2020-07-11 11:15:07 +00:00
parent 280b3327bf
commit dd86398394
2 changed files with 14 additions and 23 deletions

20
main.go
View file

@ -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 {

View file

@ -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, &currentGrey, gocv.ColorBGRAToGray)
gocv.GaussianBlur(currentGrey, &currentGrey, 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