vision - ActiveState ActiveGo 1.8
...

Package vision

import "cloud.google.com/go/vision/apiv1"
Overview
Index
Examples

Overview ▾

Package vision is an experimental, auto-generated package for the vision API.

Integrates Google Vision features, including image labeling, face, logo, and landmark detection, optical character recognition (OCR), and detection of explicit content, into applications.

Use the client at cloud.google.com/go/vision in preference to this.

Index ▾

func DefaultAuthScopes() []string
func NewImageFromReader(r io.Reader) (*pb.Image, error)
func NewImageFromURI(uri string) *pb.Image
type Chin
type Ears
type Eye
type Eyebrow
type Eyebrows
type Eyes
type FaceLandmarks
    func FaceFromLandmarks(landmarks []*pb.FaceAnnotation_Landmark) *FaceLandmarks
type ImageAnnotatorCallOptions
type ImageAnnotatorClient
    func NewImageAnnotatorClient(ctx context.Context, opts ...option.ClientOption) (*ImageAnnotatorClient, error)
    func (c *ImageAnnotatorClient) AnnotateImage(ctx context.Context, req *pb.AnnotateImageRequest, opts ...gax.CallOption) (*pb.AnnotateImageResponse, error)
    func (c *ImageAnnotatorClient) BatchAnnotateImages(ctx context.Context, req *visionpb.BatchAnnotateImagesRequest, opts ...gax.CallOption) (*visionpb.BatchAnnotateImagesResponse, error)
    func (c *ImageAnnotatorClient) Close() error
    func (c *ImageAnnotatorClient) Connection() *grpc.ClientConn
    func (c *ImageAnnotatorClient) CropHints(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, opts ...gax.CallOption) (*pb.CropHintsAnnotation, error)
    func (c *ImageAnnotatorClient) DetectDocumentText(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, opts ...gax.CallOption) (*pb.TextAnnotation, error)
    func (c *ImageAnnotatorClient) DetectFaces(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, maxResults int, opts ...gax.CallOption) ([]*pb.FaceAnnotation, error)
    func (c *ImageAnnotatorClient) DetectImageProperties(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, opts ...gax.CallOption) (*pb.ImageProperties, error)
    func (c *ImageAnnotatorClient) DetectLabels(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, maxResults int, opts ...gax.CallOption) ([]*pb.EntityAnnotation, error)
    func (c *ImageAnnotatorClient) DetectLandmarks(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, maxResults int, opts ...gax.CallOption) ([]*pb.EntityAnnotation, error)
    func (c *ImageAnnotatorClient) DetectLogos(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, maxResults int, opts ...gax.CallOption) ([]*pb.EntityAnnotation, error)
    func (c *ImageAnnotatorClient) DetectSafeSearch(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, opts ...gax.CallOption) (*pb.SafeSearchAnnotation, error)
    func (c *ImageAnnotatorClient) DetectTexts(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, maxResults int, opts ...gax.CallOption) ([]*pb.EntityAnnotation, error)
    func (c *ImageAnnotatorClient) DetectWeb(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, opts ...gax.CallOption) (*pb.WebDetection, error)
    func (c *ImageAnnotatorClient) SetGoogleClientInfo(keyval ...string)
type Mouth
type Nose

Package files

client.go doc.go face.go image.go image_annotator_client.go

func DefaultAuthScopes

func DefaultAuthScopes() []string

func NewImageFromReader

func NewImageFromReader(r io.Reader) (*pb.Image, error)

NewImageFromReader reads the bytes of an image from r.

func NewImageFromURI

func NewImageFromURI(uri string) *pb.Image

NewImageFromURI returns an image that refers to an object in Google Cloud Storage (when the uri is of the form "gs://BUCKET/OBJECT") or at a public URL.

type Chin

Chin represents a face's chin.

type Chin struct {
    Left, Center, Right *pb.Position
}

type Ears

Ears represents a face's ears.

type Ears struct {
    Left, Right *pb.Position
}

type Eye

Eye represents a face's eye.

type Eye struct {
    Left, Right, Top, Bottom, Center, Pupil *pb.Position
}

type Eyebrow

Eyebrow represents a face's eyebrow.

type Eyebrow struct {
    Top, Left, Right *pb.Position
}

type Eyebrows

Eyebrows represents a face's eyebrows.

type Eyebrows struct {
    Left, Right Eyebrow
}

type Eyes

Eyes represents a face's eyes.

type Eyes struct {
    Left, Right Eye
}

type FaceLandmarks

FaceLandmarks contains the positions of facial features detected by the service.

type FaceLandmarks struct {
    Eyebrows Eyebrows
    Eyes     Eyes
    Ears     Ears
    Nose     Nose
    Mouth    Mouth
    Chin     Chin
    Forehead *pb.Position
}

func FaceFromLandmarks

func FaceFromLandmarks(landmarks []*pb.FaceAnnotation_Landmark) *FaceLandmarks

FaceFromLandmarks converts the list of face landmarks returned by the service to a FaceLandmarks struct.

type ImageAnnotatorCallOptions

ImageAnnotatorCallOptions contains the retry settings for each method of ImageAnnotatorClient.

type ImageAnnotatorCallOptions struct {
    BatchAnnotateImages []gax.CallOption
}

type ImageAnnotatorClient

ImageAnnotatorClient is a client for interacting with Google Cloud Vision API.

type ImageAnnotatorClient struct {

    // The call options for this service.
    CallOptions *ImageAnnotatorCallOptions
    // contains filtered or unexported fields
}

func NewImageAnnotatorClient

func NewImageAnnotatorClient(ctx context.Context, opts ...option.ClientOption) (*ImageAnnotatorClient, error)

NewImageAnnotatorClient creates a new image annotator client.

Service that performs Google Cloud Vision API detection tasks over client images, such as face, landmark, logo, label, and text detection. The ImageAnnotator service returns detected entities from the images.

Example

Code:

ctx := context.Background()
c, err := vision.NewImageAnnotatorClient(ctx)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use client.
_ = c

func (*ImageAnnotatorClient) AnnotateImage

func (c *ImageAnnotatorClient) AnnotateImage(ctx context.Context, req *pb.AnnotateImageRequest, opts ...gax.CallOption) (*pb.AnnotateImageResponse, error)

AnnotateImage runs image detection and annotation for a single image.

Example

Code:

ctx := context.Background()
c, err := vision.NewImageAnnotatorClient(ctx)
if err != nil {
    // TODO: Handle error.
}
res, err := c.AnnotateImage(ctx, &pb.AnnotateImageRequest{
    Image: vision.NewImageFromURI("gs://my-bucket/my-image.png"),
    Features: []*pb.Feature{
        {Type: pb.Feature_LANDMARK_DETECTION, MaxResults: 5},
        {Type: pb.Feature_LABEL_DETECTION, MaxResults: 3},
    },
})
if err != nil {
    // TODO: Handle error.
}
// TODO: Use res.
_ = res

func (*ImageAnnotatorClient) BatchAnnotateImages

func (c *ImageAnnotatorClient) BatchAnnotateImages(ctx context.Context, req *visionpb.BatchAnnotateImagesRequest, opts ...gax.CallOption) (*visionpb.BatchAnnotateImagesResponse, error)

BatchAnnotateImages run image detection and annotation for a batch of images.

Example

Code:

ctx := context.Background()
c, err := vision.NewImageAnnotatorClient(ctx)
if err != nil {
    // TODO: Handle error.
}

req := &visionpb.BatchAnnotateImagesRequest{
// TODO: Fill request struct fields.
}
resp, err := c.BatchAnnotateImages(ctx, req)
if err != nil {
    // TODO: Handle error.
}
// TODO: Use resp.
_ = resp

func (*ImageAnnotatorClient) Close

func (c *ImageAnnotatorClient) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*ImageAnnotatorClient) Connection

func (c *ImageAnnotatorClient) Connection() *grpc.ClientConn

Connection returns the client's connection to the API service.

func (*ImageAnnotatorClient) CropHints

func (c *ImageAnnotatorClient) CropHints(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, opts ...gax.CallOption) (*pb.CropHintsAnnotation, error)

CropHints computes crop hints for the image.

func (*ImageAnnotatorClient) DetectDocumentText

func (c *ImageAnnotatorClient) DetectDocumentText(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, opts ...gax.CallOption) (*pb.TextAnnotation, error)

DetectDocumentText performs full text (OCR) detection on the image.

func (*ImageAnnotatorClient) DetectFaces

func (c *ImageAnnotatorClient) DetectFaces(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, maxResults int, opts ...gax.CallOption) ([]*pb.FaceAnnotation, error)

DetectFaces performs face detection on the image. At most maxResults results are returned.

func (*ImageAnnotatorClient) DetectImageProperties

func (c *ImageAnnotatorClient) DetectImageProperties(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, opts ...gax.CallOption) (*pb.ImageProperties, error)

DetectImageProperties computes properties of the image.

func (*ImageAnnotatorClient) DetectLabels

func (c *ImageAnnotatorClient) DetectLabels(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, maxResults int, opts ...gax.CallOption) ([]*pb.EntityAnnotation, error)

DetectLabels performs label detection on the image. At most maxResults results are returned.

func (*ImageAnnotatorClient) DetectLandmarks

func (c *ImageAnnotatorClient) DetectLandmarks(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, maxResults int, opts ...gax.CallOption) ([]*pb.EntityAnnotation, error)

DetectLandmarks performs landmark detection on the image. At most maxResults results are returned.

func (*ImageAnnotatorClient) DetectLogos

func (c *ImageAnnotatorClient) DetectLogos(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, maxResults int, opts ...gax.CallOption) ([]*pb.EntityAnnotation, error)

DetectLogos performs logo detection on the image. At most maxResults results are returned.

func (*ImageAnnotatorClient) DetectSafeSearch

func (c *ImageAnnotatorClient) DetectSafeSearch(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, opts ...gax.CallOption) (*pb.SafeSearchAnnotation, error)

DetectSafeSearch performs safe-search detection on the image.

func (*ImageAnnotatorClient) DetectTexts

func (c *ImageAnnotatorClient) DetectTexts(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, maxResults int, opts ...gax.CallOption) ([]*pb.EntityAnnotation, error)

DetectTexts performs text detection on the image. At most maxResults results are returned.

func (*ImageAnnotatorClient) DetectWeb

func (c *ImageAnnotatorClient) DetectWeb(ctx context.Context, img *pb.Image, ictx *pb.ImageContext, opts ...gax.CallOption) (*pb.WebDetection, error)

DetectWeb computes a web annotation on the image.

func (*ImageAnnotatorClient) SetGoogleClientInfo

func (c *ImageAnnotatorClient) SetGoogleClientInfo(keyval ...string)

SetGoogleClientInfo sets the name and version of the application in the `x-goog-api-client` header passed on each request. Intended for use by Google-written clients.

type Mouth

Mouth represents a face's mouth.

type Mouth struct {
    Left, Center, Right, UpperLip, LowerLip *pb.Position
}

type Nose

Nose represents a face's nose.

type Nose struct {
    Left, Right, Top, Bottom, Tip *pb.Position
}