Created
June 10, 2018 13:51
-
-
Save jumpinjan/062396de987c686b07a69e630e817c22 to your computer and use it in GitHub Desktop.
Capital Go - Capture Video Using GoCV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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