Google Vision API TEXT_DETECTION 文本注释为空

问题描述 投票:0回答:1

我正在使用 Google Vision API

TEXT_DETECTION
(使用 Java) 我回复成功了。才成功
fullTextAnnotation
。 并且
textAnnotation
是空的..我不知道为什么

我使用 Vision API REST 和 Retrofit2。

下面是响应 json:

{
    "responses": [
        {
            "fullTextAnnotation": {
                //successful
            },
            "textAnnotations": [
                {},
                {},
                {},
                {},
                {},
                {},
                {},
                {},
                {},
                {},
                {},
                {},
                {},
                {}
            ]
        }
    ]
}

这是java模型代码:

//Root class
//...

class Response {
    @SerializedName("textAnnotations")
    List<TextAnnotations> textAnnotations;
    @SerializedName("fullTextAnnotation")
    FullTextAnnotation fullTextAnnotation;
}

class TextAnnotations {
    InTextAnnotationWithLocale inTextAnnotationWithLocale;
    List<InTextAnnotation> inTextAnnotations;
}

class InTextAnnotationWithLocale {
    @SerializedName("locale")
    String locale;
    @SerializedName("description")
    String description;
    @SerializedName("boundingPoly")
    BoundingPoly boundingPoly;
}

class InTextAnnotation {
    @SerializedName("description")
    String description;
    @SerializedName("boundingPoly")
    BoundingPoly boundingPoly;
}

class BoundingPoly {
    @SerializedName("vertices")
    List<Vertex> vertices;
}

class Vertex {
    @SerializedName("x")
    int x;
    @SerializedName("y")
    int y;
}

//fullTextAnnotation
//...

我搜索vision api文档,但找不到解决方案。

java google-cloud-platform google-vision
1个回答
0
投票

我找到了解决办法。原因是模型代码..我改变如下

class Response {
    @SerializedName("textAnnotations")
    List<TextAnnotation> textAnnotations;
    @SerializedName("fullTextAnnotation")
    FullTextAnnotation fullTextAnnotation;
}

class TextAnnotation {
    @SerializedName("locale")
    String locale;
    @SerializedName("description")
    String description;
    @SerializedName("boundingPoly")
    BoundingPoly boundingPoly;
}

这是一个简单的问题,这是我的错误

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.