gobot.io/x/gobot@v1.16.0/platforms/opencv/README.md (about) 1 # OpenCV 2 3 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. 4 5 For more info about OpenCV click [here](http://opencv.org/) 6 7 ## How to Install 8 9 This package requires OpenCV 3.4+ be installed on your system, along with GoCV, which is the Go programming language wrapper used by Gobot. The best way is to follow the installation instructions on the GoCV website at [https://gocv.io](https://gocv.io). 10 11 The instructions should automatically install OpenCV 4+ 12 13 ### macOS 14 15 To install on macOS follow the instructions here: 16 17 https://gocv.io/getting-started/macos/ 18 19 ### Ubuntu 20 21 To install on Ubuntu follow the instructions here: 22 23 https://gocv.io/getting-started/linux/ 24 25 ### Windows 26 27 To install on Windows follow the instructions here: 28 29 https://gocv.io/getting-started/windows/ 30 31 32 Now you can install the Gobot package itself with 33 34 ``` 35 go get -d -u gobot.io/x/gobot/... 36 ``` 37 38 ## How to Use 39 40 Here is an example using the camera: 41 42 ```go 43 package main 44 45 import ( 46 "gobot.io/x/gobot" 47 "gobot.io/x/gobot/platforms/opencv" 48 "gocv.io/x/gocv" 49 ) 50 51 func main() { 52 window := opencv.NewWindowDriver() 53 camera := opencv.NewCameraDriver(0) 54 55 work := func() { 56 camera.On(opencv.Frame, func(data interface{}) { 57 img := data.(gocv.Mat) 58 window.ShowImage(img) 59 window.WaitKey(1) 60 }) 61 } 62 63 robot := gobot.NewRobot("cameraBot", 64 []gobot.Device{window, camera}, 65 work, 66 ) 67 68 robot.Start() 69 } 70 ```