2014-06-10 10:01:53 +08:00
# OpenCV
2014-04-26 18:11:51 +08:00
2014-11-29 07:34:42 +08:00
OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in the commercial products. Being a BSD-licensed product, OpenCV makes it easy for businesses to utilize and modify the code.
2014-04-26 18:11:51 +08:00
2014-11-29 07:34:42 +08:00
For more info about OpenCV click [here ](http://opencv.org/ )
## How to Install
2014-04-26 18:11:51 +08:00
2014-06-10 10:01:53 +08:00
This package requires `opencv` to be installed on your system
### OSX
To install `opencv` on OSX using Homebrew:
2014-04-26 18:11:51 +08:00
```
2014-07-07 03:17:10 +08:00
$ brew tap homebrew/science & & brew install opencv
2014-06-10 10:01:53 +08:00
```
### Ubuntu
Follow the official [OpenCV installation guide ](http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html )
2014-07-07 03:17:10 +08:00
### Windows
2014-06-10 10:01:53 +08:00
Follow the official [OpenCV installation guide ](http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html#windows-installation )
2014-07-07 03:17:10 +08:00
Now you can install the package with
2014-06-10 10:01:53 +08:00
```
2014-07-07 03:17:10 +08:00
go get github.com/hybridgroup/gobot & & go install github.com/hybridgroup/gobot/platforms/opencv
2014-04-26 18:11:51 +08:00
```
2014-11-29 07:34:42 +08:00
## How to Use
Example using the camera.
2014-04-26 18:11:51 +08:00
```go
package main
import (
cv "github.com/hybridgroup/go-opencv/opencv"
"github.com/hybridgroup/gobot"
2014-06-10 10:01:53 +08:00
"github.com/hybridgroup/gobot/platforms/opencv"
2014-04-26 18:11:51 +08:00
)
func main() {
2014-06-10 10:01:53 +08:00
gbot := gobot.NewGobot()
2014-04-26 18:11:51 +08:00
2014-06-10 10:01:53 +08:00
window := opencv.NewWindowDriver("window")
camera := opencv.NewCameraDriver("camera", 0)
2014-04-26 18:11:51 +08:00
work := func() {
2014-07-11 08:02:00 +08:00
gobot.On(camera.Event("frame"), func(data interface{}) {
2014-06-10 10:01:53 +08:00
window.ShowImage(data.(*cv.IplImage))
2014-04-26 18:11:51 +08:00
})
}
2014-07-11 08:02:00 +08:00
robot := gobot.NewRobot("cameraBot",
[]gobot.Device{window, camera},
work,
)
gbot.AddRobot(robot)
2014-04-26 18:11:51 +08:00
2014-06-10 10:01:53 +08:00
gbot.Start()
2014-04-26 18:11:51 +08:00
}
```