1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-09 19:29:27 +08:00
2014-07-06 14:17:10 -05:00

1.3 KiB

OpenCV

This repository contains the Gobot drivers for opencv.

Getting Started

This package requires opencv to be installed on your system

OSX

To install opencv on OSX using Homebrew:

$ brew tap homebrew/science && brew install opencv

Ubuntu

Follow the official OpenCV installation guide

Windows

Follow the official OpenCV installation guide

Now you can install the package with

go get github.com/hybridgroup/gobot && go install github.com/hybridgroup/gobot/platforms/opencv

Using

package main

import (
	cv "github.com/hybridgroup/go-opencv/opencv"
	"github.com/hybridgroup/gobot"
	"github.com/hybridgroup/gobot/platforms/opencv"
)

func main() {
	gbot := gobot.NewGobot()

	window := opencv.NewWindowDriver("window")
	camera := opencv.NewCameraDriver("camera", 0)

	work := func() {
		gobot.On(camera.Events["Frame"], func(data interface{}) {
			window.ShowImage(data.(*cv.IplImage))
		})
	}

	gbot.Robots = append(gbot.Robots,
		gobot.NewRobot("cameraBot", []gobot.Connection{}, []gobot.Device{window, camera}, work))

	gbot.Start()
}