opencv

package
v0.0.0-...-1595f01 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2014 License: Apache-2.0, Apache-2.0 Imports: 3 Imported by: 0

README

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.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 {
	gobot.Driver

	Source interface{}
	// contains filtered or unexported fields
}

func NewCameraDriver

func NewCameraDriver(name string, source interface{}) *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) Halt

func (c *CameraDriver) Halt() bool

Halt stops camera driver

func (*CameraDriver) Start

func (c *CameraDriver) Start() bool

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

type WindowDriver

type WindowDriver struct {
	gobot.Driver
	// 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) Halt

func (w *WindowDriver) Halt() bool

Halt returns true if camera is halted successfully

func (*WindowDriver) Init

func (w *WindowDriver) Init() bool

Init returns true if driver is initialized correctly

func (*WindowDriver) ShowImage

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

ShowImage displays image in window

func (*WindowDriver) Start

func (w *WindowDriver) Start() bool

Start starts window thread and driver

Jump to

Keyboard shortcuts

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