Skip to content

Commit

Permalink
samples: Vision region tag update (#1182)
Browse files Browse the repository at this point in the history
* updates region tags for detecting-crop-hints page

* updates region tags for detecting-faces page

* updates region tags for detecting-fulltext page

* updates region tags for detecting-labels page

* updates region tags for detecting-landmarks page

* update region tags for detect-logos page

* update region tags for detecting-properties page

* update region tags for detecting-safe-search page

* update region tags for detecting-text page

* update region tags for detecting-web page

* update beta tags to standard

* update PDF detection region tags to standard

* updates product search region tags to standard

* fix label detection tag

* remove region tags from imports

* updates to mirror python files

* Fix indentation
  • Loading branch information
alixhami authored and chingor13 committed Aug 13, 2020
1 parent 5ddaadc commit 224a4cd
Showing 1 changed file with 47 additions and 19 deletions.
66 changes: 47 additions & 19 deletions vision/snippets/src/main/java/com/example/vision/Detect.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<AnnotateImageRequest> requests = new ArrayList<>();

Expand Down Expand Up @@ -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.
Expand All @@ -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<AnnotateImageRequest> requests = new ArrayList<>();
Expand Down Expand Up @@ -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.
Expand All @@ -287,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_label_detection]
public static void detectLabels(String filePath, PrintStream out) throws Exception, IOException {
List<AnnotateImageRequest> requests = new ArrayList<>();

Expand Down Expand Up @@ -315,6 +320,7 @@ public static void detectLabels(String filePath, PrintStream out) throws Excepti
}
}
}
// [END vision_label_detection]

/**
* Detects labels in the specified remote image on Google Cloud Storage.
Expand All @@ -325,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<AnnotateImageRequest> requests = new ArrayList<>();
Expand Down Expand Up @@ -354,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.
Expand All @@ -363,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<AnnotateImageRequest> requests = new ArrayList<>();
Expand Down Expand Up @@ -392,6 +401,7 @@ public static void detectLandmarks(String filePath, PrintStream out) throws Exce
}
}
}
// [END vision_landmark_detection]

/**
* Detects landmarks in the specified URI.
Expand Down Expand Up @@ -440,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<AnnotateImageRequest> requests = new ArrayList<>();
Expand Down Expand Up @@ -469,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.
Expand All @@ -478,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<AnnotateImageRequest> requests = new ArrayList<>();

Expand Down Expand Up @@ -506,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.
Expand All @@ -516,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<AnnotateImageRequest> requests = new ArrayList<>();
Expand Down Expand Up @@ -544,6 +559,7 @@ public static void detectLogosGcs(String gcsPath, PrintStream out) throws Except
}
}
}
// [END vision_logo_detection_gcs]

/**
* Detects text in the specified image.
Expand All @@ -553,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<AnnotateImageRequest> requests = new ArrayList<>();

Expand Down Expand Up @@ -582,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.
Expand All @@ -591,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<AnnotateImageRequest> requests = new ArrayList<>();

Expand Down Expand Up @@ -619,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.
Expand All @@ -628,6 +648,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<AnnotateImageRequest> requests = new ArrayList<>();
Expand Down Expand Up @@ -663,6 +684,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
Expand All @@ -673,6 +695,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<AnnotateImageRequest> requests = new ArrayList<>();
Expand Down Expand Up @@ -707,8 +730,8 @@ 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.
*
Expand All @@ -717,6 +740,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<AnnotateImageRequest> requests = new ArrayList<>();
Expand Down Expand Up @@ -751,9 +775,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.
Expand All @@ -763,6 +786,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<AnnotateImageRequest> requests = new ArrayList<>();
Expand Down Expand Up @@ -796,9 +820,9 @@ 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]
// [START vision_web_detection]
/**
* Finds references to the specified image on the web.
*
Expand Down Expand Up @@ -861,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.
Expand Down Expand Up @@ -926,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.
Expand Down Expand Up @@ -1001,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.
Expand Down Expand Up @@ -1048,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
Expand Down Expand Up @@ -1099,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.
Expand All @@ -1109,6 +1133,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<AnnotateImageRequest> requests = new ArrayList<>();
Expand Down Expand Up @@ -1139,6 +1164,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.
Expand All @@ -1148,6 +1174,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<AnnotateImageRequest> requests = new ArrayList<>();
Expand Down Expand Up @@ -1177,8 +1204,8 @@ 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.
*
Expand All @@ -1187,8 +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 {
IOException {
List<AnnotateImageRequest> requests = new ArrayList<>();

ByteString imgBytes = ByteString.readFrom(new FileInputStream(filePath));
Expand Down Expand Up @@ -1241,9 +1269,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.
*
Expand All @@ -1252,6 +1279,7 @@ 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,
IOException {
List<AnnotateImageRequest> requests = new ArrayList<>();
Expand Down Expand Up @@ -1304,9 +1332,9 @@ 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]
// [START vision_text_detection_pdf_gcs]
/**
* Performs document text OCR with PDF/TIFF as source files on Google Cloud Storage.
*
Expand Down Expand Up @@ -1423,5 +1451,5 @@ public static void detectDocumentsGcs(String gcsSourcePath, String gcsDestinatio
}
}
}
// [END vision_async_detect_document_ocr]
// [END vision_text_detection_pdf_gcs]
}

0 comments on commit 224a4cd

Please sign in to comment.