我正在使用 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文档,但找不到解决方案。
我找到了解决办法。原因是模型代码..我改变如下
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;
}
这是一个简单的问题,这是我的错误