GeezerVison is showing github.com — getLabelAnnotationsList is returning empty map · Issue #2031 · googleapis/google-cloud-java
getLabelAnnotationsList is returning empty map #2031Labels api: visionIssues related to the Cloud Vision API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. DescriptionIn which file did you encounter the issue?
java-docs-samples/vision/cloud-client/src/main/java/com/example/vision/QuickstartSample.java
Did you change the file? If so, how?
no. running on Tomcat 7 in java 1.8
Describe the issue
EntityAnnotation annotation : res.getLabelAnnotationsList()
there are no items in that. It was working fine some time back, now stopped working. I'm using:
com.google.cloud
google-cloud-vision
0.17.1-beta Activityshinfan commented on May 8, 2017 For now gRPC does not support Tomcat well. We should update the doc of supported env #2039 gguuss commented on May 8, 2017 I'll see if what I can repro on Tomcat, for my tests, I'm always seeing labels returned from label annotation queries. garrettjonesgoogle commented on May 31, 2017 @gguuss did you get a chance to repro? added type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed on May 31, 2017changed the title [-]getLabelAnnotationsList is returing empty map[/-] [+]getLabelAnnotationsList is returning empty map[/+] on May 31, 2017gguuss commented on May 31, 2017 I was actually unable to repro. The following code successfully performs a request from a JSP on tomcat. All you need to do is put a jar containing all the client library dependencies in to the tomcat /lib folder from where you're serving (e.g. mvn compile assembly:single for the cloud-client sample and copy target/vision-google-cloud-samples-1.0.0-jar-with-dependencies.jar into /lib/ for your Tomcat directory. Of note, I'm using Tomcat 8.5.14 installed from homebrew on OSX.
<%@ page import="com.google.cloud.vision.spi.v1.ImageAnnotatorClient, com.google.cloud.vision.spi.v1.ImageAnnotatorSettings, com.google.cloud.vision.v1.AnnotateImageRequest, com.google.cloud.vision.v1.AnnotateImageResponse, com.google.cloud.vision.v1.BatchAnnotateImagesResponse, com.google.cloud.vision.v1.Block, com.google.cloud.vision.v1.ColorInfo, com.google.cloud.vision.v1.CropHint, com.google.cloud.vision.v1.CropHintsAnnotation, com.google.cloud.vision.v1.DominantColorsAnnotation, com.google.cloud.vision.v1.EntityAnnotation, com.google.cloud.vision.v1.FaceAnnotation, com.google.cloud.vision.v1.Feature, com.google.cloud.vision.v1.Feature.Type, com.google.cloud.vision.v1.Image, com.google.cloud.vision.v1.ImageSource, com.google.cloud.vision.v1.LocationInfo, com.google.cloud.vision.v1.Page, com.google.cloud.vision.v1.Paragraph, com.google.cloud.vision.v1.SafeSearchAnnotation, com.google.cloud.vision.v1.Symbol, com.google.cloud.vision.v1.TextAnnotation, com.google.cloud.vision.v1.WebDetection, com.google.cloud.vision.v1.WebDetection.WebEntity, com.google.cloud.vision.v1.WebDetection.WebImage, com.google.cloud.vision.v1.WebDetection.WebPage, com.google.cloud.vision.v1.Word, com.google.protobuf.ByteString, org.threeten.bp.Duration, java.io.FileInputStream, java.io.IOException, java.io.PrintStream, java.util.ArrayList, java.util.List" %>
<% String gcsPath = "gs://cloud-samples-tests/vision/face_no_surprise.jpg"; %>
<html>
<head>
<title>
I know JSP: <%=request.getServletContext().getServerInfo()%>
</title>
</head>
<body>
<h1>Hello Vision!</h1>
This is where the action happen.
<hr>
Performing face detection on <%=gcsPath%>
<%
List<AnnotateImageRequest> reqs = new ArrayList<>();
ImageAnnotatorSettings.Builder imageAnnotatorSettingsBuilder =
ImageAnnotatorSettings.defaultBuilder();
imageAnnotatorSettingsBuilder
.batchAnnotateImagesSettings()
.getRetrySettingsBuilder()
.setTotalTimeout(Duration.ofSeconds(30));
ImageAnnotatorSettings settings = imageAnnotatorSettingsBuilder.build();
ImageSource imgSource = ImageSource.newBuilder().setGcsImageUri(gcsPath).build();
Image img = Image.newBuilder().setSource(imgSource).build();
Feature feat = Feature.newBuilder().setType(Type.FACE_DETECTION).build();
AnnotateImageRequest req =
AnnotateImageRequest.newBuilder().addFeatures(feat).setImage(img).build();
reqs.add(req);
ImageAnnotatorClient client = ImageAnnotatorClient.create(settings);
BatchAnnotateImagesResponse resp = client.batchAnnotateImages(reqs);
List<AnnotateImageResponse> responses = resp.getResponsesList();
for (AnnotateImageResponse res : responses) {
if (res.hasError()) {
%>Error!!!! <%=res.getError().getMessage()%><%
break;
}
// For full list of available annotations, see http://g.co/cloud/vision/docs
for (FaceAnnotation annotation : res.getFaceAnnotationsList()) {
%><p>Anger: <%=annotation.getAngerLikelihood()%><%
%><p>Joy: <%=annotation.getSurpriseLikelihood()%><%
%><p>Poly: <%=annotation.getBoundingPoly()%><%
}
}
%>
</body>
</html>
garrettjonesgoogle commented on Jul 18, 2017 Closing out since we are unable to repro.
MetadataMetadataapi: visionIssues related to the Cloud Vision API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. DevelopmentNo branches or pull requestsIssue actions
|