visualrecognition

package
v0.0.0-...-ed9fe1d Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2018 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package visualrecognition provides types and functions for IBM Watson Visual Recognition API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Age

type Age struct {
	Max   int     `json:"max"`
	Min   int     `json:"min"`
	Score float64 `json:"score"`
}

Age is a detected age range with a score.

type Class

type Class struct {
	Class string `json:"class"`
}

Class is a class of classifiers on Watson.

type ClassScore

type ClassScore struct {
	Class string  `json:"class"`
	Score float64 `json:"score"`
}

type ClassifiedImage

type ClassifiedImage struct {
	Classifiers []*ClassifiedResult `json:"classifiers,omitempty"`
	Image       string              `json:"image"`
}

type ClassifiedResult

type ClassifiedResult struct {
	Classes      []*ClassScore `json:"classes"`
	ClassifierID string        `json:"classifier_id"`
	Name         string        `json:"name"`
}

type Classifier

type Classifier struct {
	ClassifierID string    `json:"classifier_id"`
	Name         string    `json:"name"`
	Owner        string    `json:"owner"`
	Status       Status    `json:"status"`
	Created      time.Time `json:"created"`
	Explanation  string    `json:"explanation"`
	Classes      []*Class  `json:"classes"`
}

Classifier represents a classifier on Watson

type ClassifierListResponse

type ClassifierListResponse struct {
	Classifiers []*Classifier `json:"classifiers"`
}

ClassifierListResponse is a object returned by ListClassifiers function.

type ClassifyParams

type ClassifyParams struct {
	ClassifierIDs []string `json:"classifier_ids"`
	Threshold     float64  `json:"threshold"`
}

type ClassifyResponse

type ClassifyResponse struct {
	Images         []*ClassifiedImage `json:"images,omitempty"`
	ImageProcessed int                `json:"image_processed"`
}

ClassifyResponse is a object returned by Datect* functions

type Client

type Client struct {
	APIKey   string
	Version  string
	Endpoint string
	// contains filtered or unexported fields
}

Client is an API client to access IBM Watson Visual Recognition API

func NewClient

func NewClient(apiKey string, client *http.Client) *Client

func (*Client) ClassifyImages

func (c *Client) ClassifyImages(ctx context.Context, source *xzip.Archiver, params *ClassifyParams) (*ClassifyResponse, error)

ClassifyImages make a POST request to /v3/classify endpoint with the `images_file` parameter.

func (*Client) ClassifyURL

func (c *Client) ClassifyURL(ctx context.Context, url string, params *ClassifyParams) (*ClassifyResponse, error)

ClassifyURL make a GET request to /v3/classify endpoint with the `url` parameter.

func (*Client) CreateClassifier

func (c *Client) CreateClassifier(ctx context.Context, name string, positives map[string]*xzip.Archiver, negative *xzip.Archiver) (*Classifier, error)

CreateClassifier makes a POST request to '/v3/classifiers' endpoint with the *_positive_examples files. the source map should be a map from class name to *xzip.Archiver so that `{class}_positive_examples` are registered. A class name "negative" is registered as "negative_examples"

func (*Client) DeleteClassifier

func (c *Client) DeleteClassifier(ctx context.Context, id string) (bool, error)

DeleteClassifier makes a DELETE request to '/v3/classifiers/{id}` endpoint.

func (*Client) DetectFacesOnImages

func (c *Client) DetectFacesOnImages(ctx context.Context, source *xzip.Archiver) (*FaceDetectResponse, error)

DetectFacesOnImages makes a POST request to `/v3/detect_faces“ with a zipped image file given by sources.

func (*Client) DetectFacesOnURL

func (c *Client) DetectFacesOnURL(ctx context.Context, url string) (*FaceDetectResponse, error)

DetectFacesOnURL make a GET request to `/v3/detect_faces“ with the `url` parameter.

func (*Client) GetClassifier

func (c *Client) GetClassifier(ctx context.Context, id string) (*Classifier, error)

GetClassifier makes a GET request to '/v3/classifiers/{id}“ endpoint.

func (*Client) ListClassifiers

func (c *Client) ListClassifiers(ctx context.Context, verbose bool) (*ClassifierListResponse, error)

ListClassifiers makes a GET request to '/v3/classifiers' endpoint

func (*Client) UpdateClassifier

func (c *Client) UpdateClassifier(ctx context.Context, id string, positives map[string]*xzip.Archiver, negative *xzip.Archiver) (*Classifier, error)

UpdateClassifier makes a POST request to '/v3/classifiers/{classifier_id}' endpoint with the *_positive_examples files. the source map should be a map from class name to *xzip.Archiver so that `{class}_positive_examples` are registered. A class name "negative" is registered as "negative_examples"

type ErrorResponse

type ErrorResponse struct {
	Err  string `json:"error"`
	Code int    `json:"code"`
}

func (*ErrorResponse) Error

func (er *ErrorResponse) Error() string

type Face

type Face struct {
	Age          *Age          `json:"age,omitempty"`
	FaceLocation *FaceLocation `json:"face_location,omitempty"`
	Gender       *Gender       `json:"gender,omitempty"`
	Identity     *Identity     `json:"identity,omitempty"`
}

Face is face info detected by watson.

type FaceDetectResponse

type FaceDetectResponse struct {
	Images         []*FaceImage `json:"images,omitempty"`
	ImageProcessed int          `json:"image_processed"`
}

FaceDetectResponse is a object returned by Datect* functions.

type FaceImage

type FaceImage struct {
	Faces       []*Face `json:"faces,omitempty"`
	Image       string  `json:"image,omitempty"`
	SourceURL   string  `json:"source_url,omitempty"`
	ResolvedURL string  `json:"resolved_url,omitempty"`
}

FaceImage is detected faces info on a image.

type FaceLocation

type FaceLocation struct {
	Width  int64 `json:"width"`
	Height int64 `json:"height"`
	Left   int64 `json:"left"`
	Top    int64 `json:"top"`
}

FaceLocation is a detected location of a face.

type Gender

type Gender struct {
	Gender string  `json:"gender"`
	Score  float64 `json:"score"`
}

Gender is a detected gender with a score.

type Identity

type Identity struct {
	Name          string  `json:"name"`
	Score         float64 `json:"score"`
	TypeHierarchy string  `json:"type_hierarchy"`
}

Identity is a detected identity with a score.

type Status

type Status string

Status is a type alias to represent classifier status string.

const (
	StatusAvailable   Status = "available"
	StatusReady       Status = "ready"
	StatusUnavailable Status = "unavailable"
	StatusFailed      Status = "failed"
)

Available (known) values of ClassifierStatus.

Jump to

Keyboard shortcuts

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