hybridgroup.gobot/platforms/opencv
Ron Evans b082d6739a opencv: update to latest version of GoCV
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-04-24 12:56:26 +02:00
..
LICENSE docs: update copyright date to 2018 2018-02-14 08:24:39 +01:00
README.md docs: improve docs for installation and use of OpenCV/GoCV from Gobot 2018-02-14 16:47:49 +01:00
camera_driver.go opencv: update to latest version of GoCV 2018-04-24 12:56:26 +02:00
camera_driver_test.go opencv: increase test coverage 2017-04-06 11:01:57 +02:00
doc.go docs: correct OpenCV README link 2016-12-21 10:54:15 +01:00
haarcascade_frontalface_alt.xml Add more opencv test coverage 2014-07-23 16:38:46 -07:00
helpers_test.go opencv: update to latest version of GoCV 2018-04-24 12:56:26 +02:00
lena-256x256.jpg Add more opencv test coverage 2014-07-23 16:38:46 -07:00
utils.go opencv: update to latest version of GoCV 2018-04-24 12:56:26 +02:00
utils_test.go opencv: update interface and examples to indicate multipurpose 2017-10-23 11:45:36 +02:00
window_driver.go Switch to use custom domain for GoCV package 2017-10-18 18:13:40 +02:00
window_driver_test.go Switch to use custom domain for GoCV package 2017-10-18 18:13:40 +02:00

README.md

OpenCV

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.

For more info about OpenCV click here

How to Install

This package requires OpenCV version 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.

macOS

To install on macOS follow the instructions here:

https://gocv.io/getting-started/macos/

Ubuntu

To install on Ubuntu follow the instructions here:

https://gocv.io/getting-started/linux/

Windows

To install on Windows follow the instructions here:

https://gocv.io/getting-started/windows/

Now you can install the Gobot package itself with

go get -d -u gobot.io/x/gobot/...

How to Use

When you run code that uses OpenCV, you must setup some environment variables first. The best way to do this, is to first run the env.sh script that comes with GoCV, like this:

source $GOPATH/src/gocv.io/x/gocv/env.sh

Once you have run this script you can use go run or go build on your Gobot code that uses OpenCV as you normally would.

Here is an example using the camera:

package main

import (
	"gobot.io/x/gobot"
	"gobot.io/x/gobot/platforms/opencv"
	"gocv.io/x/gocv"
)

func main() {
	window := opencv.NewWindowDriver()
	camera := opencv.NewCameraDriver(0)

	work := func() {
		camera.On(opencv.Frame, func(data interface{}) {
			img := data.(gocv.Mat)
			window.ShowImage(img)
			window.WaitKey(1)
		})
	}

	robot := gobot.NewRobot("cameraBot",
		[]gobot.Device{window, camera},
		work,
	)

	robot.Start()
}