gobotOpencv

package
v0.0.0-...-eb887f7 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2014 License: Apache-2.0, Apache-2.0 Imports: 2 Imported by: 0

README

Gobot for opencv

Gobot (http://gobot.io/) is a library for robotics and physical computing using Go

This repository contains the Gobot adaptor for opencv.

For more information about Gobot, check out the github repo at https://github.com/hybridgroup/gobot

Installing

go get github.com/hybridgroup/gobot-opencv

Using

package main

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

func main() {
	_, currentfile, _, _ := runtime.Caller(0)
	cascade := path.Join(path.Dir(currentfile), "haarcascade_frontalface_alt.xml")

	opencv := new(gobotOpencv.Opencv)
	opencv.Name = "opencv"

	window := gobotOpencv.NewWindow(opencv)
	window.Name = "window"

	camera := gobotOpencv.NewCamera(opencv)
	camera.Name = "camera"

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

		go func() {
			for {
				if image != nil {
					i := image.Clone()
					faces := gobotOpencv.DetectFaces(cascade, i)
					i = gobotOpencv.DrawRectangles(i, faces, 0, 255, 0, 5)
					window.ShowImage(i)
				}
			}
		}()
	}

	robot := gobot.Robot{
		Connections: []gobot.Connection{opencv},
		Devices:     []gobot.Device{window, camera},
		Work:        work,
	}

	robot.Start()
}

Installing OpenCV and Connecting

In order to use OpenCV you first need to install it and make sure it is working correctly on your computer. You can follow the tutorials in the OpenCV site to install it in your particular OS:

How to install OpenCV

Documentation

We're busy adding documentation to our web site at http://gobot.io/ please check there as we continue to work on Gobot

Thank you!

Contributing

  • All patches must be provided under the Apache 2.0 License
  • Please use the -s option in git to "sign off" that the commit is your work and you are providing it under the Apache 2.0 License
  • Submit a Github Pull Request to the appropriate branch and ideally discuss the changes with us in IRC.
  • We will look at the patch, test it out, and give you feedback.
  • Avoid doing minor whitespace changes, renamings, etc. along with merged content. These will be done by the maintainers from time to time but they can complicate merges and should be done seperately.
  • Take care to maintain the existing coding style.
  • Add unit tests for any new or changed functionality.
  • All pull requests should be "fast forward"
    • If there are commits after yours use “git rebase -i <new_head_branch>”
    • If you have local changes you may need to use “git stash”
    • For git help see progit which is an awesome (and free) book on git

License

Copyright (c) 2013-2014 The Hybrid Group. Licensed under the Apache 2.0 license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectFaces

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

func DrawRectangles

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

Types

type Camera

type Camera struct {
	gobot.Driver
	Adaptor *Opencv

	Source string
	// contains filtered or unexported fields
}

func NewCamera

func NewCamera(adaptor *Opencv) *Camera

func (*Camera) Halt

func (me *Camera) Halt() bool

func (*Camera) Init

func (me *Camera) Init() bool

func (*Camera) Start

func (me *Camera) Start() bool

type CameraInterface

type CameraInterface interface {
}

type Opencv

type Opencv struct {
	gobot.Adaptor
}

func (*Opencv) Connect

func (me *Opencv) Connect() bool

func (*Opencv) Disconnect

func (me *Opencv) Disconnect() bool

func (*Opencv) Finalize

func (me *Opencv) Finalize() bool

func (*Opencv) Reconnect

func (me *Opencv) Reconnect() bool

type Window

type Window struct {
	gobot.Driver
	Adaptor *Opencv
	// contains filtered or unexported fields
}

func NewWindow

func NewWindow(adaptor *Opencv) *Window

func (*Window) Halt

func (me *Window) Halt() bool

func (*Window) Init

func (me *Window) Init() bool

func (*Window) ShowImage

func (me *Window) ShowImage(image *opencv.IplImage)

func (*Window) Start

func (me *Window) Start() bool

type WindowInterface

type WindowInterface interface {
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳