Skip to content

chore: upgrade vision samples to new surface #1885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vision/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "google/vision",
"type": "project",
"require": {
"google/cloud-vision": "^1.0.0",
"google/cloud-vision": "^1.7",
"google/cloud-storage": "^1.20.1"
}
}
2 changes: 1 addition & 1 deletion vision/quickstart.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
require __DIR__ . '/vendor/autoload.php';

# imports the Google Cloud client library
use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

# instantiates a client
$imageAnnotator = new ImageAnnotatorClient();
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_document_text.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_fulltext_detection]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

/**
* @param string $path Path to the image, e.g. "path/to/your/image.jpg"
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_document_text_gcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_fulltext_detection_gcs]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

/**
* @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg"
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_face.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace Google\Cloud\Samples\Vision;

// [START vision_face_detection_tutorial_imports]
use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

// [END vision_face_detection_tutorial_imports]
/**
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_face_gcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_face_detection_gcs]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

/**
* @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg"
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_image_property.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_image_property_detection]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

/**
* @param string $path Path to the image, e.g. "path/to/your/image.jpg"
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_image_property_gcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_image_property_detection_gcs]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

/**
* @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg"
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_label.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_label_detection]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

/**
* @param string $path Path to the image, e.g. "path/to/your/image.jpg"
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_label_gcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_label_detection_gcs]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

/**
* @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg"
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_landmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_landmark_detection]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

/**
* @param string $path Path to the image, e.g. "path/to/your/image.jpg"
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_landmark_gcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_landmark_detection_gcs]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

/**
* @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg"
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_logo.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_logo_detection]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

/**
* @param string $path Path to the image, e.g. "path/to/your/image.jpg"
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_logo_gcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_logo_detection_gcs]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

/**
* @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg"
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_object.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_localize_objects]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

/**
* @param string $path Path to the image, e.g. "path/to/your/image.jpg"
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_object_gcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_localize_objects_gcs]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

/**
* @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg"
Expand Down
7 changes: 5 additions & 2 deletions vision/src/detect_pdf_gcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
use Google\Cloud\Storage\StorageClient;
use Google\Cloud\Vision\V1\AnnotateFileResponse;
use Google\Cloud\Vision\V1\AsyncAnnotateFileRequest;
use Google\Cloud\Vision\V1\AsyncBatchAnnotateFilesRequest;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Feature;
use Google\Cloud\Vision\V1\Feature\Type;
use Google\Cloud\Vision\V1\GcsDestination;
use Google\Cloud\Vision\V1\GcsSource;
use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\InputConfig;
use Google\Cloud\Vision\V1\OutputConfig;

Expand Down Expand Up @@ -66,7 +67,9 @@ function detect_pdf_gcs(string $path, string $output)

# make request
$imageAnnotator = new ImageAnnotatorClient();
$operation = $imageAnnotator->asyncBatchAnnotateFiles($requests);
$request = (new AsyncBatchAnnotateFilesRequest())
->setRequests($requests);
$operation = $imageAnnotator->asyncBatchAnnotateFiles($request);
print('Waiting for operation to finish.' . PHP_EOL);
$operation->pollUntilComplete();

Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_safe_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_safe_search_detection]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

/**
* @param string $path Path to the image, e.g. "path/to/your/image.jpg"
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_safe_search_gcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_safe_search_detection_gcs]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

/**
* @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg"
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_text.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_text_detection]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

/**
* @param string $path Path to the image, e.g. "path/to/your/image.jpg"
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_text_gcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_text_detection_gcs]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

/**
* @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg"
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_web.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_web_detection]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

/**
* @param string $path Path to the image, e.g. "path/to/your/image.jpg"
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_web_gcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_web_detection_gcs]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;

/**
* @param string $path GCS path to the image, e.g. "gs://path/to/your/image.jpg"
Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_web_with_geo_metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_web_detection_include_geo]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\ImageContext;
use Google\Cloud\Vision\V1\WebDetectionParams;

Expand Down
2 changes: 1 addition & 1 deletion vision/src/detect_web_with_geo_metadata_gcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// [START vision_web_detection_include_geo_gcs]
namespace Google\Cloud\Samples\Vision;

use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\Client\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\ImageContext;
use Google\Cloud\Vision\V1\WebDetectionParams;

Expand Down