hybridgroup.gobot/examples/opencv_window.go

30 lines
515 B
Go

package main
import (
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/opencv"
cv "github.com/lazywei/go-opencv/opencv"
)
func main() {
gbot := gobot.NewGobot()
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,
)
gbot.AddRobot(robot)
gbot.Start()
}