hybridgroup.gobot/examples/opencv_window.go

26 lines
442 B
Go

package main
import (
"gobot.io/x/gobot"
"gobot.io/x/gobot/platforms/opencv"
cv "github.com/lazywei/go-opencv/opencv"
)
func main() {
window := opencv.NewWindowDriver()
camera := opencv.NewCameraDriver(0)
work := func() {
camera.On(camera.Event("frame"), func(data interface{}) {
window.ShowImage(data.(*cv.IplImage))
})
}
robot := gobot.NewRobot("cameraBot",
[]gobot.Device{window, camera},
work,
)
robot.Start()
}