vision

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const (
	LikelihoodTextUnknown      = "UNKNOWN"
	LikelihoodTextVeryUnlikely = "VERY_UNLIKELY"
	LikelihoodTextUnlikely     = "UNLIKELY"
	LikelihoodTextPossible     = "POSSIBLE"
	LikelihoodTextLikely       = "LIKELY"
	LikelihoodTextVeryLikely   = "VERY_LIKELY"
)

Likelihood list of string result.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block added in v0.3.3

type Block struct {
	TextProperty
	BlockType  string
	Confidence float64
	Paragraphs []Paragraph
	Vertices   []Vertex
}

Block is wrapper struct for SDK.Block.

func NewBlock added in v0.3.3

func NewBlock(b *SDK.Block) Block

NewBlock creates Block from SDK.Block.

type Break added in v0.3.3

type Break struct {
	IsPrefix bool
	Type     string
}

Break is wrapper struct for SDK.DetectedBreak.

func NewBreak added in v0.3.3

func NewBreak(b *SDK.DetectedBreak) Break

NewBreak creates Break from SDK.DetectedBreak.

type CropEntity added in v0.3.3

type CropEntity struct {
	Hints []CropHint
}

CropEntity contains result of Crop Hints.

func NewCropEntity added in v0.3.3

func NewCropEntity(anno *SDK.CropHintsAnnotation) CropEntity

NewCropEntity creates CropEntity from result of Web Detection.

type CropHint added in v0.3.3

type CropHint struct {
	Vertices           []Vertex
	Confidence         float64
	ImportanceFraction float64
}

CropHint is wrapper struct for SDK.CropHint.

func NewCropHint added in v0.3.3

func NewCropHint(h *SDK.CropHint) CropHint

NewCropHint creates CropHint from SDK.CropHint.

type DocumentEntity added in v0.3.3

type DocumentEntity struct {
	Text  string
	Pages []Page
}

DocumentEntity contains result of Crop Hints.

func NewDocumentEntity added in v0.3.3

func NewDocumentEntity(anno *SDK.TextAnnotation) DocumentEntity

NewDocumentEntity creates DocumentEntity from result of Web Detection.

type Entity

type Entity struct {
	Description string
	Score       float64
	// for Web
	EntityID string
}

Entity contains general result of response.

type FeatureType

type FeatureType string

FeatureType is type for feature.

const (
	FeatureUnspecified FeatureType = "TYPE_UNSPECIFIED"
	FeatureFace        FeatureType = "FACE_DETECTION"
	FeatureLandmark    FeatureType = "LANDMARK_DETECTION"
	FeatureLabel       FeatureType = "LABEL_DETECTION"
	FeatureText        FeatureType = "TEXT_DETECTION"
	FeatureDocument    FeatureType = "DOCUMENT_TEXT_DETECTION"
	FeatureSafe        FeatureType = "SAFE_SEARCH_DETECTION"
	FeatureProperties  FeatureType = "IMAGE_PROPERTIES"
	FeatureCrop        FeatureType = "CROP_HINTS"
	FeatureWeb         FeatureType = "WEB_DETECTION"
)

FeatureType list

func (FeatureType) Feature

func (f FeatureType) Feature(max int64) *SDK.Feature

Feature creates *SDK.Feature.

func (FeatureType) String

func (f FeatureType) String() string

type Language added in v0.3.3

type Language struct {
	Confidence   float64
	LanguageCode string
}

Language is wrapper struct for SDK.Language.

func NewLanguage added in v0.3.3

func NewLanguage(l *SDK.DetectedLanguage) Language

NewLanguage creates Language from SDK.Language.

type Likelihood

type Likelihood int

Likelihood is likelihood of detection result.

const (
	LikelihoodError Likelihood = iota
	LikelihoodUnknown
	LikelihoodVeryUnlikely
	LikelihoodUnlikely
	LikelihoodPossible
	LikelihoodLikely
	LikelihoodVeryLikely
)

Likelihood list.

func NewLikelihood

func NewLikelihood(s string) Likelihood

NewLikelihood creates Likelihood.

func (Likelihood) IsError

func (l Likelihood) IsError() bool

IsError checks if Likelifood is error.

func (Likelihood) Likely

func (l Likelihood) Likely() bool

Likely checks if Likelifood is more than Likely.

func (Likelihood) Possible

func (l Likelihood) Possible() bool

Possible checks if Likelifood is more than Possible.

func (Likelihood) String

func (l Likelihood) String() string

func (Likelihood) Unknown

func (l Likelihood) Unknown() bool

Unknown checks if Likelifood is more than Unknown.

func (Likelihood) Unlikely

func (l Likelihood) Unlikely() bool

Unlikely checks if Likelifood is more than Unlikely.

func (Likelihood) VeryLikely

func (l Likelihood) VeryLikely() bool

VeryLikely checks if Likelifood is more than VeryLikely.

func (Likelihood) VeryUnlikely

func (l Likelihood) VeryUnlikely() bool

VeryUnlikely checks if Likelifood is more than VeryUnlikely.

type Page added in v0.3.3

type Page struct {
	TextProperty
	Blocks     []Block
	Confidence float64
	Height     int64
	Width      int64
}

Page is wrapper struct for SDK.Page.

func NewPage added in v0.3.3

func NewPage(p *SDK.Page) Page

NewPage creates Page from SDK.Page.

type Paragraph added in v0.3.3

type Paragraph struct {
	TextProperty
	Confidence float64
	Vertices   []Vertex
	Words      []Word
}

Paragraph is wrapper struct for SDK.Paragraph.

func NewParagraph added in v0.3.3

func NewParagraph(p *SDK.Paragraph) Paragraph

NewParagraph creates Paragraph from SDK.Paragraph.

type Resource

type Resource struct {
	Image        []byte
	ImageList    [][]byte
	ImageURL     string
	ImageURLList []string
	IsBase64     bool
	Type         FeatureType
	TypeList     []FeatureType
	MaxResults   int64

	// options
	LanguageHints []string
}

Resource is parameter struct for Annotate.

type Response

type Response struct {
	*SDK.BatchAnnotateImagesResponse
}

Response contains response from Annotate API.

func (*Response) CropResult added in v0.3.3

func (r *Response) CropResult() []CropEntity

CropResult returns all of data from crop hints results.

func (*Response) DocumentResult added in v0.3.3

func (r *Response) DocumentResult() []DocumentEntity

DocumentResult returns all of full text from OCR results.

func (*Response) FaceResult

func (r *Response) FaceResult() []float64

FaceResult returns all of detection score(0-1) from face detection results.

func (*Response) LabelResult

func (r *Response) LabelResult() []Entity

LabelResult returns all of scores from label detection results.

func (*Response) LandmarkResult

func (r *Response) LandmarkResult() []Entity

LandmarkResult returns all of scores from landmark detection results.

func (*Response) Len

func (r *Response) Len() int

Len returns size of response. This coinsides the number of images in request.

func (*Response) LogoResult

func (r *Response) LogoResult() []Entity

LogoResult returns all of scores from logo detection results.

func (*Response) SafeResult

func (r *Response) SafeResult() []SafeEntity

SafeResult returns all of text from safe-search results.

func (*Response) TextResult

func (r *Response) TextResult() []string

TextResult returns all of text from OCR results.

func (*Response) WebResult added in v0.3.3

func (r *Response) WebResult() []WebEntity

WebResult returns all of data from Web Detection results.

type SafeEntity

type SafeEntity struct {
	Adult    Likelihood
	Spoof    Likelihood
	Medical  Likelihood
	Violence Likelihood
}

SafeEntity contains result of SafeSearch.

func NewSafeEntity

func NewSafeEntity(anno *SDK.SafeSearchAnnotation) SafeEntity

NewSafeEntity creates SafeEntity from result of SafeSearchAnnotation.

type Symbol added in v0.3.3

type Symbol struct {
	TextProperty
	Text       string
	Confidence float64
	Vertices   []Vertex
}

Symbol is wrapper struct for SDK.Symbol.

func NewSymbol added in v0.3.3

func NewSymbol(s *SDK.Symbol) Symbol

NewSymbol creates Symbol from SDK.Symbol.

type TextProperty added in v0.3.3

type TextProperty struct {
	Break     Break
	Languages []Language
}

TextProperty is wrapper struct for SDK.TextProperty.

func NewTextProperty added in v0.3.3

func NewTextProperty(p *SDK.TextProperty) TextProperty

NewTextProperty creates TextProperty from SDK.TextProperty.

type Vertex added in v0.3.3

type Vertex struct {
	X int64
	Y int64
}

Vertex has a 2D point in the image.

func NewVertices added in v0.3.3

func NewVertices(p *SDK.BoundingPoly) []Vertex

NewVertices creates []Vertex from *SDK.BoundingPoly.

type Vision

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

Vision repesents Cloud Vision API client.

func New

func New(conf config.Config) (*Vision, error)

New returns initialized *Vision.

func (*Vision) Crop added in v0.3.3

func (v *Vision) Crop(image []byte) (*Response, error)

Crop sends image to API and detects crop hints feature type.

func (*Vision) Document added in v0.3.3

func (v *Vision) Document(image []byte) (*Response, error)

Document sends image to API and detects document OCR feature type.

func (*Vision) Errorf

func (v *Vision) Errorf(format string, vv ...interface{})

Errorf logging error information.

func (*Vision) Face

func (v *Vision) Face(image []byte) (*Response, error)

Face sends image to API and detects face feature type.

func (*Vision) Get

func (v *Vision) Get(r *Resource) (*Response, error)

Get executes Images.Annotate operation with parameters of Resource.

func (*Vision) GetFromByte

func (v *Vision) GetFromByte(image []byte) (*Response, error)

GetFromByte sends image to API and detects all of feature types.

func (*Vision) Label

func (v *Vision) Label(image []byte) (*Response, error)

Label sends image to API and detects label feature type.

func (*Vision) Landmark

func (v *Vision) Landmark(image []byte) (*Response, error)

Landmark sends image to API and detects landmark feature type.

func (v *Vision) Logo(image []byte) (*Response, error)

Logo sends image to API and detects logo feature type.

func (*Vision) Properties

func (v *Vision) Properties(image []byte) (*Response, error)

Properties sends image to API and detects propaties of images.

func (*Vision) Safe

func (v *Vision) Safe(image []byte) (*Response, error)

Safe sends image to API and detects safe-search feature type.

func (*Vision) SetLogger added in v0.5.0

func (v *Vision) SetLogger(logger log.Logger)

SetLogger sets internal API logger.

func (*Vision) Text

func (v *Vision) Text(image []byte) (*Response, error)

Text sends image to API and detects OCR feature type.

func (*Vision) Web added in v0.3.3

func (v *Vision) Web(image []byte) (*Response, error)

Web sends image to API and detects web document feature type.

type WebEntity added in v0.3.3

type WebEntity struct {
	Labels                []WebLabel
	FullMatchingImages    []string // URL
	PartialMatchingImages []string
	VisuallySimilarImages []string
	Entities              []Entity
	Pages                 []WebPage
}

WebEntity contains result of Web Detection.

func NewWebEntity added in v0.3.3

func NewWebEntity(anno *SDK.WebDetection) WebEntity

NewWebEntity creates WebEntity from result of Web Detection.

func (WebEntity) GetMatchingURL added in v0.3.3

func (e WebEntity) GetMatchingURL() []string

GetMatchingURL returns all of matching image url.

type WebLabel added in v0.3.3

type WebLabel struct {
	Label        string
	LanguageCode string
}

WebLabel is wrapper strcut for SDK.WebLabel.

func NewWebLabels added in v0.3.3

func NewWebLabels(labels []*SDK.WebLabel) []WebLabel

NewWebLabels creates []WebLabel from []SDK.WebLabel.

type WebPage added in v0.3.3

type WebPage struct {
	FullMatchingImages    []string
	PartialMatchingImages []string
	Title                 string
	URL                   string
}

WebPage is wrapper struct for SDK.WebPage.

func NewWebPages added in v0.3.3

func NewWebPages(labels []*SDK.WebPage) []WebPage

NewWebPages creates []WebPage from []SDK.WebPage.

type Word added in v0.3.3

type Word struct {
	TextProperty
	Confidence float64
	Vertices   []Vertex
	Symbols    []Symbol
}

Word is wrapper struct for SDK.Word.

func NewWord added in v0.3.3

func NewWord(w *SDK.Word) Word

NewWord creates Word from SDK.Word.

Jump to

Keyboard shortcuts

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