Skip to content

Instantly share code, notes, and snippets.

@jumpinjan
Created June 10, 2018 13:51
Show Gist options
  • Save jumpinjan/062396de987c686b07a69e630e817c22 to your computer and use it in GitHub Desktop.
Save jumpinjan/062396de987c686b07a69e630e817c22 to your computer and use it in GitHub Desktop.
Capital Go - Capture Video Using GoCV
func kiosk() {
webcam, err := gocv.VideoCaptureDevice(0)
if err != nil {
log.Fatalln("can't find camera")
}
// prepare image matrix
img := gocv.NewMat()
defer img.Close()
for {
if ok := webcam.Read(&img); !ok || img.Empty() {
log.Print("cannot read webcam")
continue
}
buf, err := gocv.IMEncode(".jpg", img)
if err != nil {
log.Printf("unable to encode matrix: %v", err)
continue
}
stream.UpdateJPEG(buf)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment