2014-04-26 18:11:51 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-02-20 10:36:33 +08:00
|
|
|
cv "github.com/lazywei/go-opencv/opencv"
|
2014-04-26 18:11:51 +08:00
|
|
|
"github.com/hybridgroup/gobot"
|
2014-05-23 11:53:15 +08:00
|
|
|
"github.com/hybridgroup/gobot/platforms/opencv"
|
2014-04-26 18:11:51 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2014-05-23 11:53:15 +08:00
|
|
|
gbot := gobot.NewGobot()
|
2014-04-26 18:11:51 +08:00
|
|
|
|
2014-05-23 11:53:15 +08:00
|
|
|
window := opencv.NewWindowDriver("window")
|
|
|
|
camera := opencv.NewCameraDriver("camera", 0)
|
2014-04-26 18:11:51 +08:00
|
|
|
|
|
|
|
work := func() {
|
2014-07-09 09:36:14 +08:00
|
|
|
gobot.On(camera.Event("frame"), func(data interface{}) {
|
2014-04-26 18:11:51 +08:00
|
|
|
window.ShowImage(data.(*cv.IplImage))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2014-07-09 09:36:14 +08:00
|
|
|
robot := gobot.NewRobot("cameraBot",
|
|
|
|
[]gobot.Device{window, camera},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
|
|
|
gbot.AddRobot(robot)
|
2014-04-26 18:11:51 +08:00
|
|
|
|
2014-06-07 04:18:07 +08:00
|
|
|
gbot.Start()
|
2014-04-26 18:11:51 +08:00
|
|
|
}
|