opencv

package module
v0.0.0-...-81af635 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2016 License: MIT Imports: 9 Imported by: 0

README

OpenCV plug-in for SensorBee

This plug-in is a library to use OpenCV library, User can use a part of OpenCV functions. For example user can create source component to generate stream video capturing.

Require

  • OpenCV
    • attention that ffmpeg version.
    • ex) Mac OS X brew install opencv --with-ffmpeg
  • SensorBee
    • later v0.5

Usage

Registering plug-in

build_sensorbee with build.yaml set gopkg.in/sensorbee/opencv.v0/plugin

build.yaml
plugins:
- gopkg.in/sensorbee/opencv.v0/plugin

Using from BQLs sample

Capturing video source and streaming frames
-- capturing
CREATE PAUSED SOURCE camera1_avi TYPE opencv_capture_from_uri WITH
    uri="video/camera1.avi",
    frame_skip=4, next_frame_error=false;

will start generating stream from "video/camera1.avi" after execute RESUME query.

RESUME SOURCE camera1_avi;

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectMultiScale

func DetectMultiScale(ctx *core.Context, classifierName string, img data.Map) (
	data.Array, error)

DetectMultiScale classifies and detect image.

classifierName: cascadeClassifier state name.

img: target image as RawData map structure.

func DrawRectsToImage

func DrawRectsToImage(img data.Map, rects data.Array) (data.Map, error)

DrawRectsToImage draws rectangle information on target image. The image is required to structured as RawData.

func MountAlphaImage

func MountAlphaImage(ctx *core.Context, imgName string, back data.Map,
	rects data.Array) (data.Map, error)

MountAlphaImage draw target image on back image.

func NewCascadeClassifier

func NewCascadeClassifier(ctx *core.Context, params data.Map) (core.SharedState,
	error)

NewCascadeClassifier returns cascadeClassifier state.

file: cascade configuration file path for detection. e.g. "haarcascade_frontalface_default.xml".

func NewSharedImage

func NewSharedImage(ctx *core.Context, params data.Map) (core.SharedState, error)

NewSharedImage returns shared image file to reduce I/O cost.

Types

type FromDeviceCreator

type FromDeviceCreator struct{}

FromDeviceCreator is a creator of a capture from device.

func (*FromDeviceCreator) CreateSource

func (c *FromDeviceCreator) CreateSource(ctx *core.Context, ioParams *bql.IOParams,
	params data.Map) (core.Source, error)

CreateSource creates a frame generator using OpenCV video capture (`VideoCapture::open`).

WITH parameters.

device_id: [required] The ID of associated device.

format: Output format style, default is "cvmat".

width: Frame width, if set empty or "0" then will be ignore.

height: Frame height, if set empty or "0" then will be ignore.

fps: Frame per second, if set empty or "0" then will be ignore.

type FromURICreator

type FromURICreator struct{}

FromURICreator is a creator of a capture from URI.

func (*FromURICreator) CreateSource

func (c *FromURICreator) CreateSource(ctx *core.Context,
	ioParams *bql.IOParams, params data.Map) (core.Source, error)

CreateSource creates a frame generator using OpenCV video capture. URI can be set HTTP address or file path.

WITH parameters.

uri: [required] A capture data's URI (e.g. /data/test.avi).

format: Output format style, default is "cvmat".

frame_skip: The number of frame skip, if set empty or "0" then read all frames. FPS is depended on the URI's file (or device).

next_frame_error: When this source cannot read a new frame, occur error or not decided by the flag. If the flag set `true` then return error. Default value is true.

rewind: If set `true` then user can use `REWIND SOURCE` query.

type RawData

type RawData struct {
	Format TypeImageFormat
	Width  int
	Height int
	Data   []byte
}

RawData is represented of `cv::Mat_<cv::Vec3b>` structure.

func ConvertMapToRawData

func ConvertMapToRawData(dm data.Map) (RawData, error)

ConvertMapToRawData returns RawData from data.Map. This function is utility method for other plug-in.

func ToRawData

func ToRawData(m bridge.MatVec3b) RawData

ToRawData converts MatVec3b to RawData.

func (*RawData) ConvertToDataMap

func (r *RawData) ConvertToDataMap() data.Map

ConvertToDataMap returns data.map. This function is utility method for other plug-in.

func (*RawData) ToJpegData

func (r *RawData) ToJpegData(quality int) ([]byte, error)

ToJpegData convert JPGE format image bytes.

func (*RawData) ToMatVec3b

func (r *RawData) ToMatVec3b() (bridge.MatVec3b, error)

ToMatVec3b converts RawData to MatVec3b. Returned MatVec3b is required to delete after using.

type TypeImageFormat

type TypeImageFormat int

TypeImageFormat is an ID of image format type.

const (

	// TypeCVMAT is OpenCV cv::Mat_<cv::Vec3b> format
	TypeCVMAT TypeImageFormat
	// TypeCVMAT4b is OpenCV cv::Mat_<cv::Vec4b> format
	TypeCVMAT4b
	// TypeJPEG is JPEG format
	TypeJPEG
)

func GetTypeImageFormat

func GetTypeImageFormat(str string) TypeImageFormat

GetTypeImageFormat returns image format type.

func (TypeImageFormat) String

func (t TypeImageFormat) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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