machinebox

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package machinebox contains the HTTP server for machinebox services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(
	facebox Facebox,
) *remotohttp.Server

New makes a new remotohttp.Server with the specified services registered.

func RegisterFaceboxServer

func RegisterFaceboxServer(server *remotohttp.Server, service Facebox)

RegisterFaceboxServer registers a Facebox with a remotohttp.Server.

func Run

func Run(addr string,
	facebox Facebox,
) error

Run is the simplest way to run the services.

Types

type CheckFaceprintRequest

type CheckFaceprintRequest struct {

	// Faceprints is a list of Faceprints to check.
	Faceprints []string `json:"faceprints"`
}

CheckFaceprintRequest is the request object for CheckFaceprint calls.

type CheckFaceprintResponse

type CheckFaceprintResponse struct {

	// Faces is a list of faces checked from Faceprints.
	Faces []FaceprintFace `json:"faces"`

	// Error is an error message if one occurred.
	Error string `json:"error"`
}

CheckFaceprintResponse is the response object for CheckFaceprint calls.

type CheckFileRequest

type CheckFileRequest struct {

	// File is the image to check for faces.
	File remototypes.File `json:"file"`
}

CheckFileRequest is the request object for CheckFile calls.

type CheckFileResponse

type CheckFileResponse struct {

	// Faces is a list of faces that were found.
	Faces []Face `json:"faces"`

	// Error is an error message if one occurred.
	Error string `json:"error"`
}

CheckFileResponse is the response object for CheckFile calls.

type CheckURLRequest

type CheckURLRequest struct {

	// URL is the address of the image to check.
	URL string `json:"url"`
}

CheckURLRequest is the request object for CheckURL calls.

type CheckURLResponse

type CheckURLResponse struct {

	// Faces is a list of faces that were found.
	Faces []Face `json:"faces"`

	// Error is an error message if one occurred.
	Error string `json:"error"`
}

CheckURLResponse is the response object for CheckURL calls.

type Face

type Face struct {

	// ID is the identifier of the source that was matched.
	ID string `json:"id"`

	// Name is the name of the identified person.
	Name string `json:"name"`

	// Matched is whether the face was recognized or not.
	Matched bool `json:"matched"`

	// Faceprint is the Facebox Faceprint of this face.
	Faceprint string `json:"faceprint"`

	// Rect is where the face appears in the source image.
	Rect Rect `json:"rect"`
}

Face describes a face.

type Facebox

type Facebox interface {

	// CheckFaceprint checks to see if a Faceprint matches any known
	// faces.
	CheckFaceprint(context.Context, *CheckFaceprintRequest) (*CheckFaceprintResponse, error)

	// CheckFile checks an image file for faces.
	CheckFile(context.Context, *CheckFileRequest) (*CheckFileResponse, error)

	// CheckURL checks a hosted image file for faces.
	CheckURL(context.Context, *CheckURLRequest) (*CheckURLResponse, error)

	// FaceprintCompare compares faceprints to a specified target describing
	// similarity.
	FaceprintCompare(context.Context, *FaceprintCompareRequest) (*FaceprintCompareResponse, error)

	// GetState gets the Facebox state file.
	GetState(context.Context, *GetStateRequest) (*remototypes.FileResponse, error)

	// PutState sets the Facebox state file.
	PutState(context.Context, *PutStateRequest) (*PutStateResponse, error)

	// RemoveID removes a face with the specified ID.
	RemoveID(context.Context, *RemoveIDRequest) (*RemoveIDResponse, error)

	// Rename changes a person's name.
	Rename(context.Context, *RenameRequest) (*RenameResponse, error)

	// RenameID changes the name of a previously taught face, by ID.
	RenameID(context.Context, *RenameIDRequest) (*RenameIDResponse, error)

	// SimilarFile checks for similar faces from the face in an image file.
	SimilarFile(context.Context, *SimilarFileRequest) (*SimilarFileResponse, error)

	// SimilarID checks for similar faces by ID.
	SimilarID(context.Context, *SimilarIDRequest) (*SimilarIDResponse, error)

	// SimilarURL checks for similar faces in a hosted image file.
	SimilarURL(context.Context, *SimilarURLRequest) (*SimilarURLResponse, error)

	// TeachFaceprint teaches Facebox about a face from a Faceprint.
	TeachFaceprint(context.Context, *TeachFaceprintRequest) (*TeachFaceprintResponse, error)

	// TeachFile teaches Facebox a new face from an image file.
	TeachFile(context.Context, *TeachFileRequest) (*TeachFileResponse, error)

	// TeachURL teaches Facebox a new face from an image on the web.
	TeachURL(context.Context, *TeachURLRequest) (*TeachURLResponse, error)
}

Facebox provides facial detection and recognition in images.

type FaceprintCompareRequest

type FaceprintCompareRequest struct {

	// Target is the target Faceprint to which the Faceprints will be compared.
	Target string `json:"target"`

	// Faceprints is a list of Faceprints that will be compared to Target.
	Faceprints []string `json:"faceprints"`
}

FaceprintCompareRequest is the request object for FaceprintCompare calls.

type FaceprintCompareResponse

type FaceprintCompareResponse struct {

	// Confidences is a list of confidence values.
	// The order matches the order of FaceprintCompareRequest.Faceprints.
	Confidences []float64 `json:"confidences"`

	// Error is an error message if one occurred.
	Error string `json:"error"`
}

FaceprintCompareResponse is the response object for FaceprintCompare calls.

type FaceprintFace

type FaceprintFace struct {

	// Matched is whether the face was recognized or not.
	Matched bool `json:"matched"`

	// Confidence is a numerical value of how confident the AI
	// is that this is a match.
	Confidence float64 `json:"confidence"`

	// ID is the identifier of the source that matched.
	ID string `json:"id"`

	// Name is the name of the person recognized.
	Name string `json:"name"`
}

FaceprintFace is a face.

type GetStateRequest

type GetStateRequest struct {
}

GetStateRequest is the request object for GetState calls.

type PutStateRequest

type PutStateRequest struct {

	// StateFile is the Facebox state file to set.
	StateFile remototypes.File `json:"state_file"`
}

PutStateRequest is the request object for PutState calls.

type PutStateResponse

type PutStateResponse struct {

	// Error is an error message if one occurred.
	Error string `json:"error"`
}

PutStateResponse is the response object for PutState calls.

type Rect

type Rect struct {

	// Top is the starting Y coordinate.
	Top int `json:"top"`

	// Left is the starting X coordinate.
	Left int `json:"left"`

	// Width is the width.
	Width int `json:"width"`

	// Height is the height.
	Height int `json:"height"`
}

Rect is a bounding box describing a rectangle of an image.

type RemoveIDRequest

type RemoveIDRequest struct {

	// ID is the identifier of the source to remove.
	ID string `json:"id"`
}

RemoveIDRequest is the request object for RemoveID calls.

type RemoveIDResponse

type RemoveIDResponse struct {

	// Error is an error message if one occurred.
	Error string `json:"error"`
}

RemoveIDResponse is the response object for RemoveID calls.

type RenameIDRequest

type RenameIDRequest struct {

	// ID is the identifier of the source to rename.
	ID string `json:"id"`

	// Name is the new name to assign to the item matching ID.
	Name string `json:"name"`
}

RenameIDRequest is the request object for RenameID calls.

type RenameIDResponse

type RenameIDResponse struct {

	// Error is an error message if one occurred.
	Error string `json:"error"`
}

RenameIDResponse is the response object for RenameID calls.

type RenameRequest

type RenameRequest struct {

	// From is the original name.
	From string `json:"from"`

	// To is the new name.
	To string `json:"to"`
}

RenameRequest is the request object for Rename calls.

type RenameResponse

type RenameResponse struct {

	// Error is an error message if one occurred.
	Error string `json:"error"`
}

RenameResponse is the response object for Rename calls.

type SimilarFace

type SimilarFace struct {

	// Rect is where the face appears in the image.
	Rect Rect `json:"rect"`

	// SimilarFaces is a list of similar faces.
	SimilarFaces []Face `json:"similar_faces"`
}

SimilarFace is a detected face with similar matching faces.

type SimilarFileRequest

type SimilarFileRequest struct {
	File remototypes.File `json:"file"`
}

SimilarFileRequest is the request object for SimilarFile calls.

type SimilarFileResponse

type SimilarFileResponse struct {
	Faces []SimilarFace `json:"faces"`

	// Error is an error message if one occurred.
	Error string `json:"error"`
}

SimilarFileResponse is the response object for SimilarFile calls.

type SimilarIDRequest

type SimilarIDRequest struct {

	// ID is the identifier of the source to look for similar faces of.
	ID string `json:"id"`
}

SimilarIDRequest is the request object for SimilarID calls.

type SimilarIDResponse

type SimilarIDResponse struct {

	// Faces is a list of similar faces.
	Faces []SimilarFace `json:"faces"`

	// Error is an error message if one occurred.
	Error string `json:"error"`
}

SimilarIDResponse is the response object for SimilarID calls.

type SimilarURLRequest

type SimilarURLRequest struct {
	URL string `json:"url"`
}

SimilarURLRequest is the request object for SimilarURL calls.

type SimilarURLResponse

type SimilarURLResponse struct {
	Faces []SimilarFace `json:"faces"`

	// Error is an error message if one occurred.
	Error string `json:"error"`
}

SimilarURLResponse is the response object for SimilarURL calls.

type TeachFaceprintRequest

type TeachFaceprintRequest struct {
	ID string `json:"id"`

	Name string `json:"name"`

	Faceprint string `json:"faceprint"`
}

TeachFaceprintRequest is the request object for TeachFaceprint calls.

type TeachFaceprintResponse

type TeachFaceprintResponse struct {

	// Error is an error message if one occurred.
	Error string `json:"error"`
}

TeachFaceprintResponse is the response object for TeachFaceprint calls.

type TeachFileRequest

type TeachFileRequest struct {

	// ID is an identifier describing the source, for example the filename.
	ID string `json:"id"`

	// Name is the name of the person in the image.
	Name string `json:"name"`

	// File is the image containing the face to teach.
	File remototypes.File `json:"file"`
}

TeachFileRequest is the request object for TeachFile calls.

type TeachFileResponse

type TeachFileResponse struct {

	// Error is an error message if one occurred.
	Error string `json:"error"`
}

TeachFileResponse is the response object for TeachFile calls.

type TeachURLRequest

type TeachURLRequest struct {

	// ID is an identifier describing the source, for example the filename.
	ID string `json:"id"`

	// Name is the name of the person in the image.
	Name string `json:"name"`

	// URL is the address of the image.
	URL string `json:"url"`
}

TeachURLRequest is the request object for TeachURL calls.

type TeachURLResponse

type TeachURLResponse struct {

	// Error is an error message if one occurred.
	Error string `json:"error"`
}

TeachURLResponse is the response object for TeachURL calls.

Jump to

Keyboard shortcuts

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