Falls Sie dies noch nicht getan haben, richten Sie wie unten beschrieben das Projekt ein und erstellen Sie einen Cloud Storage-Bucket.
Projekt einrichten
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
On the Create a bucket page, enter your bucket information. To go to the next
step, click Continue.
For Name your bucket, enter a unique bucket name. Don't include sensitive
information in the bucket name, because the bucket namespace is global and publicly
visible.
In the Choose where to store your data section, do the following:
Choose a location where your bucket's data is permanently stored from the Location type drop-down menu.
If you select the dual-region location type, you can
also choose to enable turbo replication by using the
relevant checkbox.
To set up cross-bucket replication, select
Add cross-bucket replication via Storage Transfer Service and
follow these steps:
Set up cross-bucket replication
In the Bucket menu, select a bucket.
In the Replication settings section,
click Configure to configure settings for the
replication job.
The Configure cross-bucket replication pane
appears.
To filter objects to replicate by object name prefix,
enter a prefix that you want to include or exclude objects from, then click addAdd a prefix.
To set a storage class for the replicated objects,
select a storage class from the Storage class menu.
If you skip this step, the replicated objects will use the
destination bucket's storage class by default.
Click Done.
In the Choose how to store your data section, do the following:
In the Set a default class section, select the following:
Standard.
To enable hierarchical namespace, in the
Optimize storage for data-intensive workloads section, select
Enable hierarchical namespace on this bucket.
In the Choose how to control access to objects section, select
whether or not your bucket enforces public access prevention,
and select an access control method for your bucket's objects.
In the Choose how to protect object data section, do the
following:
Select any of the options under Data protection that you
want to set for your bucket.
To enable soft delete, click the
Soft delete policy (For data recovery) checkbox,
and specify the number of days you want to retain objects
after deletion.
To set Object Versioning, click the
Object versioning (For version control) checkbox,
and specify the maximum number of versions per object and the number of days after which
the noncurrent versions expire.
To enable the retention policy on objects and buckets, click the Retention (For compliance) checkbox, and then do the following:
Wählen Sie den Bucket aus, den Sie im vorherigen Abschnitt erstellt haben.
Klicken Sie auf Upload Files (Dateien hochladen) und wählen Sie die lokale Version der Datei demo-img.jpg aus, um Sie in Ihren Cloud Storage-Bucket hochzuladen.
Das ist die Bilddatei, die Sie gerade hochgeladen haben:
Bildnachweis:
Rohiim Ariful auf Unsplash.
Füllen Sie im Abschnitt Diese Methode testen die interaktive API Explorer-Vorlage aus. Ersetzen Sie dazu cloud-samples-data/vision im Feld image.source.imageUri durch den Namen des Cloud Storage-Buckets, in den Sie die Datei demo-img.jpg hochgeladen haben. Der Anfragetext sollte in etwa so aussehen:
Klicken Sie auf Ausführen, um die Anfrage an den Dienst zu senden. Die JSON-Antwort wird nach dem Anfragetext angezeigt.
Glückwunsch! Sie haben Ihre erste images.annotate-Anfrage an Cloud Vision gesendet.
Bereinigen
Löschen Sie Ihren Cloud Storage-Bucket und ggf. Ihr Projekt mithilfe der Google Cloud Console, wenn Sie sie nicht benötigen. Damit vermeiden Sie unnötige Google Cloud -Kosten.
Erste Schritte mit Vision API in der Sprache Ihrer Wahl. Verwenden Sie dafür eine Vision API-Clientbibliothek.
Verwenden Sie die Anleitungen, um mehr über bestimmte Funktionen zu erfahren, Beispielannotationen anzusehen und Annotationen für einzelne Dateien oder Bilder abzurufen.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-19 (UTC)."],[],[],null,["# Quickstart: Detect labels in an image by using the Cloud Vision API\n\nDetect labels in an image by using the Cloud Vision API\n=======================================================\n\nThis quickstart shows you how to:\n\n- Create a Cloud Storage bucket.\n- Upload your image to Cloud Storage and make the file publicly accessible.\n- Make a request to the Vision API with that image.\n\nThese steps should take about five minutes to complete. You can [store up to\n5 GB of data in Cloud Storage for no\ncharge](/storage/pricing#cloud-storage-always-free) and make up to [1000 feature\nrequests](/vision/docs/pricing) per month to the Vision API for no\ncharge.\n\nBefore you begin\n----------------\n\nIf you haven't done so already, use the following instructions to set up your\nproject and create a Cloud Storage bucket.\n\n### Set up your project\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Cloud Vision API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=vision.googleapis.com&redirect=https://console.cloud.google.com)\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Cloud Vision API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=vision.googleapis.com&redirect=https://console.cloud.google.com)\n\n\u003cbr /\u003e\n\n### Create a Cloud Storage bucket\n\n1. In the Google Cloud console, go to the Cloud Storage **Buckets** page.\n\n [Go to Buckets](https://console.cloud.google.com/storage/browser)\n2. Click add_box **Create**.\n3. On the **Create a bucket** page, enter your bucket information. To go to the next step, click **Continue** .\n 1. For **Name your bucket**, enter a unique bucket name. Don't include sensitive information in the bucket name, because the bucket namespace is global and publicly visible.\n 2. In the **Choose where to store your data** section, do the following:\n 1. Select a [Location type](/storage/docs/locations).\n 2. Choose a location where your bucket's data is permanently stored from the **[Location type](/storage/docs/locations#available-locations)** drop-down menu.\n - If you select the [dual-region](/storage/docs/locations#location-dr) location type, you can also choose to enable [turbo replication](/storage/docs/availability-durability#turbo-replication) by using the relevant checkbox.\n 3. To set up [cross-bucket replication](/storage/docs/availability-durability#cross-bucket-replication), select **Add cross-bucket replication via Storage Transfer Service** and follow these steps: \n\n #### Set up cross-bucket replication\n\n 1. In the **Bucket** menu, select a bucket.\n 2. In the **Replication settings** section,\n click **Configure** to configure settings for the\n replication job.\n\n The **Configure cross-bucket replication** pane\n appears.\n - To filter objects to replicate by object name prefix, enter a prefix that you want to include or exclude objects from, then click add **Add a prefix**.\n - To set a storage class for the replicated objects, select a storage class from the **Storage class** menu. If you skip this step, the replicated objects will use the destination bucket's storage class by default.\n - Click **Done**.\n 3. In the **Choose how to store your data** section, do the following:\n 1. In the **Set a default class** section, select the following: **Standard**.\n 2. To enable [hierarchical namespace](/storage/docs/hns-overview), in the **Optimize storage for data-intensive workloads** section, select **Enable hierarchical namespace on this bucket** . **Note:** You cannot enable hierarchical namespace in existing buckets.\n 4. In the **Choose how to control access to objects** section, select whether or not your bucket enforces [public access prevention](/storage/docs/public-access-prevention), and select an [access control method](/storage/docs/access-control) for your bucket's objects. **Note:** You cannot change the **Prevent public access** setting if this setting is enforced at an [organization policy](/storage/docs/org-policy-constraints#public-access-prevention).\n 5. In the **Choose how to protect object data** section, do the following:\n - Select any of the options under **Data protection** that you want to set for your bucket.\n - To enable [soft delete](/storage/docs/soft-delete), click the **Soft delete policy (For data recovery)** checkbox, and specify the number of days you want to retain objects after deletion.\n - To set [Object Versioning](/storage/docs/object-versioning), click the **Object versioning (For version control)** checkbox, and specify the maximum number of versions per object and the number of days after which the noncurrent versions expire.\n - To enable the retention policy on objects and buckets, click the **Retention (For compliance)** checkbox, and then do the following:\n - To enable [Object Retention Lock](/storage/docs/object-lock), click the **Enable object retention** checkbox.\n - To enable [Bucket Lock](/storage/docs/bucket-lock), click the **Set bucket retention policy** checkbox, and choose a unit of time and a length of time for your retention period.\n - To choose how your object data will be encrypted, expand the **Data encryption** section (expand_more), and select a [**Data encryption** method](/storage/docs/encryption).\n4. Click **Create**.\n\n\u003cbr /\u003e\n\nMake a request to Cloud Vision\n------------------------------\n\n1. Save a local version of the sample image file ([`demo-img.jpg`](/static/vision/docs/images/demo-img.jpg)).\n\n2. In the Google Cloud console, go to the Cloud Storage **Buckets** page.\n\n [Go to Buckets](https://console.cloud.google.com/storage/browser)\n3. Select the bucket you created in the previous section.\n\n4. Click **Upload Files** and select the local version of the `demo-img.jpg`\n file to upload to your Cloud Storage bucket.\n\n This is the image file that you just uploaded: *Image credit* : [Rohiim Ariful](https://unsplash.com/photos/Iz2cMcT6BzU) on [Unsplash](https://unsplash.com/).\n\n \u003cbr /\u003e\n\n5. After the file is uploaded and appears in the Cloud Storage bucket,\n [share the image publicly](/storage/docs/access-control/making-data-public).\n\n6. In the [Try this method](#apis-explorer-try-this-method) section, complete\n the interactive API Explorer template by replacing\n `cloud-samples-data/vision` in the `image.source.imageUri` field with the\n name of the Cloud Storage bucket where you uploaded the `demo-img.jpg`\n file. The request body should look like the following:\n\n ```\n {\n \"requests\": [\n {\n \"features\": [\n {\n \"type\": \"LABEL_DETECTION\"\n }\n ],\n \"image\": {\n \"source\": {\n \"imageUri\": \"gs://cloud-samples-data/vision/demo-img.jpg\"\n }\n }\n }\n ]\n }\n ``` \n\n \u003cbr /\u003e\n\n7. Click **Execute** to send the request to the service. The JSON response\n appears after the request body.\n\nCongratulations! You've made your first `images.annotate` request to\nCloud Vision.\n\nClean up\n--------\n\nTo avoid unnecessary Google Cloud charges, use the Google Cloud console to\ndelete your Cloud Storage bucket (and your project) if you don't need them.\n\nWhat's next\n-----------\n\n- See a list of [all feature types](/vision/docs/features-list) and their uses.\n- Get started with the Vision API in your language of choice by using a [Vision API Client\n Library](/vision/docs/quickstart-client-libraries).\n- Use the [How-to guides](/vision/docs/how-to) to learn more about specific features, see example annotations, and get annotations for an individual file or image.\n- Learn about batch [image](/vision/docs/batch) and [file](/vision/docs/file-small-batch) (PDF/TIFF/GIF) annotation.\n- Browse through a comprehensive list of client library code [samples](/vision/docs/samples)."]]