Codota Logo
org.springframework.cloud.gcp.vision
Code IndexAdd Codota to your IDE (free)

How to use org.springframework.cloud.gcp.vision

Best Java code snippets using org.springframework.cloud.gcp.vision (Showing top 7 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Connection c =
  • Codota IconDataSource dataSource;dataSource.getConnection()
  • Codota IconString url;DriverManager.getConnection(url)
  • Codota IconIdentityDatabaseUtil.getDBConnection()
  • Smart code suggestions by Codota
}
origin: spring-cloud/spring-cloud-gcp

@GetMapping("/extractText")
public String extractText(String imageUrl) {
  String textFromImage = this.cloudVisionTemplate.extractTextFromImage(
      this.resourceLoader.getResource(imageUrl));
  return "Text from image: " + textFromImage;
}
origin: spring-cloud/spring-cloud-gcp

@Bean
@ConditionalOnMissingBean
public CloudVisionTemplate cloudVisionTemplate(ImageAnnotatorClient imageAnnotatorClient) {
  return new CloudVisionTemplate(imageAnnotatorClient);
}
origin: spring-cloud/spring-cloud-gcp

/**
 * Extract the text out of an image and return the result as a String.
 * @param imageResource the image one wishes to analyze
 * @return the text extracted from the image aggregated to a String
 * @throws CloudVisionException if the image could not be read or if text extraction failed
 */
public String extractTextFromImage(Resource imageResource) {
  AnnotateImageResponse response = analyzeImage(imageResource, Type.TEXT_DETECTION);
  String result = response.getFullTextAnnotation().getText();
  if (result.isEmpty() && response.getError().getCode() != Code.OK.getNumber()) {
    throw new CloudVisionException(response.getError().getMessage());
  }
  return result;
}
origin: spring-cloud/spring-cloud-gcp

/**
 * This method downloads an image from a URL and sends its contents to the Vision API for label detection.
 *
 * @param imageUrl the URL of the image
 * @param map the model map to use
 * @return a string with the list of labels and percentage of certainty
 * @throws CloudVisionTemplate if the Vision API call produces an error
 */
@GetMapping("/extractLabels")
public ModelAndView extractLabels(String imageUrl, ModelMap map) {
  AnnotateImageResponse response = this.cloudVisionTemplate.analyzeImage(
      this.resourceLoader.getResource(imageUrl), Type.LABEL_DETECTION);
  Map<String, Float> imageLabels =
      response.getLabelAnnotationsList()
          .stream()
          .collect(Collectors.toMap(
              EntityAnnotation::getDescription, EntityAnnotation::getScore));
  map.addAttribute("annotations", imageLabels);
  map.addAttribute("imageUrl", imageUrl);
  return new ModelAndView("result", map);
}
origin: spring-cloud/spring-cloud-gcp

throw new CloudVisionException("Failed to read image bytes from provided resource.", ex);
throw new CloudVisionException(
    "Failed to receive valid response Vision APIs; empty response received.");
origin: org.springframework.cloud/spring-cloud-gcp-vision

/**
 * Extract the text out of an image and return the result as a String.
 * @param imageResource the image one wishes to analyze
 * @return the text extracted from the image aggregated to a String
 * @throws CloudVisionTemplate if the image could not be read or if text extraction failed
 */
public String extractTextFromImage(Resource imageResource) {
  AnnotateImageResponse response = analyzeImage(imageResource, Type.TEXT_DETECTION);
  String result = response.getFullTextAnnotation().getText();
  if (result.isEmpty() && response.getError().getCode() != Code.OK.getNumber()) {
    throw new CloudVisionException(response.getError().getMessage());
  }
  return result;
}
origin: org.springframework.cloud/spring-cloud-gcp-vision

throw new CloudVisionException("Failed to read image bytes from provided resource.", ex);
throw new CloudVisionException(
    "Failed to receive valid response Vision APIs; empty response received.");
org.springframework.cloud.gcp.vision

Most used classes

  • CloudVisionTemplate
    Spring Template offering convenience methods for interacting with the Cloud Vision APIs.
  • CloudVisionException
    Describes error conditions that can occur when interfacing with Cloud Vision APIs.
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now