tagbox

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package tagbox provides a client for accessing Tagbox services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckResponse

type CheckResponse struct {
	// Tags are the standard tags returned
	Tags []Tag `json:"tags"`
	// CustomTags are the custom tags (previously teach) that match
	CustomTags []Tag `json:"custom_tags"`
}

CheckResponse is all the data from /check request to tagbox

type Client

type Client struct {

	// HTTPClient is the http.Client that will be used to
	// make requests.
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

Client is an HTTP client that can make requests to the box.

func New

func New(addr string) *Client

New makes a new Client for the box at the specified address.

func (*Client) Check

func (c *Client) Check(image io.Reader) (CheckResponse, error)

Check gets the tags for the image data provided.

func (*Client) CheckBase64

func (c *Client) CheckBase64(data string) (CheckResponse, error)

CheckBase64 gets the tags for the image in the encoded Base64 data string.

func (*Client) CheckURL

func (c *Client) CheckURL(imageURL *url.URL) (CheckResponse, error)

CheckURL gets the tags for the image at the specified URL.

func (*Client) Info

func (c *Client) Info() (*boxutil.Info, error)

Info gets the details about the box.

func (*Client) OpenState

func (c *Client) OpenState() (io.ReadCloser, error)

OpenState opens the state file for reading. Clients must call Close.

func (*Client) PostState

func (c *Client) PostState(r io.Reader) error

PostState uploads new state data.

func (*Client) PostStateURL

func (c *Client) PostStateURL(stateURL *url.URL) error

PostStateURL tells tagbox to download the state file specified by the URL.

func (*Client) Remove

func (c *Client) Remove(id string) error

Remove makes tagbox to forget an image

func (*Client) Rename

func (c *Client) Rename(id, tag string) error

Rename allows to change the custom tag for a given image by id

func (*Client) RenameAll

func (c *Client) RenameAll(oldTag, newTag string) error

RenameAll changes the tag for all the images

func (*Client) Similar

func (c *Client) Similar(image io.Reader) ([]Tag, error)

Similar checks the image in the io.Reader for similar images based on tags previously taught.

func (*Client) SimilarBase64

func (c *Client) SimilarBase64(data string) ([]Tag, error)

SimilarBase64 checks the image at the specified URL for similar images based on tags previously taught.

func (*Client) SimilarID

func (c *Client) SimilarID(id string) ([]Tag, error)

SimilarID returns similar images based on the ID provided

func (*Client) SimilarURL

func (c *Client) SimilarURL(imageURL *url.URL) ([]Tag, error)

SimilarURL checks the image at the specified URL for similar images based on tags previously taught.

func (*Client) Teach

func (c *Client) Teach(image io.Reader, id, tag string) error

Teach teaches tagbox the image with a custom tag in the io.Reader. The tag is the string representation of the main thing on the image. The id should be a unique identifier for the image, usually the filename.

func (*Client) TeachBase64

func (c *Client) TeachBase64(data, id, tag string) error

TeachBase64 teaches tagbox the Base64 encoded image with a custom tag. See Teach for more information.

func (*Client) TeachURL

func (c *Client) TeachURL(imageURL *url.URL, id, tag string) error

TeachURL teaches tagbox the image with a custom tag at the specified URL. See Teach for more information.

type ErrTagbox

type ErrTagbox string

ErrTagbox represents an error from Tagbox.

func (ErrTagbox) Error

func (e ErrTagbox) Error() string

type Tag

type Tag struct {
	// Tag is the tag string.
	Tag string
	// Confidence is a probability number between 0 and 1.
	Confidence float64
	// ID is unique identifier of the image, previosly teach
	ID string
}

Tag represents a single tag that describes an image.

Jump to

Keyboard shortcuts

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