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
```
2017-06-10 12:59:19 +02:00
go get -d -u gobot.io/x/gobot/...
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"
2016-12-08 13:24:03 +01:00
"gobot.io/x/gobot"
"gobot.io/x/gobot/platforms/opencv"
2014-04-26 03:11:51 -07:00
)
func main() {
2016-10-01 17:53:39 +02:00
window := opencv.NewWindowDriver()
camera := opencv.NewCameraDriver(0)
2014-04-26 03:11:51 -07:00
work := func() {
2016-10-01 17:53:39 +02:00
camera.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,
)
2016-10-18 21:37:10 +02:00
robot.Start()
2014-04-26 03:11:51 -07:00
}
```