Documentation ¶
Overview ¶
Package vision is a library for micrsoft vision api
Let's start to make a request to bing vision Full documention is on https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/
Installation : go get github.com/ahmdrz/microsoft-vision-golang
First of all , let me to explain how to use image from url.
Tag method :
func main() { vision, err := vision.New("<KEY>") if err != nil { panic(err) } result, err := vision.Tag("https://portalstoragewuprod2.azureedge.net/vision/Analysis/1.jpg") if err != nil { panic(err) } fmt.Println(result) }
Analyze method :
func main() { vis, err := vision.New("<KEY>") if err != nil { panic(err) } result, err := vis.Analyze("https://portalstoragewuprod2.azureedge.net/vision/Analysis/1.jpg", vision.VisualFeatures{ Adult: true, Tags: true, }) if err != nil { panic(err) } }
------
In analyze method we have VisualFeatures , Source of VisualFeatures struct is
type VisualFeatures struct { Categories bool Tags bool Description bool Faces bool ImageType bool Color bool Adult bool }
... and func (order VisualFeatures) String() (string, error) can make a string from this struct
vision project vision.go license MIT powered by github.com/ahmdrz full api reference on https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/
Index ¶
- Constants
- type Adult
- type Caption
- type Category
- type Color
- type Description
- type Error
- type Face
- type Image
- type ImageType
- type Line
- type MetaData
- type Model
- type OCROption
- type Rectangle
- type Region
- type Tag
- type ThumbnailOrder
- type Vision
- func (vision *Vision) Analyze(url string, order VisualFeatures) (VisionResult, error)
- func (vision *Vision) AnalyzeFile(path string, order VisualFeatures) (VisionResult, error)
- func (vision *Vision) Describe(url string, max int) (VisionResult, error)
- func (vision *Vision) DescribeFile(path string, max int) (VisionResult, error)
- func (vision *Vision) GetModels() ([]Model, error)
- func (vision *Vision) OCR(url string, order OCROption) (VisionOCRResult, error)
- func (vision *Vision) OCRFile(path string, order OCROption) (VisionOCRResult, error)
- func (vision *Vision) Tag(url string) (VisionResult, error)
- func (vision *Vision) TagFile(path string) (VisionResult, error)
- func (vision *Vision) Thumbnail(url string, order ThumbnailOrder) (Image, error)
- type VisionOCRResult
- type VisionResult
- type VisualFeatures
- type Word
Constants ¶
const ( URL string = "https://api.projectoxford.ai/vision/v1.0" LANG_AutoDetect string = "unk" LANG_ChineseSimplified string = "zh-Hans" LANG_ChineseTraditional string = "zh-Hant" LANG_Czech string = "cs" LANG_Danish string = "da" LANG_Dutch string = "nl" LANG_English string = "en" LANG_Finnish string = "fi" LANG_French string = "fr" LANG_German string = "de" LANG_Greek string = "el" LANG_Hungarian string = "hu" LANG_Italian string = "it" LANG_Japanese string = "Ja" LANG_Korean string = "ko" LANG_Norwegian string = "nb" LANG_Polish string = "pl" LANG_Portuguese string = "pt" LANG_Russian string = "ru" LANG_Spanish string = "es" LANG_Swedish string = "sv" LANG_Turkish string = "tr" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Description ¶
type ThumbnailOrder ¶
type Vision ¶
Main struct of library , contains BingKey for saving token and LastRequestID for determine the request id of last method.
func (*Vision) Analyze ¶
func (vision *Vision) Analyze(url string, order VisualFeatures) (VisionResult, error)
func (*Vision) AnalyzeFile ¶
func (vision *Vision) AnalyzeFile(path string, order VisualFeatures) (VisionResult, error)
func (*Vision) DescribeFile ¶
func (vision *Vision) DescribeFile(path string, max int) (VisionResult, error)
func (*Vision) OCR ¶
func (vision *Vision) OCR(url string, order OCROption) (VisionOCRResult, error)
type VisionOCRResult ¶
type VisionOCRResult struct { Language string `json:"language"` TextAngle float64 `json:"textAngle"` Orientation string `json:"orientation"` Regions []Region `json:"regions"` }
func (VisionOCRResult) String ¶
func (order VisionOCRResult) String() (result string)
this method can make a full sentence from OCR result
type VisionResult ¶
type VisionResult struct { RequestID string `json:"requestId"` Categories []Category `json:"categories"` Adult Adult `json:"adult"` Faces []Face `json:"faces"` ImageType ImageType `json:"imageType"` Color Color `json:"color"` MetaData MetaData `json:"metadata"` Description Description `json:"description"` Tags []Tag `json:"tags"` }