opencv

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2016 License: Apache-2.0, Apache-2.0 Imports: 4 Imported by: 0

README

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 2.4 to be installed on your system. Please note that it is not compatible with OpenCV 3.x at this time.

OSX

To install OpenCV on OSX using Homebrew:

$ brew tap homebrew/science && brew install opencv
Ubuntu

To install OpenCV on Ubuntu 14.04:

$ sudo apt-get install libopencv-dev

Or, follow the official OpenCV installation guide

Windows

Follow the official OpenCV installation guide

Now you can install the package with

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

How to Use

Example using the camera.

package main

import (
	cv "github.com/lazywei/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.Event("frame"), func(data interface{}) {
			window.ShowImage(data.(*cv.IplImage))
		})
	}

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

	gbot.AddRobot(robot)

	gbot.Start()
}

Documentation

Overview

Packge opencv contains the Gobot drivers for opencv.

Installing:

This package requires `opencv` to be installed on your system

Then you can install the package with:

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

Example:

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.Event("frame"), func(data interface{}) {
			window.ShowImage(data.(*cv.IplImage))
		})
	}

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

	gbot.AddRobot(robot)

	gbot.Start()
}

For further information refer to opencv README: https://github.com/hybridgroup/gobot/blob/master/platforms/opencv/README.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectFaces

func DetectFaces(haar string, image *cv.IplImage) []*cv.Rect

DetectFaces loads Haar cascade to detect face objects in image

func DrawRectangles

func DrawRectangles(image *cv.IplImage, rect []*cv.Rect, r int, g int, b int, thickness int) *cv.IplImage

DrawRectangles uses Rect array values to return image with rectangles drawn.

Types

type CameraDriver

type CameraDriver struct {
	Source interface{}

	gobot.Eventer
	// contains filtered or unexported fields
}

func NewCameraDriver

func NewCameraDriver(name string, source interface{}, v ...time.Duration) *CameraDriver

NewCameraDriver creates a new driver with specified name and source. It also creates a start function to either set camera as a File or Camera capture.

func (*CameraDriver) Connection

func (c *CameraDriver) Connection() gobot.Connection

func (*CameraDriver) Halt

func (c *CameraDriver) Halt() (errs []error)

Halt stops camera driver

func (*CameraDriver) Name

func (c *CameraDriver) Name() string

func (*CameraDriver) Start

func (c *CameraDriver) Start() (errs []error)

Start initializes camera by grabbing a frame every `interval` and publishing an frame event

type WindowDriver

type WindowDriver struct {
	// contains filtered or unexported fields
}

func NewWindowDriver

func NewWindowDriver(name string) *WindowDriver

NewWindowDriver creates a new window driver with specified name. It adds an start function to initialize window

func (*WindowDriver) Connection

func (w *WindowDriver) Connection() gobot.Connection

func (*WindowDriver) Halt

func (w *WindowDriver) Halt() (errs []error)

Halt returns true if camera is halted successfully

func (*WindowDriver) Name

func (w *WindowDriver) Name() string

func (*WindowDriver) ShowImage

func (w *WindowDriver) ShowImage(image *cv.IplImage)

ShowImage displays image in window

func (*WindowDriver) Start

func (w *WindowDriver) Start() (errs []error)

Start starts window thread and driver

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL