From 6f3965fa9b4e422f67564587f3487b48e9d85ec4 Mon Sep 17 00:00:00 2001 From: Alix Hamilton Date: Fri, 10 Aug 2018 13:04:39 -0700 Subject: [PATCH 01/17] updates region tags for detecting-crop-hints page --- .../cloud-client/src/main/java/com/example/vision/Detect.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vision/cloud-client/src/main/java/com/example/vision/Detect.java b/vision/cloud-client/src/main/java/com/example/vision/Detect.java index 68f8c98bb5c..19d5188d8bc 100644 --- a/vision/cloud-client/src/main/java/com/example/vision/Detect.java +++ b/vision/cloud-client/src/main/java/com/example/vision/Detect.java @@ -1109,6 +1109,7 @@ public static void detectWebEntitiesIncludeGeoResultsGcs(String gcsPath, PrintSt * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ + // [START vision_crop_hint_detection] public static void detectCropHints(String filePath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>(); @@ -1139,6 +1140,7 @@ public static void detectCropHints(String filePath, PrintStream out) throws Exce } } } + // [END vision_crop_hint_detection] /** * Suggests a region to crop to for a remote file on Google Cloud Storage. @@ -1148,6 +1150,7 @@ public static void detectCropHints(String filePath, PrintStream out) throws Exce * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ + // [START vision_crop_hint_detection_gcs] public static void detectCropHintsGcs(String gcsPath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>(); @@ -1177,6 +1180,7 @@ public static void detectCropHintsGcs(String gcsPath, PrintStream out) throws Ex } } } + // [END vision_crop_hint_detection_gcs] // [START vision_detect_document] /** From cb42013893bd790a0a552ced138ee2c00b9cbe76 Mon Sep 17 00:00:00 2001 From: Alix Hamilton Date: Fri, 10 Aug 2018 13:20:50 -0700 Subject: [PATCH 02/17] updates region tags for detecting-faces page --- .../cloud-client/src/main/java/com/example/vision/Detect.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vision/cloud-client/src/main/java/com/example/vision/Detect.java b/vision/cloud-client/src/main/java/com/example/vision/Detect.java index 19d5188d8bc..29c5b497d7e 100644 --- a/vision/cloud-client/src/main/java/com/example/vision/Detect.java +++ b/vision/cloud-client/src/main/java/com/example/vision/Detect.java @@ -201,6 +201,7 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception, * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ + // [START vision_face_detection] public static void detectFaces(String filePath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>(); @@ -234,6 +235,7 @@ public static void detectFaces(String filePath, PrintStream out) throws Exceptio } } } + // [END vision_face_detection] /** * Detects faces in the specified remote image on Google Cloud Storage. @@ -244,6 +246,7 @@ public static void detectFaces(String filePath, PrintStream out) throws Exceptio * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ + // [START vision_face_detection_gcs] public static void detectFacesGcs(String gcsPath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>(); @@ -278,6 +281,7 @@ public static void detectFacesGcs(String gcsPath, PrintStream out) throws Except } } } + // [END vision_face_detection_gcs] /** * Detects labels in the specified local image. From a6088f4468528f129ac6b60bfe159d25d66e3ef4 Mon Sep 17 00:00:00 2001 From: Alix Hamilton Date: Fri, 10 Aug 2018 13:35:47 -0700 Subject: [PATCH 03/17] updates region tags for detecting-fulltext page --- .../src/main/java/com/example/vision/Detect.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vision/cloud-client/src/main/java/com/example/vision/Detect.java b/vision/cloud-client/src/main/java/com/example/vision/Detect.java index 29c5b497d7e..f2044be390a 100644 --- a/vision/cloud-client/src/main/java/com/example/vision/Detect.java +++ b/vision/cloud-client/src/main/java/com/example/vision/Detect.java @@ -1186,7 +1186,6 @@ public static void detectCropHintsGcs(String gcsPath, PrintStream out) throws Ex } // [END vision_crop_hint_detection_gcs] - // [START vision_detect_document] /** * Performs document text detection on a local image file. * @@ -1195,7 +1194,8 @@ public static void detectCropHintsGcs(String gcsPath, PrintStream out) throws Ex * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ - public static void detectDocumentText(String filePath, PrintStream out) throws Exception, + // [START vision_fulltext_detection] + public static void detectDocumentText(String filePath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>(); @@ -1249,9 +1249,8 @@ public static void detectDocumentText(String filePath, PrintStream out) throws E } } } - // [END vision_detect_document] + // [END vision_fulltext_detection] - // [START vision_detect_document_uri] /** * Performs document text detection on a remote image on Google Cloud Storage. * @@ -1260,7 +1259,8 @@ public static void detectDocumentText(String filePath, PrintStream out) throws E * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ - public static void detectDocumentTextGcs(String gcsPath, PrintStream out) throws Exception, + // [START vision_fulltext_detection_gcs] + public static void detectDocumentTextGcs(String gcsPath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>(); @@ -1312,7 +1312,7 @@ public static void detectDocumentTextGcs(String gcsPath, PrintStream out) throws } } } - // [END vision_detect_document_uri] + // [END vision_fulltext_detection_gcs] // [START vision_async_detect_document_ocr] /** From 673f783f958aa7914e744abef7d083f045ea6630 Mon Sep 17 00:00:00 2001 From: Alix Hamilton Date: Fri, 10 Aug 2018 13:54:29 -0700 Subject: [PATCH 04/17] updates region tags for detecting-labels page --- .../cloud-client/src/main/java/com/example/vision/Detect.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vision/cloud-client/src/main/java/com/example/vision/Detect.java b/vision/cloud-client/src/main/java/com/example/vision/Detect.java index f2044be390a..5d4495f5cd5 100644 --- a/vision/cloud-client/src/main/java/com/example/vision/Detect.java +++ b/vision/cloud-client/src/main/java/com/example/vision/Detect.java @@ -291,6 +291,7 @@ public static void detectFacesGcs(String gcsPath, PrintStream out) throws Except * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ + // [START vision_logo_detection] public static void detectLabels(String filePath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>(); @@ -319,6 +320,7 @@ public static void detectLabels(String filePath, PrintStream out) throws Excepti } } } + // [END vision_logo_detection] /** * Detects labels in the specified remote image on Google Cloud Storage. @@ -329,6 +331,7 @@ public static void detectLabels(String filePath, PrintStream out) throws Excepti * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ + // [START vision_label_detection_gcs] public static void detectLabelsGcs(String gcsPath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>(); @@ -358,6 +361,7 @@ public static void detectLabelsGcs(String gcsPath, PrintStream out) throws Excep } } } + // [END vision_label_detection_gcs] /** * Detects landmarks in the specified local image. From 5660f80923e778ee3e54865d2a31c604e5206320 Mon Sep 17 00:00:00 2001 From: Alix Hamilton Date: Fri, 10 Aug 2018 14:03:51 -0700 Subject: [PATCH 05/17] updates region tags for detecting-landmarks page --- .../cloud-client/src/main/java/com/example/vision/Detect.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vision/cloud-client/src/main/java/com/example/vision/Detect.java b/vision/cloud-client/src/main/java/com/example/vision/Detect.java index 5d4495f5cd5..874dd692e5e 100644 --- a/vision/cloud-client/src/main/java/com/example/vision/Detect.java +++ b/vision/cloud-client/src/main/java/com/example/vision/Detect.java @@ -371,6 +371,7 @@ public static void detectLabelsGcs(String gcsPath, PrintStream out) throws Excep * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ + // [START vision_landmark_detection] public static void detectLandmarks(String filePath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>(); @@ -400,6 +401,7 @@ public static void detectLandmarks(String filePath, PrintStream out) throws Exce } } } + // [END vision_landmark_detection] /** * Detects landmarks in the specified URI. @@ -448,6 +450,7 @@ public static void detectLandmarksUrl(String uri, PrintStream out) throws Except * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ + // [START vision_landmark_detection_gcs] public static void detectLandmarksGcs(String gcsPath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>(); @@ -477,6 +480,7 @@ public static void detectLandmarksGcs(String gcsPath, PrintStream out) throws Ex } } } + // [END vision_landmark_detection_gcs] /** * Detects logos in the specified local image. From 2861c4fcf7ab3c523817efd7f1525b7dfa9b6400 Mon Sep 17 00:00:00 2001 From: Alix Hamilton Date: Fri, 10 Aug 2018 14:11:34 -0700 Subject: [PATCH 06/17] update region tags for detect-logos page --- .../cloud-client/src/main/java/com/example/vision/Detect.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vision/cloud-client/src/main/java/com/example/vision/Detect.java b/vision/cloud-client/src/main/java/com/example/vision/Detect.java index 874dd692e5e..7adac8033d8 100644 --- a/vision/cloud-client/src/main/java/com/example/vision/Detect.java +++ b/vision/cloud-client/src/main/java/com/example/vision/Detect.java @@ -490,6 +490,7 @@ public static void detectLandmarksGcs(String gcsPath, PrintStream out) throws Ex * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ + // [START vision_logo_detection] public static void detectLogos(String filePath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>(); @@ -518,6 +519,7 @@ public static void detectLogos(String filePath, PrintStream out) throws Exceptio } } } + // [END vision_logo_detection] /** * Detects logos in the specified remote image on Google Cloud Storage. @@ -528,6 +530,7 @@ public static void detectLogos(String filePath, PrintStream out) throws Exceptio * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ + // [START vision_logo_detection_gcs] public static void detectLogosGcs(String gcsPath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>(); @@ -556,6 +559,7 @@ public static void detectLogosGcs(String gcsPath, PrintStream out) throws Except } } } + // [END vision_logo_detection_gcs] /** * Detects text in the specified image. From 79ba58cddb8a6b16ccc0e9420a7111d143c3d919 Mon Sep 17 00:00:00 2001 From: Alix Hamilton Date: Fri, 10 Aug 2018 14:20:05 -0700 Subject: [PATCH 07/17] update region tags for detecting-properties page --- .../cloud-client/src/main/java/com/example/vision/Detect.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vision/cloud-client/src/main/java/com/example/vision/Detect.java b/vision/cloud-client/src/main/java/com/example/vision/Detect.java index 7adac8033d8..e7858f84492 100644 --- a/vision/cloud-client/src/main/java/com/example/vision/Detect.java +++ b/vision/cloud-client/src/main/java/com/example/vision/Detect.java @@ -644,6 +644,7 @@ public static void detectTextGcs(String gcsPath, PrintStream out) throws Excepti * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ + // [START vision_image_property_detection] public static void detectProperties(String filePath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>(); @@ -679,6 +680,7 @@ public static void detectProperties(String filePath, PrintStream out) throws Exc } } } + // [END vision_image_property_detection] /** * Detects image properties such as color frequency from the specified remote image on Google @@ -689,6 +691,7 @@ public static void detectProperties(String filePath, PrintStream out) throws Exc * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ + // [START vision_image_property_detection_gcs] public static void detectPropertiesGcs(String gcsPath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>(); @@ -723,6 +726,7 @@ public static void detectPropertiesGcs(String gcsPath, PrintStream out) throws E } } } + // [END vision_image_property_detection_gcs] // [START vision_detect_safe_search] /** From 75f8e66bd6ea0bb8cfa018005468db6713463c5b Mon Sep 17 00:00:00 2001 From: Alix Hamilton Date: Fri, 10 Aug 2018 15:14:07 -0700 Subject: [PATCH 08/17] update region tags for detecting-safe-search page --- .../src/main/java/com/example/vision/Detect.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vision/cloud-client/src/main/java/com/example/vision/Detect.java b/vision/cloud-client/src/main/java/com/example/vision/Detect.java index e7858f84492..9986451eb53 100644 --- a/vision/cloud-client/src/main/java/com/example/vision/Detect.java +++ b/vision/cloud-client/src/main/java/com/example/vision/Detect.java @@ -728,7 +728,6 @@ public static void detectPropertiesGcs(String gcsPath, PrintStream out) throws E } // [END vision_image_property_detection_gcs] - // [START vision_detect_safe_search] /** * Detects whether the specified image has features you would want to moderate. * @@ -737,6 +736,7 @@ public static void detectPropertiesGcs(String gcsPath, PrintStream out) throws E * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ + // [START vision_safe_search_detection] public static void detectSafeSearch(String filePath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>(); @@ -771,9 +771,8 @@ public static void detectSafeSearch(String filePath, PrintStream out) throws Exc } } } - // [END vision_detect_safe_search] + // [END vision_safe_search_detection] - // [START vision_detect_safe_search_uri] /** * Detects whether the specified image on Google Cloud Storage has features you would want * to moderate. @@ -783,6 +782,7 @@ public static void detectSafeSearch(String filePath, PrintStream out) throws Exc * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ + // [START vision_safe_search_detection_gcs] public static void detectSafeSearchGcs(String gcsPath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>(); @@ -816,7 +816,7 @@ public static void detectSafeSearchGcs(String gcsPath, PrintStream out) throws E } } } - // [END vision_detect_safe_search_uri] + // [END vision_safe_search_detection_gcs] // [START vision_detect_web] /** From 56b407800963b45308effae41c2834887118cc48 Mon Sep 17 00:00:00 2001 From: Alix Hamilton Date: Fri, 10 Aug 2018 15:21:54 -0700 Subject: [PATCH 09/17] update region tags for detecting-text page --- .../cloud-client/src/main/java/com/example/vision/Detect.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vision/cloud-client/src/main/java/com/example/vision/Detect.java b/vision/cloud-client/src/main/java/com/example/vision/Detect.java index 9986451eb53..9f47627c538 100644 --- a/vision/cloud-client/src/main/java/com/example/vision/Detect.java +++ b/vision/cloud-client/src/main/java/com/example/vision/Detect.java @@ -569,6 +569,7 @@ public static void detectLogosGcs(String gcsPath, PrintStream out) throws Except * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ + // [START vision_text_detection] public static void detectText(String filePath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>(); @@ -598,6 +599,7 @@ public static void detectText(String filePath, PrintStream out) throws Exception } } } + // [END vision_text_detection] /** * Detects text in the specified remote image on Google Cloud Storage. @@ -607,6 +609,7 @@ public static void detectText(String filePath, PrintStream out) throws Exception * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ + // [START vision_text_detection_gcs] public static void detectTextGcs(String gcsPath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>(); @@ -635,6 +638,7 @@ public static void detectTextGcs(String gcsPath, PrintStream out) throws Excepti } } } + // [END vision_text_detection_gcs] /** * Detects image properties such as color frequency from the specified local image. From f119ea5c2536c415a9c2728bebaddc996f52ecef Mon Sep 17 00:00:00 2001 From: Alix Hamilton Date: Fri, 10 Aug 2018 15:48:05 -0700 Subject: [PATCH 10/17] update region tags for detecting-web page --- .../src/main/java/com/example/vision/Detect.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/vision/cloud-client/src/main/java/com/example/vision/Detect.java b/vision/cloud-client/src/main/java/com/example/vision/Detect.java index 9f47627c538..3fb343eac6f 100644 --- a/vision/cloud-client/src/main/java/com/example/vision/Detect.java +++ b/vision/cloud-client/src/main/java/com/example/vision/Detect.java @@ -822,7 +822,7 @@ public static void detectSafeSearchGcs(String gcsPath, PrintStream out) throws E } // [END vision_safe_search_detection_gcs] - // [START vision_detect_web] + // [START vision_web_detection] /** * Finds references to the specified image on the web. * @@ -885,9 +885,9 @@ public static void detectWebDetections(String filePath, PrintStream out) throws } } } - // [END vision_detect_web] + // [END vision_web_detection] - // [START vision_detect_web_uri] + // [START vision_web_detection_gcs] /** * Detects whether the remote image on Google Cloud Storage has features you would want to * moderate. @@ -950,7 +950,7 @@ public static void detectWebDetectionsGcs(String gcsPath, PrintStream out) throw } } } - // [END vision_detect_web_uri] + // [END vision_web_detection_gcs] /** * Find web entities given a local image. @@ -1025,7 +1025,7 @@ public static void detectWebEntitiesGcs(String gcsPath, PrintStream out) throws } } - // [START vision_web_entities_include_geo_results] + // [START vision_web_detection_include_geo] /** * Find web entities given a local image. * @param filePath The path of the image to detect. @@ -1072,9 +1072,9 @@ public static void detectWebEntitiesIncludeGeoResults(String filePath, PrintStre })); } } - // [END vision_web_entities_include_geo_results] + // [END vision_web_detection_include_geo] - // [START vision_web_entities_include_geo_results_uri] + // [START vision_web_detection_include_geo_gcs] /** * Find web entities given the remote image on Google Cloud Storage. * @param gcsPath The path to the remote file on Google Cloud Storage to detect web entities with @@ -1123,7 +1123,7 @@ public static void detectWebEntitiesIncludeGeoResultsGcs(String gcsPath, PrintSt })); } } - // [END vision_web_entities_include_geo_results_uri] + // [END vision_web_detection_include_geo_gcs] /** * Suggests a region to crop to for a local file. From f62adf966688c989f4a8680945040247311315bb Mon Sep 17 00:00:00 2001 From: Alix Hamilton Date: Mon, 13 Aug 2018 10:50:49 -0700 Subject: [PATCH 11/17] update beta tags to standard --- .../src/main/java/com/example/vision/Detect.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vision/beta/cloud-client/src/main/java/com/example/vision/Detect.java b/vision/beta/cloud-client/src/main/java/com/example/vision/Detect.java index 9780de29705..0cc74a342e9 100644 --- a/vision/beta/cloud-client/src/main/java/com/example/vision/Detect.java +++ b/vision/beta/cloud-client/src/main/java/com/example/vision/Detect.java @@ -1482,7 +1482,7 @@ public static void detectLocalizedObjects(String filePath, PrintStream out) } // [END vision_localize_objects] - // [START vision_localize_objects_uri] + // [START vision_localize_objects_gcs] /** * Detects localized objects in a remote image on Google Cloud Storage. * @@ -1525,7 +1525,7 @@ public static void detectLocalizedObjectsGcs(String gcsPath, PrintStream out) } } } - // [END vision_localize_objects_uri] + // [END vision_localize_objects_gcs] // [START vision_handwritten_ocr] /** @@ -1600,7 +1600,7 @@ public static void detectHandwrittenOcr(String filePath, PrintStream out) throws } // [END vision_handwritten_ocr] - // [START vision_handwritten_ocr_uri] + // [START vision_handwritten_ocr_gcs] /** * Performs handwritten text detection on a remote image on Google Cloud Storage. * @@ -1672,5 +1672,5 @@ public static void detectHandwrittenOcrGcs(String gcsPath, PrintStream out) thro } } } - // [END vision_handwritten_ocr_uri] + // [END vision_handwritten_ocr_gcs] } From 645f05c97688274c593e2531ca879e620d8b48b8 Mon Sep 17 00:00:00 2001 From: Alix Hamilton Date: Mon, 13 Aug 2018 14:13:09 -0700 Subject: [PATCH 12/17] update PDF detection region tags to standard --- .../cloud-client/src/main/java/com/example/vision/Detect.java | 4 ++-- .../cloud-client/src/main/java/com/example/vision/Detect.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vision/beta/cloud-client/src/main/java/com/example/vision/Detect.java b/vision/beta/cloud-client/src/main/java/com/example/vision/Detect.java index 0cc74a342e9..7bab5b15995 100644 --- a/vision/beta/cloud-client/src/main/java/com/example/vision/Detect.java +++ b/vision/beta/cloud-client/src/main/java/com/example/vision/Detect.java @@ -1319,7 +1319,7 @@ public static void detectDocumentTextGcs(String gcsPath, PrintStream out) throws } // [END vision_detect_document_uri] - // [START vision_async_detect_document_ocr] + // [START vision_text_detection_pdf_gcs] /** * Performs document text OCR with PDF/TIFF as source files on Google Cloud Storage. * @@ -1436,7 +1436,7 @@ public static void detectDocumentsGcs(String gcsSourcePath, String gcsDestinatio } } } - // [END vision_async_detect_document_ocr] + // [END vision_text_detection_pdf_gcs] // [START vision_localize_objects] /** diff --git a/vision/cloud-client/src/main/java/com/example/vision/Detect.java b/vision/cloud-client/src/main/java/com/example/vision/Detect.java index 3fb343eac6f..eac655145a0 100644 --- a/vision/cloud-client/src/main/java/com/example/vision/Detect.java +++ b/vision/cloud-client/src/main/java/com/example/vision/Detect.java @@ -1334,7 +1334,7 @@ public static void detectDocumentTextGcs(String gcsPath, PrintStream out) throws } // [END vision_fulltext_detection_gcs] - // [START vision_async_detect_document_ocr] + // [START vision_text_detection_pdf_gcs] /** * Performs document text OCR with PDF/TIFF as source files on Google Cloud Storage. * @@ -1451,5 +1451,5 @@ public static void detectDocumentsGcs(String gcsSourcePath, String gcsDestinatio } } } - // [END vision_async_detect_document_ocr] + // [END vision_text_detection_pdf_gcs] } From fd07544f913673913a785303d442a2cf47af089e Mon Sep 17 00:00:00 2001 From: Alix Hamilton Date: Tue, 14 Aug 2018 11:55:13 -0700 Subject: [PATCH 13/17] updates product search region tags to standard --- .../com/example/vision/ImportProductSets.java | 9 ++- .../vision/ProductInProductSetManagement.java | 28 ++++---- .../com/example/vision/ProductManagement.java | 60 +++++----------- .../com/example/vision/ProductSearch.java | 8 +-- .../example/vision/ProductSetManagement.java | 69 ++++++------------- .../vision/ReferenceImageManagement.java | 26 ++++--- 6 files changed, 76 insertions(+), 124 deletions(-) diff --git a/vision/product-search/cloud-client/src/main/java/com/example/vision/ImportProductSets.java b/vision/product-search/cloud-client/src/main/java/com/example/vision/ImportProductSets.java index 04c0a15783e..6071e33d0ed 100644 --- a/vision/product-search/cloud-client/src/main/java/com/example/vision/ImportProductSets.java +++ b/vision/product-search/cloud-client/src/main/java/com/example/vision/ImportProductSets.java @@ -16,7 +16,7 @@ package com.example.vision; -// [START product_search_import] +// [START vision_product_search_tutorial_import] import com.google.api.gax.longrunning.OperationFuture; import com.google.cloud.vision.v1p3beta1.BatchOperationMetadata; import com.google.cloud.vision.v1p3beta1.ImportProductSetsGcsSource; @@ -26,7 +26,7 @@ import com.google.cloud.vision.v1p3beta1.LocationName; import com.google.cloud.vision.v1p3beta1.ProductSearchClient; import com.google.cloud.vision.v1p3beta1.ReferenceImage; - +// [END vision_product_search_tutorial_import] import java.io.PrintStream; import javax.swing.JPanel; @@ -36,7 +36,6 @@ import net.sourceforge.argparse4j.inf.Namespace; import net.sourceforge.argparse4j.inf.Subparser; import net.sourceforge.argparse4j.inf.Subparsers; -// [END product_search_import] /** * This application demonstrates how to Import Product Sets in Cloud Vision @@ -47,7 +46,7 @@ */ public class ImportProductSets extends JPanel { - // [START product_search_import_product_sets] + // [START vision_product_search_import_product_images] /** * Import images of different products in the product set. * @@ -89,7 +88,7 @@ public static void importProductSets(String projectId, String computeRegion, Str } } } - // [END product_search_import_product_sets] + // [END vision_product_search_import_product_images] public static void main(String[] args) throws Exception { ImportProductSets importProductSet = new ImportProductSets(); diff --git a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductInProductSetManagement.java b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductInProductSetManagement.java index 95c38109cdf..979fa8ff9c6 100644 --- a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductInProductSetManagement.java +++ b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductInProductSetManagement.java @@ -16,7 +16,9 @@ package com.example.vision; -// [START product_search_import] +// [START vision_product_search_remove_product_from_product_set] +// [START vision_product_search_list_products] +// [START vision_product_search_update_product_set] import com.google.cloud.vision.v1p3beta1.LocationName; import com.google.cloud.vision.v1p3beta1.Product; import com.google.cloud.vision.v1p3beta1.ProductName; @@ -29,13 +31,15 @@ import java.io.IOException; import java.io.PrintStream; +// [END vision_product_search_remove_product_from_product_set] +// [END vision_product_search_list_products] +// [END vision_product_search_update_product_set] import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParser; import net.sourceforge.argparse4j.inf.ArgumentParserException; import net.sourceforge.argparse4j.inf.Namespace; import net.sourceforge.argparse4j.inf.Subparser; import net.sourceforge.argparse4j.inf.Subparsers; -// [END product_search_import] /** * This application demonstrates how to perform basic operations with Products in a Product Set. @@ -46,7 +50,7 @@ public class ProductInProductSetManagement { - // [START product_search_add_product_to_product_set] + // [START vision_product_search_update_product_set] /** * Update a product set. * @@ -56,7 +60,7 @@ public class ProductInProductSetManagement { * @param productSetDisplayName - Display name of the product set. * @throws IOException - on I/O errors. */ - public static void addProductToProductSet( + public static void updateProductSet( String projectId, String computeRegion, String productSetId, String productSetDisplayName) throws IOException { ProductSearchClient client = ProductSearchClient.create(); @@ -92,9 +96,9 @@ public static void addProductToProductSet( System.out.println( String.format("Updated product set display name: %s", updatedProductSet.getDisplayName())); } - // [END product_search_add_product_to_product_set] + // [END vision_product_search_update_product_set] - // [START product_search_remove_product_from_product_set] + // [START vision_product_search_remove_product_from_product_set] /** * Remove a product from a product set. * @@ -120,9 +124,9 @@ public static void removeProductFromProductSet( System.out.println(String.format("Product removed from product set.")); } - // [END product_search_remove_product_from_product_set] + // [END vision_product_search_remove_product_from_product_set] - // [START product_search_list_products_in_product_set] + // [START vision_product_search_list_products_in_product_set] /** * List all products in a product set. * @@ -154,9 +158,9 @@ public static void listProductsInProductSet( String.format("Product labels: %s\n", product.getProductLabelsList().toString())); } } - // [END product_search_list_products_in_product_set] + // [END vision_product_search_list_products_in_product_set] - // [START product_search_list_products] + // [START vision_product_search_list_products] /** * List all products. * @@ -185,7 +189,7 @@ public static void listProducts(String projectId, String computeRegion) throws I String.format("Product labels: %s", product.getProductLabelsList().toString())); } } - // [END product_search_list_products] + // [END vision_product_search_list_products] public static void main(String[] args) throws Exception { ProductInProductSetManagement productInProductSetManagement = @@ -220,7 +224,7 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception { listProducts(projectId, computeRegion); } if (ns.get("command").equals("update_product_set")) { - addProductToProductSet( + updateProductSet( projectId, computeRegion, ns.getString("productSetId"), diff --git a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductManagement.java b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductManagement.java index c026b4913e0..269d37dc4d3 100644 --- a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductManagement.java +++ b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductManagement.java @@ -16,7 +16,10 @@ package com.example.vision; -// [START product_search_import] +// [START vision_product_search_create_product] +// [START vision_product_search_delete_product] +// [START vision_product_search_get_product] +// [START vision_product_search_update_product_labels] import com.google.cloud.vision.v1p3beta1.LocationName; import com.google.cloud.vision.v1p3beta1.Product; import com.google.cloud.vision.v1p3beta1.Product.KeyValue; @@ -27,13 +30,16 @@ import java.io.IOException; import java.io.PrintStream; +// [END vision_product_search_create_product] +// [END vision_product_search_delete_product] +// [END vision_product_search_get_product] +// [END vision_product_search_update_product_labels] import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParser; import net.sourceforge.argparse4j.inf.ArgumentParserException; import net.sourceforge.argparse4j.inf.Namespace; import net.sourceforge.argparse4j.inf.Subparser; import net.sourceforge.argparse4j.inf.Subparsers; -// [END product_search_import] /** * This application demonstrates how to perform basic operations on Products. @@ -44,7 +50,7 @@ public class ProductManagement { - // [START product_search_create_product] + // [START vision_product_search_create_product] /** * Create one product. * @@ -90,40 +96,9 @@ public static void createProduct( // Display the product information System.out.println(String.format("Product name: %s", product.getName())); } - // [END product_search_create_product] + // [END vision_product_search_create_product] - // [START product_search_list_products] - /** - * List all products. - * - * @param projectId - Id of the project. - * @param computeRegion - Region name. - * @throws IOException - on I/O errors. - */ - public static void listProducts(String projectId, String computeRegion) throws IOException { - ProductSearchClient client = ProductSearchClient.create(); - - // A resource that represents Google Cloud Platform location. - LocationName projectLocation = LocationName.of(projectId, computeRegion); - - // List all the products available in the region. - for (Product product : client.listProducts(projectLocation).iterateAll()) { - // Display the product information - System.out.println(String.format("\nProduct name: %s", product.getName())); - System.out.println( - String.format( - "Product id: %s", - product.getName().substring(product.getName().lastIndexOf('/') + 1))); - System.out.println(String.format("Product display name: %s", product.getDisplayName())); - System.out.println(String.format("Product category: %s", product.getProductCategory())); - System.out.println("Product labels:"); - System.out.println( - String.format("Product labels: %s", product.getProductLabelsList().toString())); - } - } - // [END product_search_list_products] - - // [START product_search_get_product] + // [START vision_product_search_get_product] /** * Get information about a product. * @@ -154,9 +129,9 @@ public static void getProduct(String projectId, String computeRegion, String pro System.out.println( String.format("Product labels: %s", product.getProductLabelsList().toString())); } - // [END product_search_get_product] + // [END vision_product_search_get_product] - // [START product_search_update_product_labels] + // [START vision_product_search_update_product_labels] /** * Update the product labels. * @@ -198,9 +173,9 @@ public static void updateProductLabels( String.format( "Updated product labels: %s", updatedProduct.getProductLabelsList().toString())); } - // [END product_search_update_product_labels] + // [END vision_product_search_update_product_labels] - // [START product_search_delete_product] + // [START vision_product_search_delete_product] /** * Delete the product and all its reference images. * @@ -221,7 +196,7 @@ public static void deleteProduct(String projectId, String computeRegion, String System.out.println("Product deleted."); } - // [END product_search_delete_product] + // [END vision_product_search_delete_product] public static void main(String[] args) throws Exception { ProductManagement productManagement = new ProductManagement(); @@ -267,9 +242,6 @@ public void argsHelper(String[] args, PrintStream out) throws Exception { ns.getString("productDescription"), ns.getString("productLabels")); } - if (ns.get("command").equals("list_products")) { - listProducts(projectId, computeRegion); - } if (ns.get("command").equals("get_product")) { getProduct(projectId, computeRegion, ns.getString("productId")); } diff --git a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSearch.java b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSearch.java index 91abb208331..11f4f7767d5 100644 --- a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSearch.java +++ b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSearch.java @@ -16,7 +16,7 @@ package com.example.vision; -// [START product_search_import] +// [START vision_product_search_get_similar_products] import com.google.cloud.vision.v1p3beta1.AnnotateImageRequest; import com.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse; import com.google.cloud.vision.v1p3beta1.Feature; @@ -36,13 +36,13 @@ import java.util.Arrays; import java.util.List; +// [END vision_product_search_get_similar_products] import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParser; import net.sourceforge.argparse4j.inf.ArgumentParserException; import net.sourceforge.argparse4j.inf.Namespace; import net.sourceforge.argparse4j.inf.Subparser; import net.sourceforge.argparse4j.inf.Subparsers; -// [END product_search_import] /** * This application demonstrates how to perform similar product search operation in Cloud Vision @@ -54,7 +54,7 @@ public class ProductSearch { - // [START product_search_get_similar_products_file] + // [START vision_product_search_get_similar_products] /** * Search similar products to image. * @@ -130,7 +130,7 @@ public static void getSimilarProducts( System.out.println(String.format("Image name: %s", product.getImage())); } } - // [END product_search_get_similar_products_file] + // [END vision_product_search_get_similar_products] public static void main(String[] args) throws Exception { ProductSearch productSearch = new ProductSearch(); diff --git a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSetManagement.java b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSetManagement.java index ea362c43c91..3e06cc8e454 100644 --- a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSetManagement.java +++ b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSetManagement.java @@ -16,7 +16,11 @@ package com.example.vision; -// [START product_search_import] +// [START vision_product_search_create_product_set] +// [START vision_product_search_add_product_to_product_set] +// [START vision_product_search_delete_product_set] +// [START vision_product_search_list_product_sets] +// [START vision_product_search_get_product_set] import com.google.cloud.vision.v1p3beta1.CreateProductSetRequest; import com.google.cloud.vision.v1p3beta1.LocationName; import com.google.cloud.vision.v1p3beta1.Product; @@ -28,13 +32,17 @@ import java.io.IOException; import java.io.PrintStream; +// [END vision_product_search_create_product_set] +// [END vision_product_search_add_product_to_product_set] +// [END vision_product_search_delete_product_set] +// [END vision_product_search_list_product_sets] +// [END vision_product_search_get_product_set] import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParser; import net.sourceforge.argparse4j.inf.ArgumentParserException; import net.sourceforge.argparse4j.inf.Namespace; import net.sourceforge.argparse4j.inf.Subparser; import net.sourceforge.argparse4j.inf.Subparsers; -// [END product_search_import] /** * This application demonstrates how to perform basic operations on Product Sets. @@ -45,7 +53,7 @@ public class ProductSetManagement { - // [START product_search_create_product_set] + // [START vision_product_search_create_product_set] /** * Create a product set * @@ -76,9 +84,9 @@ public static void createProductSet( // Display the product set information System.out.println(String.format("Product set name: %s", productSet.getName())); } - // [END product_search_create_product_set] + // [END vision_product_search_create_product_set] - // [START product_search_list_product_sets] + // [START vision_product_search_list_product_sets] /** * List all product sets * @@ -107,9 +115,9 @@ public static void listProductSets(String projectId, String computeRegion) throw System.out.println(String.format("\tnanos: %s", productSet.getIndexTime().getNanos())); } } - // [END product_search_list_product_sets] + // [END vision_product_search_list_product_sets] - // [START product_search_get_product_set] + // [START vision_product_search_get_product_set] /** * Get info about the product set. * @@ -139,43 +147,9 @@ public static void getProductSet(String projectId, String computeRegion, String System.out.println(String.format("\tseconds: %s", productSet.getIndexTime().getSeconds())); System.out.println(String.format("\tnanos: %s", productSet.getIndexTime().getNanos())); } - // [END product_search_get_product_set] + // [END vision_product_search_get_product_set] - // [START product_search_list_products_in_product_set] - /** - * List all products in a product set. - * - * @param projectId - Id of the project. - * @param computeRegion - Region name. - * @param productSetId - Id of the product set. - * @throws IOException - on I/O errors. - */ - public static void listProductsInSet(String projectId, String computeRegion, String productSetId) - throws IOException { - ProductSearchClient client = ProductSearchClient.create(); - - // Get the full path of the product set. - ProductSetName productSetPath = ProductSetName.of(projectId, computeRegion, productSetId); - - // List all the products available in the product set. - for (Product product : - client.listProductsInProductSet(productSetPath.toString()).iterateAll()) { - // Display the product information - System.out.println(String.format("Product name: %s", product.getName())); - System.out.println( - String.format( - "Product id: %s", - product.getName().substring(product.getName().lastIndexOf('/') + 1))); - System.out.println(String.format("Product display name: %s", product.getDisplayName())); - System.out.println(String.format("Product description: %s", product.getDescription())); - System.out.println(String.format("Product category: %s", product.getProductCategory())); - System.out.println( - String.format("Product labels: %s\n", product.getProductLabelsList().toString())); - } - } - // [END product_search_list_products_in_product_set] - - // [START product_search_add_product_to_product_set] + // [START vision_product_search_add_product_to_product_set] /** * Add a product to a product set. * @@ -201,9 +175,9 @@ public static void addProductToSet( System.out.println(String.format("Product added to product set.")); } - // [END product_search_add_product_to_product_set] + // [END vision_product_search_add_product_to_product_set] - // [START product_search_delete_product_set] + // [START vision_product_search_delete_product_set] /** * Delete a product set. * @@ -224,7 +198,7 @@ public static void deleteProductSet( System.out.println(String.format("Product set deleted")); } - // [END product_search_delete_product_set] + // [END vision_product_search_delete_product_set] public static void main(String[] args) throws Exception { ProductSetManagement productSetManagement = new ProductSetManagement(); @@ -277,9 +251,6 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception { addProductToSet( projectId, computeRegion, ns.getString("productId"), ns.getString("productSetId")); } - if (ns.get("command").equals("list_products_in_product_set")) { - listProductsInSet(projectId, computeRegion, ns.getString("productSetId")); - } if (ns.get("command").equals("delete_product_set")) { deleteProductSet(projectId, computeRegion, ns.getString("productSetId")); } diff --git a/vision/product-search/cloud-client/src/main/java/com/example/vision/ReferenceImageManagement.java b/vision/product-search/cloud-client/src/main/java/com/example/vision/ReferenceImageManagement.java index 11a6164e5ec..dc277b7c9ea 100644 --- a/vision/product-search/cloud-client/src/main/java/com/example/vision/ReferenceImageManagement.java +++ b/vision/product-search/cloud-client/src/main/java/com/example/vision/ReferenceImageManagement.java @@ -17,7 +17,10 @@ package com.example.vision; -// [START product_search_import] +// [START vision_product_search_create_reference_image] +// [START vision_product_search_delete_reference_image] +// [START vision_product_search_list_reference_images] +// [START vision_product_search_get_reference_image] import com.google.cloud.vision.v1p3beta1.ProductName; import com.google.cloud.vision.v1p3beta1.ProductSearchClient; import com.google.cloud.vision.v1p3beta1.ReferenceImage; @@ -26,13 +29,16 @@ import java.io.IOException; import java.io.PrintStream; +// [END vision_product_search_create_reference_image] +// [END vision_product_search_delete_reference_image] +// [END vision_product_search_list_reference_images] +// [END vision_product_search_get_reference_image] import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParser; import net.sourceforge.argparse4j.inf.ArgumentParserException; import net.sourceforge.argparse4j.inf.Namespace; import net.sourceforge.argparse4j.inf.Subparser; import net.sourceforge.argparse4j.inf.Subparsers; -// [END product_search_import] /** * This application demonstrates how to perform basic operations on Reference Images in Cloud Vision @@ -44,7 +50,7 @@ public class ReferenceImageManagement { - // [START product_search_create_reference_image] + // [START vision_product_search_create_reference_image] /** * Create a reference image. * @@ -76,9 +82,9 @@ public static void createReferenceImage( System.out.println(String.format("Reference image name: %s", image.getName())); System.out.println(String.format("Reference image uri: %s", image.getUri())); } - // [END product_search_create_reference_image] + // [END vision_product_search_create_reference_image] - // [START product_search_list_reference_images] + // [START vision_product_search_list_reference_images] /** * List all images in a product. * @@ -107,9 +113,9 @@ public static void listReferenceImagesOfProduct( "Reference image bounding polygons: %s \n", image.getBoundingPolysList().toString())); } } - // [END product_search_list_reference_images] + // [END vision_product_search_list_reference_images] - // [START product_search_get_reference_image] + // [START vision_product_search_get_reference_image] /** * Get info about a reference image. * @@ -142,9 +148,9 @@ public static void getReferenceImage( String.format( "Reference image bounding polygons: %s \n", image.getBoundingPolysList().toString())); } - // [END product_search_get_reference_image] + // [END vision_product_search_get_reference_image] - // [START product_search_delete_reference_image] + // [START vision_product_search_delete_reference_image] /** * Delete a reference image. * @@ -167,7 +173,7 @@ public static void deleteReferenceImage( client.deleteReferenceImage(referenceImagePath.toString()); System.out.println("Reference image deleted from product."); } - // [END product_search_delete_reference_image] + // [END vision_product_search_delete_reference_image] public static void main(String[] args) throws Exception { ReferenceImageManagement referenceImageManagement = new ReferenceImageManagement(); From 2d4568993ddc234f5392b7e611a8118b7ee2b144 Mon Sep 17 00:00:00 2001 From: Alix Hamilton Date: Tue, 14 Aug 2018 15:26:45 -0700 Subject: [PATCH 14/17] fix label detection tag --- .../cloud-client/src/main/java/com/example/vision/Detect.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vision/cloud-client/src/main/java/com/example/vision/Detect.java b/vision/cloud-client/src/main/java/com/example/vision/Detect.java index eac655145a0..e57f8458fc0 100644 --- a/vision/cloud-client/src/main/java/com/example/vision/Detect.java +++ b/vision/cloud-client/src/main/java/com/example/vision/Detect.java @@ -291,7 +291,7 @@ public static void detectFacesGcs(String gcsPath, PrintStream out) throws Except * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ - // [START vision_logo_detection] + // [START vision_label_detection] public static void detectLabels(String filePath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>(); @@ -320,7 +320,7 @@ public static void detectLabels(String filePath, PrintStream out) throws Excepti } } } - // [END vision_logo_detection] + // [END vision_label_detection] /** * Detects labels in the specified remote image on Google Cloud Storage. From 9fdbd968764861680111cc78d9a793c47e9ff83b Mon Sep 17 00:00:00 2001 From: Alix Hamilton Date: Wed, 15 Aug 2018 10:57:14 -0700 Subject: [PATCH 15/17] remove region tags from imports --- .../example/vision/ProductInProductSetManagement.java | 6 ------ .../java/com/example/vision/ProductManagement.java | 8 -------- .../main/java/com/example/vision/ProductSearch.java | 2 -- .../java/com/example/vision/ProductSetManagement.java | 10 ---------- .../com/example/vision/ReferenceImageManagement.java | 8 -------- 5 files changed, 34 deletions(-) diff --git a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductInProductSetManagement.java b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductInProductSetManagement.java index 979fa8ff9c6..7cd472e578e 100644 --- a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductInProductSetManagement.java +++ b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductInProductSetManagement.java @@ -16,9 +16,6 @@ package com.example.vision; -// [START vision_product_search_remove_product_from_product_set] -// [START vision_product_search_list_products] -// [START vision_product_search_update_product_set] import com.google.cloud.vision.v1p3beta1.LocationName; import com.google.cloud.vision.v1p3beta1.Product; import com.google.cloud.vision.v1p3beta1.ProductName; @@ -31,9 +28,6 @@ import java.io.IOException; import java.io.PrintStream; -// [END vision_product_search_remove_product_from_product_set] -// [END vision_product_search_list_products] -// [END vision_product_search_update_product_set] import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParser; import net.sourceforge.argparse4j.inf.ArgumentParserException; diff --git a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductManagement.java b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductManagement.java index 269d37dc4d3..b1a37028cca 100644 --- a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductManagement.java +++ b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductManagement.java @@ -16,10 +16,6 @@ package com.example.vision; -// [START vision_product_search_create_product] -// [START vision_product_search_delete_product] -// [START vision_product_search_get_product] -// [START vision_product_search_update_product_labels] import com.google.cloud.vision.v1p3beta1.LocationName; import com.google.cloud.vision.v1p3beta1.Product; import com.google.cloud.vision.v1p3beta1.Product.KeyValue; @@ -30,10 +26,6 @@ import java.io.IOException; import java.io.PrintStream; -// [END vision_product_search_create_product] -// [END vision_product_search_delete_product] -// [END vision_product_search_get_product] -// [END vision_product_search_update_product_labels] import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParser; import net.sourceforge.argparse4j.inf.ArgumentParserException; diff --git a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSearch.java b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSearch.java index 11f4f7767d5..d36fa6e24c4 100644 --- a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSearch.java +++ b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSearch.java @@ -16,7 +16,6 @@ package com.example.vision; -// [START vision_product_search_get_similar_products] import com.google.cloud.vision.v1p3beta1.AnnotateImageRequest; import com.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse; import com.google.cloud.vision.v1p3beta1.Feature; @@ -36,7 +35,6 @@ import java.util.Arrays; import java.util.List; -// [END vision_product_search_get_similar_products] import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParser; import net.sourceforge.argparse4j.inf.ArgumentParserException; diff --git a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSetManagement.java b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSetManagement.java index 3e06cc8e454..e87ea90fc0b 100644 --- a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSetManagement.java +++ b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSetManagement.java @@ -16,11 +16,6 @@ package com.example.vision; -// [START vision_product_search_create_product_set] -// [START vision_product_search_add_product_to_product_set] -// [START vision_product_search_delete_product_set] -// [START vision_product_search_list_product_sets] -// [START vision_product_search_get_product_set] import com.google.cloud.vision.v1p3beta1.CreateProductSetRequest; import com.google.cloud.vision.v1p3beta1.LocationName; import com.google.cloud.vision.v1p3beta1.Product; @@ -32,11 +27,6 @@ import java.io.IOException; import java.io.PrintStream; -// [END vision_product_search_create_product_set] -// [END vision_product_search_add_product_to_product_set] -// [END vision_product_search_delete_product_set] -// [END vision_product_search_list_product_sets] -// [END vision_product_search_get_product_set] import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParser; import net.sourceforge.argparse4j.inf.ArgumentParserException; diff --git a/vision/product-search/cloud-client/src/main/java/com/example/vision/ReferenceImageManagement.java b/vision/product-search/cloud-client/src/main/java/com/example/vision/ReferenceImageManagement.java index dc277b7c9ea..7618b3d796c 100644 --- a/vision/product-search/cloud-client/src/main/java/com/example/vision/ReferenceImageManagement.java +++ b/vision/product-search/cloud-client/src/main/java/com/example/vision/ReferenceImageManagement.java @@ -17,10 +17,6 @@ package com.example.vision; -// [START vision_product_search_create_reference_image] -// [START vision_product_search_delete_reference_image] -// [START vision_product_search_list_reference_images] -// [START vision_product_search_get_reference_image] import com.google.cloud.vision.v1p3beta1.ProductName; import com.google.cloud.vision.v1p3beta1.ProductSearchClient; import com.google.cloud.vision.v1p3beta1.ReferenceImage; @@ -29,10 +25,6 @@ import java.io.IOException; import java.io.PrintStream; -// [END vision_product_search_create_reference_image] -// [END vision_product_search_delete_reference_image] -// [END vision_product_search_list_reference_images] -// [END vision_product_search_get_reference_image] import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParser; import net.sourceforge.argparse4j.inf.ArgumentParserException; From a2f5e6ac2c5b19e49a2294137fe9488e3e17fb7b Mon Sep 17 00:00:00 2001 From: Alix Hamilton Date: Wed, 15 Aug 2018 11:46:31 -0700 Subject: [PATCH 16/17] updates to mirror python files --- .../vision/ProductInProductSetManagement.java | 125 +++++------------- .../com/example/vision/ProductManagement.java | 34 +++++ .../example/vision/ProductSetManagement.java | 39 ------ 3 files changed, 67 insertions(+), 131 deletions(-) diff --git a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductInProductSetManagement.java b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductInProductSetManagement.java index 7cd472e578e..e040d33b26b 100644 --- a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductInProductSetManagement.java +++ b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductInProductSetManagement.java @@ -22,7 +22,6 @@ import com.google.cloud.vision.v1p3beta1.ProductSearchClient; import com.google.cloud.vision.v1p3beta1.ProductSet; import com.google.cloud.vision.v1p3beta1.ProductSetName; -import com.google.cloud.vision.v1p3beta1.UpdateProductSetRequest; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -44,57 +43,9 @@ public class ProductInProductSetManagement { - // [START vision_product_search_update_product_set] + // [START vision_product_search_add_product_to_product_set] /** - * Update a product set. - * - * @param projectId - Id of the project. - * @param computeRegion - Region name. - * @param productSetId - Id of the product set. - * @param productSetDisplayName - Display name of the product set. - * @throws IOException - on I/O errors. - */ - public static void updateProductSet( - String projectId, String computeRegion, String productSetId, String productSetDisplayName) - throws IOException { - ProductSearchClient client = ProductSearchClient.create(); - - // Get the full path of the product set. - String productSetPath = ProductSetName.of(projectId, computeRegion, productSetId).toString(); - - // Update the product set display name. - ProductSet productSet = - ProductSet.newBuilder() - .setName(productSetPath) - .setDisplayName(productSetDisplayName) - .build(); - - FieldMask updateMask = FieldMask.newBuilder().addPaths("display_name").build(); - - UpdateProductSetRequest request = - UpdateProductSetRequest.newBuilder() - .setProductSet(productSet) - .setUpdateMask(updateMask) - .build(); - - ProductSet updatedProductSet = client.updateProductSet(request); - - // Display the updated set information - System.out.println(String.format("Product set name: %s", updatedProductSet.getName())); - System.out.println( - String.format( - "Product set id: %s", - updatedProductSet - .getName() - .substring(updatedProductSet.getName().lastIndexOf('/') + 1))); - System.out.println( - String.format("Updated product set display name: %s", updatedProductSet.getDisplayName())); - } - // [END vision_product_search_update_product_set] - - // [START vision_product_search_remove_product_from_product_set] - /** - * Remove a product from a product set. + * Add a product to a product set. * * @param projectId - Id of the project. * @param computeRegion - Region name. @@ -102,7 +53,7 @@ public static void updateProductSet( * @param productSetId - Id of the product set. * @throws IOException - on I/O errors. */ - public static void removeProductFromProductSet( + public static void addProductToSet( String projectId, String computeRegion, String productId, String productSetId) throws IOException { ProductSearchClient client = ProductSearchClient.create(); @@ -113,12 +64,12 @@ public static void removeProductFromProductSet( // Get the full path of the product. String productPath = ProductName.of(projectId, computeRegion, productId).toString(); - // Remove the product from the product set. - client.removeProductFromProductSet(productSetPath, productPath); + // Add the product to the product set. + client.addProductToProductSet(productSetPath, productPath); - System.out.println(String.format("Product removed from product set.")); + System.out.println(String.format("Product added to product set.")); } - // [END vision_product_search_remove_product_from_product_set] + // [END vision_product_search_add_product_to_product_set] // [START vision_product_search_list_products_in_product_set] /** @@ -154,36 +105,33 @@ public static void listProductsInProductSet( } // [END vision_product_search_list_products_in_product_set] - // [START vision_product_search_list_products] + // [START vision_product_search_remove_product_from_product_set] /** - * List all products. + * Remove a product from a product set. * * @param projectId - Id of the project. * @param computeRegion - Region name. + * @param productId - Id of the product. + * @param productSetId - Id of the product set. * @throws IOException - on I/O errors. */ - public static void listProducts(String projectId, String computeRegion) throws IOException { + public static void removeProductFromProductSet( + String projectId, String computeRegion, String productId, String productSetId) + throws IOException { ProductSearchClient client = ProductSearchClient.create(); - // A resource that represents Google Cloud Platform location. - LocationName projectLocation = LocationName.of(projectId, computeRegion); + // Get the full path of the product set. + ProductSetName productSetPath = ProductSetName.of(projectId, computeRegion, productSetId); - // List all the products available in the region. - for (Product product : client.listProducts(projectLocation).iterateAll()) { - // Display the product information - System.out.println(String.format("\nProduct name: %s", product.getName())); - System.out.println( - String.format( - "Product id: %s", - product.getName().substring(product.getName().lastIndexOf('/') + 1))); - System.out.println(String.format("Product display name: %s", product.getDisplayName())); - System.out.println(String.format("Product category: %s", product.getProductCategory())); - System.out.println("Product labels:"); - System.out.println( - String.format("Product labels: %s", product.getProductLabelsList().toString())); - } + // Get the full path of the product. + String productPath = ProductName.of(projectId, computeRegion, productId).toString(); + + // Remove the product from the product set. + client.removeProductFromProductSet(productSetPath, productPath); + + System.out.println(String.format("Product removed from product set.")); } - // [END vision_product_search_list_products] + // [END vision_product_search_remove_product_from_product_set] public static void main(String[] args) throws Exception { ProductInProductSetManagement productInProductSetManagement = @@ -194,15 +142,14 @@ public static void main(String[] args) throws Exception { public static void argsHelper(String[] args, PrintStream out) throws Exception { ArgumentParser parser = ArgumentParsers.newFor("").build(); Subparsers subparsers = parser.addSubparsers().dest("command"); - subparsers.addParser("list_products"); + + Subparser addProductParser = subparsers.addParser("add_product_to_product_set"); + addProductParser.addArgument("productSetId"); + addProductParser.addArgument("productId"); Subparser listProductInProductSetParser = subparsers.addParser("list_products_in_product_set"); listProductInProductSetParser.addArgument("productSetId"); - Subparser updateProductSetParser = subparsers.addParser("update_product_set"); - updateProductSetParser.addArgument("productSetId"); - updateProductSetParser.addArgument("productSetDisplayName"); - Subparser removeProductFromProductSetParser = subparsers.addParser("remove_product_from_product_set"); removeProductFromProductSetParser.addArgument("productId"); @@ -214,23 +161,17 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception { Namespace ns = null; try { ns = parser.parseArgs(args); - if (ns.get("command").equals("list_products")) { - listProducts(projectId, computeRegion); + if (ns.get("command").equals("add_product_to_product_set")) { + addProductToSet( + projectId, computeRegion, ns.getString("productId"), ns.getString("productSetId")); } - if (ns.get("command").equals("update_product_set")) { - updateProductSet( - projectId, - computeRegion, - ns.getString("productSetId"), - ns.getString("productSetDisplayName")); + if (ns.get("command").equals("list_products_in_product_set")) { + listProductsInProductSet(projectId, computeRegion, ns.getString("productSetId")); } if (ns.get("command").equals("remove_product_from_product_set")) { removeProductFromProductSet( projectId, computeRegion, ns.getString("productId"), ns.getString("productSetId")); } - if (ns.get("command").equals("list_products_in_product_set")) { - listProductsInProductSet(projectId, computeRegion, ns.getString("productSetId")); - } } catch (ArgumentParserException e) { parser.handleError(e); diff --git a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductManagement.java b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductManagement.java index b1a37028cca..0d6661913d1 100644 --- a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductManagement.java +++ b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductManagement.java @@ -90,6 +90,37 @@ public static void createProduct( } // [END vision_product_search_create_product] + // [START vision_product_search_list_products] + /** + * List all products. + * + * @param projectId - Id of the project. + * @param computeRegion - Region name. + * @throws IOException - on I/O errors. + */ + public static void listProducts(String projectId, String computeRegion) throws IOException { + ProductSearchClient client = ProductSearchClient.create(); + + // A resource that represents Google Cloud Platform location. + LocationName projectLocation = LocationName.of(projectId, computeRegion); + + // List all the products available in the region. + for (Product product : client.listProducts(projectLocation).iterateAll()) { + // Display the product information + System.out.println(String.format("\nProduct name: %s", product.getName())); + System.out.println( + String.format( + "Product id: %s", + product.getName().substring(product.getName().lastIndexOf('/') + 1))); + System.out.println(String.format("Product display name: %s", product.getDisplayName())); + System.out.println(String.format("Product category: %s", product.getProductCategory())); + System.out.println("Product labels:"); + System.out.println( + String.format("Product labels: %s", product.getProductLabelsList().toString())); + } + } + // [END vision_product_search_list_products] + // [START vision_product_search_get_product] /** * Get information about a product. @@ -234,6 +265,9 @@ public void argsHelper(String[] args, PrintStream out) throws Exception { ns.getString("productDescription"), ns.getString("productLabels")); } + if (ns.get("command").equals("list_products")) { + listProducts(projectId, computeRegion); + } if (ns.get("command").equals("get_product")) { getProduct(projectId, computeRegion, ns.getString("productId")); } diff --git a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSetManagement.java b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSetManagement.java index e87ea90fc0b..d5ed87955fb 100644 --- a/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSetManagement.java +++ b/vision/product-search/cloud-client/src/main/java/com/example/vision/ProductSetManagement.java @@ -139,34 +139,6 @@ public static void getProductSet(String projectId, String computeRegion, String } // [END vision_product_search_get_product_set] - // [START vision_product_search_add_product_to_product_set] - /** - * Add a product to a product set. - * - * @param projectId - Id of the project. - * @param computeRegion - Region name. - * @param productId - Id of the product. - * @param productSetId - Id of the product set. - * @throws IOException - on I/O errors. - */ - public static void addProductToSet( - String projectId, String computeRegion, String productId, String productSetId) - throws IOException { - ProductSearchClient client = ProductSearchClient.create(); - - // Get the full path of the product set. - ProductSetName productSetPath = ProductSetName.of(projectId, computeRegion, productSetId); - - // Get the full path of the product. - String productPath = ProductName.of(projectId, computeRegion, productId).toString(); - - // Add the product to the product set. - client.addProductToProductSet(productSetPath, productPath); - - System.out.println(String.format("Product added to product set.")); - } - // [END vision_product_search_add_product_to_product_set] - // [START vision_product_search_delete_product_set] /** * Delete a product set. @@ -203,18 +175,11 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception { createProductSetParser.addArgument("productSetId"); createProductSetParser.addArgument("productSetDisplayName"); - Subparser addProductParser = subparsers.addParser("add_product_to_product_set"); - addProductParser.addArgument("productSetId"); - addProductParser.addArgument("productId"); - subparsers.addParser("list_product_sets"); Subparser getProductSetParser = subparsers.addParser("get_product_set"); getProductSetParser.addArgument("productSetId"); - Subparser listProductsInProductSetParser = subparsers.addParser("list_products_in_product_set"); - listProductsInProductSetParser.addArgument("productSetId"); - Subparser deleteProductSetParser = subparsers.addParser("delete_product_set"); deleteProductSetParser.addArgument("productSetId"); @@ -237,10 +202,6 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception { if (ns.get("command").equals("get_product_set")) { getProductSet(projectId, computeRegion, ns.getString("productSetId")); } - if (ns.get("command").equals("add_product_to_product_set")) { - addProductToSet( - projectId, computeRegion, ns.getString("productId"), ns.getString("productSetId")); - } if (ns.get("command").equals("delete_product_set")) { deleteProductSet(projectId, computeRegion, ns.getString("productSetId")); } From 81fa84bed6433fd2ceee806736ecd72ffd953c1d Mon Sep 17 00:00:00 2001 From: nnegrey Date: Wed, 15 Aug 2018 13:15:19 -0700 Subject: [PATCH 17/17] Fix indentation --- .../src/main/java/com/example/vision/Detect.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vision/cloud-client/src/main/java/com/example/vision/Detect.java b/vision/cloud-client/src/main/java/com/example/vision/Detect.java index e57f8458fc0..2332828db2c 100644 --- a/vision/cloud-client/src/main/java/com/example/vision/Detect.java +++ b/vision/cloud-client/src/main/java/com/example/vision/Detect.java @@ -1214,9 +1214,9 @@ public static void detectCropHintsGcs(String gcsPath, PrintStream out) throws Ex * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ - // [START vision_fulltext_detection] - public static void detectDocumentText(String filePath, PrintStream out) throws Exception, - IOException { + // [START vision_fulltext_detection] + public static void detectDocumentText(String filePath, PrintStream out) throws Exception, + IOException { List requests = new ArrayList<>(); ByteString imgBytes = ByteString.readFrom(new FileInputStream(filePath)); @@ -1279,8 +1279,8 @@ public static void detectDocumentText(String filePath, PrintStream out) throws E * @throws Exception on errors while closing the client. * @throws IOException on Input/Output errors. */ - // [START vision_fulltext_detection_gcs] - public static void detectDocumentTextGcs(String gcsPath, PrintStream out) throws Exception, + // [START vision_fulltext_detection_gcs] + public static void detectDocumentTextGcs(String gcsPath, PrintStream out) throws Exception, IOException { List requests = new ArrayList<>();