אם עוד לא יצרתם Google Cloud פרויקט, אתם יכולים ליצור אחד. כדי לראות את ההוראות, אפשר להרחיב את הקטע הזה.
נכנסים לחשבון Google Cloud . אם אתם משתמשים חדשים ב- Google Cloud,
צרו חשבון כדי שתוכלו להעריך את הביצועים של המוצרים שלנו בתרחישים מהעולם האמיתי. לקוחות חדשים מקבלים בחינם גם קרדיט בשווי 300$ להרצה, לבדיקה ולפריסה של עומסי העבודה.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
Roles required to select or create a project
Select a project: Selecting a project doesn't require a specific
IAM role—you can select any project that you've been
granted a role on.
Create a project: To create a project, you need the Project Creator role
(roles/resourcemanager.projectCreator), which contains the
resourcemanager.projects.create permission. Learn how to grant
roles.
To enable APIs, you need the serviceusage.services.enable permission. If you
created the project, then you likely already have this permission through the
Owner role (roles/owner). Otherwise, you can get this permission through the
Service Usage Admin role (roles/serviceusage.serviceUsageAdmin).
Learn how to grant roles.
כדי לאתחל את ה-CLI של gcloud, הריצו את הפקודה הבאה:
gcloudinit
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
Roles required to select or create a project
Select a project: Selecting a project doesn't require a specific
IAM role—you can select any project that you've been
granted a role on.
Create a project: To create a project, you need the Project Creator role
(roles/resourcemanager.projectCreator), which contains the
resourcemanager.projects.create permission. Learn how to grant
roles.
To enable APIs, you need the serviceusage.services.enable permission. If you
created the project, then you likely already have this permission through the
Owner role (roles/owner). Otherwise, you can get this permission through the
Service Usage Admin role (roles/serviceusage.serviceUsageAdmin).
Learn how to grant roles.
כדי לבצע אימות ב-Vision, צריך להגדיר את Application Default Credentials.
מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.
// detectLogos gets logos from the Vision API for an image at the given file path.funcdetectLogos(wio.Writer,filestring)error{ctx:=context.Background()client,err:=vision.NewImageAnnotatorClient(ctx)iferr!=nil{returnerr}fileBytes,err:=os.ReadFile(file)iferr!=nil{returnerr}image:=&visionpb.Image{Content:fileBytes,}feature:=&visionpb.Feature{Type:visionpb.Feature_LOGO_DETECTION,MaxResults:10,}request:=&visionpb.BatchAnnotateImagesRequest{Requests:[]*visionpb.AnnotateImageRequest{{Image:image,Features:[]*visionpb.Feature{feature},},},}response,err:=client.BatchAnnotateImages(ctx,request)iferr!=nil{returnerr}for_,resp:=rangeresponse.Responses{ifresp.Error!=nil{fmt.Fprintf(w,"Error: %v\n",resp.Error)continue}iflen(resp.LogoAnnotations)