Stay organized with collections Save and categorize content based on your preferences.
An idiomatic C++ client library for the Cloud Vision API. Integrate Google Vision features, including image labeling, face, logo, and landmark detection, optical character recognition (OCR), and detection of explicit content, into applications.
While this library is GA, please note Google Cloud C++ client libraries do not follow Semantic Versioning.
QuickstartThe following shows the code that you'll run in the google/cloud/vision/quickstart/
directory, which should give you a taste of the Cloud Vision API C++ client library API.
#include "google/cloud/vision/v1/image_annotator_client.h"
#include <iostream>
int main(int argc, char* argv[]) try {
auto constexpr kDefaultUri =
"gs://cloud-samples-data/vision/label/wakeupcat.jpg";
if (argc > 2) {
std::cerr << "Usage: " << argv[0] << " [gcs-uri]\n"
<< " The gcs-uri must be in gs://... format. It defaults to "
<< kDefaultUri << "\n";
return 1;
}
auto uri = std::string{argc == 2 ? argv[1] : kDefaultUri};
namespace vision = ::google::cloud::vision_v1;
auto client =
vision::ImageAnnotatorClient(vision::MakeImageAnnotatorConnection());
// Define the image we want to annotate
google::cloud::vision::v1::Image image;
image.mutable_source()->set_image_uri(uri);
// Create a request to annotate this image with Request text annotations for a
// file stored in GCS.
google::cloud::vision::v1::AnnotateImageRequest request;
*request.mutable_image() = std::move(image);
request.add_features()->set_type(
google::cloud::vision::v1::Feature::TEXT_DETECTION);
google::cloud::vision::v1::BatchAnnotateImagesRequest batch_request;
*batch_request.add_requests() = std::move(request);
auto batch = client.BatchAnnotateImages(batch_request);
if (!batch) throw std::move(batch).status();
// Find the longest annotation and print it
auto result = std::string{};
for (auto const& response : batch->responses()) {
for (auto const& annotation : response.text_annotations()) {
if (result.size() < annotation.description().size()) {
result = annotation.description();
}
}
}
std::cout << "The image contains this text: " << result << "\n";
return 0;
} catch (google::cloud::Status const& status) {
std::cerr << "google::cloud::Status thrown: " << status << "\n";
return 1;
}
Main classes
This library offers multiple *Client
classes, which are listed below. Each one of these classes exposes all the RPCs for a service as member functions of the class. This library groups multiple services because they are part of the same product or are often used together. A typical example may be the administrative and data plane operations for a single product.
The library also has other classes that provide helpers, configuration parameters, and infrastructure to mock the *Client
classes when testing your application.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-14 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["This page provides documentation for the Cloud Vision API C++ client library, which allows developers to integrate Google Vision features like image labeling, OCR, and content detection into their applications."],["The library offers `ImageAnnotatorClient` and `ProductSearchClient` classes, with each exposing all RPCs for their respective services as member functions, grouped together because they are part of the same product."],["The C++ client library is in GA, but does not adhere to Semantic Versioning, and it provides a quickstart guide with example code demonstrating text annotation for images stored in GCS."],["A list of available library versions are provided, including the latest release candidate, version 2.37.0-rc, along with other versions ranging from 2.36.0 to 2.11.0."],["The page has links to resources regarding error handling, overriding default settings such as endpoint, authentication credentials, retry policies, and environment variables that can be used to change library behavior."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4