1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-29 13:49:14 +08:00

63 lines
1.2 KiB
Markdown
Raw Normal View History

2014-06-09 19:01:53 -07:00
# OpenCV
2014-06-09 19:01:53 -07:00
This repository contains the Gobot drivers for opencv.
2014-06-09 19:01:53 -07:00
## Getting Started
2014-06-09 19:01:53 -07:00
This package requires `opencv` to be installed on your system
### OSX
To install `opencv` on OSX using Homebrew:
```
2014-07-06 14:17:10 -05:00
$ brew tap homebrew/science && brew install opencv
2014-06-09 19:01:53 -07:00
```
### Ubuntu
Follow the official [OpenCV installation guide](http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html)
2014-07-06 14:17:10 -05:00
### Windows
2014-06-09 19:01:53 -07:00
Follow the official [OpenCV installation guide](http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html#windows-installation)
2014-07-06 14:17:10 -05:00
Now you can install the package with
2014-06-09 19:01:53 -07:00
```
2014-07-06 14:17:10 -05:00
go get github.com/hybridgroup/gobot && go install github.com/hybridgroup/gobot/platforms/opencv
```
## Using
```go
package main
import (
cv "github.com/hybridgroup/go-opencv/opencv"
"github.com/hybridgroup/gobot"
2014-06-09 19:01:53 -07:00
"github.com/hybridgroup/gobot/platforms/opencv"
)
func main() {
2014-06-09 19:01:53 -07:00
gbot := gobot.NewGobot()
2014-06-09 19:01:53 -07:00
window := opencv.NewWindowDriver("window")
camera := opencv.NewCameraDriver("camera", 0)
work := func() {
2014-07-10 17:02:00 -07:00
gobot.On(camera.Event("frame"), func(data interface{}) {
2014-06-09 19:01:53 -07:00
window.ShowImage(data.(*cv.IplImage))
})
}
2014-07-10 17:02:00 -07:00
robot := gobot.NewRobot("cameraBot",
[]gobot.Device{window, camera},
work,
)
gbot.AddRobot(robot)
2014-06-09 19:01:53 -07:00
gbot.Start()
}
```