Java 为什么EntityAnnotation类的getScore()api始终返回零?
我正在使用GoogleVisionAPI对图像进行文本检测,并以JSON格式给出响应。所以这个响应属于com.google.cloud.vision.v1.EntityAnnotation.From EntityAnnotation对象,我正在尝试使用EntityAnnotation的getScore获取值。但每次它返回0时,我希望得到一些浮点值,而不仅仅是0。有没有人面临过类似的问题?要了解google vision文本检测api,您可以浏览此帮助。谢谢 我用google vision api提供的标签检测标签尝试了相同的输入。为此,它返回一些介于0到1之间的值,而不仅仅是零。但它不适用于文本检测标记的相同输入。我在windows-10上进行了测试Java 为什么EntityAnnotation类的getScore()api始终返回零?,java,google-cloud-platform,ocr,google-vision,Java,Google Cloud Platform,Ocr,Google Vision,我正在使用GoogleVisionAPI对图像进行文本检测,并以JSON格式给出响应。所以这个响应属于com.google.cloud.vision.v1.EntityAnnotation.From EntityAnnotation对象,我正在尝试使用EntityAnnotation的getScore获取值。但每次它返回0时,我希望得到一些浮点值,而不仅仅是0。有没有人面临过类似的问题?要了解google vision文本检测api,您可以浏览此帮助。谢谢 我用google vision api
try (FileInputStream inputStream = new FileInputStream(filePath); ImageAnnotatorClient client = ImageAnnotatorClient.create()) {
final ByteString imageBytes = ByteString.readFrom(inputStream);
final Image image = Image.newBuilder().setContent(imageBytes).build();
final Feature feature = Feature.newBuilder().setType(TEXT_DETECTION).build();
final AnnotateImageRequest request = AnnotateImageRequest.newBuilder().addFeatures(feature).setImage(image)
.build();
requests.add(request);
final BatchAnnotateImagesResponse response = client.batchAnnotateImages(requests);
final List < AnnotateImageResponse > responseList = response.getResponsesList();
result = responseList.get(0).getTextAnnotationsList();
}
final EntityAnnotation annotation = result.get(0);
final Float score = annotation.getScore();
文本检测没有得分。尝试展开响应以查看返回用于文本检测的属性示例: 你可能会对和感兴趣,而这已经发生了