webcam

package
v0.0.0-...-b688cd4 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2019 License: BSD-2-Clause Imports: 7 Imported by: 0

README

webcam

This activity provides your flogo application the ability to take pictures with a USB connected Webcam. It is mandatory to specify the device Id, the image resolution as width and height and the compression factor. The image has a png format.

IMPORTANT
This activity uses the GoCV package that provides a binding for the OpenCV 4 computer vision library. Based on the specific OS, you need to install OpenCV 4 on your system, otherwise the activity will throw an exception.

The installation instructions can be found here: https://github.com/hybridgroup/gocv#how-to-install

Installation

flogo install activity github.com/achimera/flogo/activity/webcam

Schema

Settings and Outputs:

{
  "settings":[
    {
      "name": "deviceID",
      "type": "int",
      "required": true
	},
	{
      "name": "imageWidth",
      "type": "int",
      "required": true
	},
	{
      "name": "imageHeigth",
      "type": "int",
      "required": true
	},
	{
      "name": "compression",
      "type": "int",
      "allowed": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    }
  ],
  "outputs": [
    {
      "name": "image",
      "type": "[]byte"
	},
	{
      "name": "base64String",
      "type": "string"
    },
  	{
      "name": "status",
      "type": "string"
    }
  ]
}

Settings

Name Type Description
deviceID int The device id of the webcam. Usually the device id is 0 for onboard cameras
imageWidth int The resolution width of the image. Please check the resolutions that your webcam are supporting
imageHeigth int The resolution height of the image. Please check the resolutions that your webcam are supporting
compression int The compression factor of the png image. Value 0 is no compression, where 9 is the maximum compression and also the smallest size. Valid integer values are between 0 and 9. If not set or not in range, then the default compression of 3 is applied

Output

Name Type Description
image []byte The captured image is returned as a byte array. No Base64 encoding is done.
base64String string The captured image is returned as a Base64 encoded string.
status string The status of the operation. "OK" is returned when the webcam successfully captured an image

Configuration Example

		{
			"id": "webcam",
			"name": "Take a picture from a Webcam",
			"description": "Webcam Activity",
			"activity": {
				"ref": "github.com/achimera/flogo/activity/webcam",
				"settings": {
					"deviceID": "0",
					"imageWidth": "1024",
					"imageHeigth": "720",
					"compression": "10"
				}
			}
		}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

New create a new activity

Types

type Activity

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

Activity is a kafka activity

func (*Activity) Eval

func (act *Activity) Eval(ctx activity.Context) (done bool, err error)

Eval implements the evaluation of the kafka activity

func (*Activity) Metadata

func (*Activity) Metadata() *activity.Metadata

Metadata returns the metadata for the kafka activity

type Output

type Output struct {
	Image        []byte `md:"image"`        // The byte array containing the image
	Base64String string `md:"base64String"` // The Base64 encoded byte array returned as a string
	Status       string `md:"status"`       // Status of the webcam
}

func (*Output) FromMap

func (o *Output) FromMap(values map[string]interface{}) error

func (*Output) ToMap

func (o *Output) ToMap() map[string]interface{}

type Settings

type Settings struct {
	DeviceID    string `md:"deviceID, required"`                                 // The webcam deviceId
	ImageWidth  int    `md:"imageWidth, required"`                               // The image resolution width
	ImageHeigth int    `md:"imageHeigth, required"`                              // The image resolution heigth
	Compression int    `md:"compression, allowed(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)"` // The image compression factor
}

Jump to

Keyboard shortcuts

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