import "gobot.io/x/gobot/platforms/opencv"
Package opencv contains the Gobot drivers for opencv.
Installing:
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
camera_driver.go doc.go utils.go window_driver.go
const ( // Frame event Frame = "frame" )
DetectObjects loads Haar cascade to detect face objects in image
DrawRectangles uses Rect array values to return image with rectangles drawn.
type CameraDriver struct { Source interface{} gobot.Eventer // contains filtered or unexported fields }
CameraDriver is the Gobot Driver for the OpenCV camera
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 (c *CameraDriver) Connection() gobot.Connection
Connection returns the Driver's connection
func (c *CameraDriver) Halt() (err error)
Halt stops camera driver
func (c *CameraDriver) Name() string
Name returns the Driver name
func (c *CameraDriver) SetName(n string)
SetName sets the Driver name
func (c *CameraDriver) Start() (err error)
Start initializes camera by grabbing frames
type WindowDriver struct {
// contains filtered or unexported fields
}
WindowDriver is the Gobot Driver for the OpenCV window
func NewWindowDriver() *WindowDriver
NewWindowDriver creates a new window driver. It adds an start function to initialize window
func (w *WindowDriver) Connection() gobot.Connection
Connection returns the Driver's connection
func (w *WindowDriver) Halt() (err error)
Halt returns true if camera is halted successfully
func (w *WindowDriver) Name() string
Name returns the Driver name
func (w *WindowDriver) SetName(n string)
SetName sets the Driver name
func (w *WindowDriver) ShowImage(img gocv.Mat)
ShowImage displays image in window
func (w *WindowDriver) Start() (err error)
Start starts window thread and driver
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 3 packages. Updated 2019-05-23. Refresh now. Tools for package owners.