gobot: gobot.io/x/gobot/platforms/opencv Index | Files

package opencv

import "gobot.io/x/gobot/platforms/opencv"

Package 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 gobot.io/x/gobot && go install gobot.io/x/gobot/platforms/opencv

Example:

package main

import (
	cv "gobot.io/x/go-opencv/opencv"
	"gobot.io/x/gobot"
	"gobot.io/x/gobot/platforms/opencv"
)

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

	work := func() {
		camera.On(camera.Event("frame"), func(data interface{}) {
			window.ShowImage(data.(*cv.IplImage))
		})
	}

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

	robot.Start()
}

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

Index

Package Files

camera_driver.go doc.go utils.go window_driver.go

Constants

const (
    // Frame event
    Frame = "frame"
)

func DetectObjects Uses

func DetectObjects(haar string, img gocv.Mat) []image.Rectangle

DetectObjects loads Haar cascade to detect face objects in image

func DrawRectangles Uses

func DrawRectangles(img gocv.Mat, rects []image.Rectangle, r int, g int, b int, thickness int)

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

type CameraDriver Uses

type CameraDriver struct {
    Source interface{}

    gobot.Eventer
    // contains filtered or unexported fields
}

CameraDriver is the Gobot Driver for the OpenCV camera

func NewCameraDriver Uses

func NewCameraDriver(source interface{}) *CameraDriver

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

func (*CameraDriver) Connection Uses

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

Connection returns the Driver's connection

func (*CameraDriver) Halt Uses

func (c *CameraDriver) Halt() (err error)

Halt stops camera driver

func (*CameraDriver) Name Uses

func (c *CameraDriver) Name() string

Name returns the Driver name

func (*CameraDriver) SetName Uses

func (c *CameraDriver) SetName(n string)

SetName sets the Driver name

func (*CameraDriver) Start Uses

func (c *CameraDriver) Start() (err error)

Start initializes camera by grabbing frames

type WindowDriver Uses

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

WindowDriver is the Gobot Driver for the OpenCV window

func NewWindowDriver Uses

func NewWindowDriver() *WindowDriver

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

func (*WindowDriver) Connection Uses

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

Connection returns the Driver's connection

func (*WindowDriver) Halt Uses

func (w *WindowDriver) Halt() (err error)

Halt returns true if camera is halted successfully

func (*WindowDriver) Name Uses

func (w *WindowDriver) Name() string

Name returns the Driver name

func (*WindowDriver) SetName Uses

func (w *WindowDriver) SetName(n string)

SetName sets the Driver name

func (*WindowDriver) ShowImage Uses

func (w *WindowDriver) ShowImage(img gocv.Mat)

ShowImage displays image in window

func (*WindowDriver) Start Uses

func (w *WindowDriver) Start() (err error)

Start starts window thread and driver

func (*WindowDriver) WaitKey Uses

func (w *WindowDriver) WaitKey(pause int) int

WaitKey gives window a chance to redraw, and checks for keyboard input

Package opencv imports 5 packages (graph) and is imported by 1 packages. Updated 2019-05-23. Refresh now. Tools for package owners.