因此,我正在使用 Google Cloud Vision API 制作一个 java 应用程序,该方法将许多 DEBUG 日志返回到我的控制台。我想禁用它们,但我不知道如何。我得到这个输出https://pastebin.com/gVVJprhV
这是我的代码
public String googleapi(String image) throws IOException, Exception {
List<AnnotateImageRequest> requests = new ArrayList<>();
ByteString imgBytes = ByteString.readFrom(new FileInputStream(image));
Image img = Image.newBuilder().setContent(imgBytes).build();
Feature feat = Feature.newBuilder().setType(Type.TEXT_DETECTION).build();
AnnotateImageRequest request =
AnnotateImageRequest.newBuilder().addFeatures(feat).setImage(img).build();
requests.add(request);
String question = null;
try (ImageAnnotatorClient client = ImageAnnotatorClient.create()) {
BatchAnnotateImagesResponse response = client.batchAnnotateImages(requests);
List<AnnotateImageResponse> responses = response.getResponsesList();
for (AnnotateImageResponse res : responses) {
if (res.hasError()) {
//System.out.printf("Error: %s\n", res.getError().getMessage());
System.out.println("Se ta bom, n mexas");
return null;
}
EntityAnnotation annotation = res.getTextAnnotations(0);
question = annotation.getDescription();
question = question.replaceAll("\n", " ");
}
}
return question;
}
我不知道为什么它会抛出所有这些调试,但我想禁用它。提前致谢。