Skip to content

Commit 424469e

Browse files
alixhamibshaffer
authored andcommitted
Vision region tag update (GoogleCloudPlatform#677)
1 parent 8b90341 commit 424469e

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

vision/src/detect_face.php

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,27 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
1817
// [START vision_face_detection]
1918
namespace Google\Cloud\Samples\Vision;
2019

21-
// [START import_client_library]
20+
// [START vision_face_detection_tutorial_imports]
2221
use Google\Cloud\Vision\V1\ImageAnnotatorClient;
2322

24-
// [END import_client_library]
25-
26-
// $path = 'path/to/your/image.jpg'
23+
// [END vision_face_detection_tutorial_imports]
2724

2825
function detect_face($path, $outFile = null)
2926
{
30-
// [START get_vision_service]
27+
// [START vision_face_detection_tutorial_client]
3128
$imageAnnotator = new ImageAnnotatorClient();
32-
// [END get_vision_service]
33-
34-
// [START detect_face]
29+
// [END vision_face_detection_tutorial_client]
30+
31+
// [START vision_face_detection_tutorial_send_request]
3532
# annotate the image
33+
// $path = 'path/to/your/image.jpg'
3634
$image = file_get_contents($path);
3735
$response = $imageAnnotator->faceDetection($image);
3836
$faces = $response->getFaceAnnotations();
39-
// [END detect_face]
37+
// [END vision_face_detection_tutorial_send_request]
4038

4139
# names of likelihood from google.cloud.vision.enums
4240
$likelihoodName = ['UNKNOWN', 'VERY_UNLIKELY', 'UNLIKELY',
@@ -62,7 +60,9 @@ function detect_face($path, $outFile = null)
6260
print('Bounds: ' . join(', ',$bounds) . PHP_EOL);
6361
print(PHP_EOL);
6462
}
63+
// [END vision_face_detection]
6564

65+
# [START vision_face_detection_tutorial_process_response]
6666
# draw box around faces
6767
if ($faces && $outFile) {
6868
$imageCreateFunc = [
@@ -79,14 +79,14 @@ function detect_face($path, $outFile = null)
7979
'jpg' => 'imagejpeg',
8080
'jpeg' => 'imagejpeg',
8181
];
82-
82+
8383
copy($path, $outFile);
8484
$ext = strtolower(pathinfo($path, PATHINFO_EXTENSION));
8585
if (!array_key_exists($ext, $imageCreateFunc)) {
8686
throw new \Exception('Unsupported image extension');
8787
}
8888
$outputImage = call_user_func($imageCreateFunc[$ext], $outFile);
89-
# [START highlight_image]
89+
9090
foreach ($faces as $face) {
9191
$vertices = $face->getBoundingPoly()->getVertices();
9292
if ($vertices) {
@@ -97,9 +97,12 @@ function detect_face($path, $outFile = null)
9797
imagerectangle($outputImage, $x1, $y1, $x2, $y2, 0x00ff00);
9898
}
9999
}
100-
# [END highlight_image]
100+
# [END vision_face_detection_tutorial_process_response]
101+
# [START vision_face_detection_tutorial_run_application]
101102
call_user_func($imageWriteFunc[$ext], $outputImage, $outFile);
102103
printf('Output image written to %s' . PHP_EOL, $outFile);
104+
# [END vision_face_detection_tutorial_run_application]
103105
}
106+
// [START vision_face_detection]
104107
}
105108
// [END vision_face_detection]

vision/src/detect_web_with_geo_metadata.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
// [START vision_web_entities_include_geo_results]
18+
// [START vision_web_detection_include_geo]
1919
namespace Google\Cloud\Samples\Vision;
2020

2121
use Google\Cloud\Vision\V1\ImageAnnotatorClient;
@@ -53,4 +53,4 @@ function detect_web_with_geo_metadata($path)
5353
}
5454
}
5555
}
56-
// [END vision_web_entities_include_geo_results]
56+
// [END vision_web_detection_include_geo]

vision/src/detect_web_with_geo_metadata_gcs.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
// [START vision_web_entities_include_geo_results_gcs]
18+
// [START vision_web_detection_include_geo_gcs]
1919
namespace Google\Cloud\Samples\Vision;
2020

2121
use Google\Cloud\Vision\V1\ImageAnnotatorClient;
@@ -54,4 +54,4 @@ function detect_web_with_geo_metadata_gcs($path)
5454
print('No Results.' . PHP_EOL);
5555
}
5656
}
57-
// [END vision_web_entities_include_geo_results_gcs]
57+
// [END vision_web_detection_include_geo_gcs]

0 commit comments

Comments
 (0)