gobot.io/x/gobot@v1.16.0/examples/opencv_window.go (about) 1 // +build example 2 // 3 // Do not build by default. 4 5 package main 6 7 import ( 8 "gobot.io/x/gobot" 9 "gobot.io/x/gobot/platforms/opencv" 10 "gocv.io/x/gocv" 11 ) 12 13 func main() { 14 window := opencv.NewWindowDriver() 15 camera := opencv.NewCameraDriver(0) 16 17 work := func() { 18 camera.On(opencv.Frame, func(data interface{}) { 19 img := data.(gocv.Mat) 20 window.ShowImage(img) 21 window.WaitKey(1) 22 }) 23 } 24 25 robot := gobot.NewRobot("cameraBot", 26 []gobot.Device{window, camera}, 27 work, 28 ) 29 30 robot.Start() 31 }