2014-06-09 19:01:53 -07:00
# OpenCV
2014-04-26 03:11:51 -07:00
2014-11-28 15: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 03:11:51 -07:00
2014-11-28 15:34:42 -08:00
For more info about OpenCV click [here ](http://opencv.org/ )
## How to Install
2014-04-26 03:11:51 -07:00
2016-02-19 18:36:33 -08:00
This package requires OpenCV version 2.4 to be installed on your system. Please note that it is not compatible with OpenCV 3.x at this time.
2014-06-09 19:01:53 -07:00
### OSX
2016-02-19 18:36:33 -08:00
To install OpenCV on OSX using Homebrew:
2014-04-26 03:11:51 -07:00
```
2014-07-06 14:17:10 -05:00
$ brew tap homebrew/science & & brew install opencv
2014-06-09 19:01:53 -07:00
```
### Ubuntu
2016-02-19 18:36:33 -08:00
To install OpenCV on Ubuntu 14.04:
```
$ sudo apt-get install libopencv-dev
```
Or, follow the official [OpenCV installation guide ](http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html )
2014-06-09 19:01:53 -07:00
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
```
2015-07-08 16:03:20 -07:00
go get -d -u github.com/hybridgroup/gobot/... & & go install github.com/hybridgroup/gobot/platforms/opencv
2014-04-26 03:11:51 -07:00
```
2014-11-28 15:34:42 -08:00
## How to Use
Example using the camera.
2014-04-26 03:11:51 -07:00
```go
package main
import (
2016-02-19 18:36:33 -08:00
cv "github.com/lazywei/go-opencv/opencv"
2014-04-26 03:11:51 -07:00
"github.com/hybridgroup/gobot"
2014-06-09 19:01:53 -07:00
"github.com/hybridgroup/gobot/platforms/opencv"
2014-04-26 03:11:51 -07:00
)
func main() {
2014-06-09 19:01:53 -07:00
gbot := gobot.NewGobot()
2014-04-26 03:11:51 -07:00
2014-06-09 19:01:53 -07:00
window := opencv.NewWindowDriver("window")
camera := opencv.NewCameraDriver("camera", 0)
2014-04-26 03:11:51 -07:00
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-04-26 03:11:51 -07:00
})
}
2014-07-10 17:02:00 -07:00
robot := gobot.NewRobot("cameraBot",
[]gobot.Device{window, camera},
work,
)
gbot.AddRobot(robot)
2014-04-26 03:11:51 -07:00
2014-06-09 19:01:53 -07:00
gbot.Start()
2014-04-26 03:11:51 -07:00
}
```