hybridgroup.gobot/platforms/opencv/README.md

74 lines
1.8 KiB
Markdown
Raw Normal View History

2014-06-10 10:01:53 +08:00
# OpenCV
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-11-29 07:34:42 +08:00
For more info about OpenCV click [here](http://opencv.org/)
## How to Install
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-10 10:01:53 +08:00
### OSX
To install OpenCV on OSX using Homebrew:
```
2014-07-07 03:17:10 +08:00
$ brew tap homebrew/science && brew install opencv
2014-06-10 10:01:53 +08:00
```
### Ubuntu
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-10 10:01:53 +08:00
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
```
go get -d -u github.com/hybridgroup/gobot/... && go install github.com/hybridgroup/gobot/platforms/opencv
```
2014-11-29 07:34:42 +08:00
## How to Use
Example using the camera.
```go
package main
import (
cv "github.com/lazywei/go-opencv/opencv"
"github.com/hybridgroup/gobot"
2014-06-10 10:01:53 +08:00
"github.com/hybridgroup/gobot/platforms/opencv"
)
func main() {
2014-06-10 10:01:53 +08:00
gbot := gobot.NewGobot()
2014-06-10 10:01:53 +08:00
window := opencv.NewWindowDriver("window")
camera := opencv.NewCameraDriver("camera", 0)
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-07-11 08:02:00 +08:00
robot := gobot.NewRobot("cameraBot",
[]gobot.Device{window, camera},
work,
)
gbot.AddRobot(robot)
2014-06-10 10:01:53 +08:00
gbot.Start()
}
```