Created
July 29, 2019 03:38
-
-
Save Niraj-Fonseka/3265e94d9a163b59edc3facecf46f568 to your computer and use it in GitHub Desktop.
gocv.go
This file contains 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
package main | |
import ( | |
"log" | |
"gocv.io/x/gocv" | |
) | |
func main() { | |
webcam, err := gocv.VideoCaptureDevice(0) | |
if err != nil { | |
log.Fatalf("error opening device: %v", err) | |
} | |
defer webcam.Close() | |
img := gocv.NewMat() | |
defer img.Close() | |
window := gocv.NewWindow("webcamwindow") | |
defer window.Close() | |
for { | |
if ok := webcam.Read(&img); !ok || img.Empty() { | |
log.Println("Unable to read from the webcam") | |
continue | |
} | |
window.IMShow(img) | |
window.WaitKey(50) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment