Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么EntityAnnotation类的getScore()api始终返回零?_Java_Google Cloud Platform_Ocr_Google Vision - Fatal编程技术网

Java 为什么EntityAnnotation类的getScore()api始终返回零?

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

我正在使用GoogleVisionAPI对图像进行文本检测,并以JSON格式给出响应。所以这个响应属于com.google.cloud.vision.v1.EntityAnnotation.From EntityAnnotation对象,我正在尝试使用EntityAnnotation的getScore获取值。但每次它返回0时,我希望得到一些浮点值,而不仅仅是0。有没有人面临过类似的问题?要了解google vision文本检测api,您可以浏览此帮助。谢谢

我用google vision api提供的标签检测标签尝试了相同的输入。为此,它返回一些介于0到1之间的值,而不仅仅是零。但它不适用于文本检测标记的相同输入。我在windows-10上进行了测试

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();

文本检测没有得分。尝试展开响应以查看返回用于文本检测的属性示例:

你可能会对和感兴趣,而这已经发生了