Java google cloud vision api OCR边界框
我使用了谷歌云视觉api 我只想识别图像的某些部分 通过坐标输入进行ocr分析。。 (如果我在图像中找到坐标) 谷歌的例子中没有Java google cloud vision api OCR边界框,java,coordinates,ocr,vertices,vision-api,Java,Coordinates,Ocr,Vertices,Vision Api,我使用了谷歌云视觉api 我只想识别图像的某些部分 通过坐标输入进行ocr分析。。 (如果我在图像中找到坐标) 谷歌的例子中没有 有可能吗?是的,有可能,这里我留下一部分代码,您可以试试, 主要的事情是找到你要处理的字段的顶点“x”和“y” try (ImageAnnotatorClient client = ImageAnnotatorClient.create()) { BatchAnnotateImagesResponse response = client.batchAn
有可能吗?是的,有可能,这里我留下一部分代码,您可以试试, 主要的事情是找到你要处理的字段的顶点“x”和“y”
try (ImageAnnotatorClient client = ImageAnnotatorClient.create()) {
BatchAnnotateImagesResponse response = client.batchAnnotateImages(requests);
List<AnnotateImageResponse> responses = response.getResponsesList();
for (AnnotateImageResponse res : responses) {
if (res.hasError()) {
System.out.format("Error: %s%n", res.getError().getMessage());
return;
}
for (int i = 0; i < res.getTextAnnotationsCount(); i++) {
EntityAnnotation annotation = res.getTextAnnotations(i);
if (i > 0) {
descriptionText = annotation.getDescription().replaceAll("\\s+", "").trim();
System.out.println("Text--> " + descriptionText);
for (int x = 0; x < annotation.getBoundingPoly().getVerticesCount(); x++) {
xvertice = annotation.getBoundingPoly().getVertices(x).getX();
yvertice = annotation.getBoundingPoly().getVertices(x).getY();
System.out.println("X--> " + xvertice);
System.out.println("Y--> " + yvertice);
System.out.println("<---------------->");
}
/*
* for (int xx = 0; xx <
* annotation.getBoundingPoly().getNormalizedVerticesCount(); xx++) { xp =
* annotation.getBoundingPoly().getNormalizedVertices(xx).getX(); yy =
* annotation.getBoundingPoly().getNormalizedVertices(xx).getY();
*
* System.out.println("X--> " + xp); System.out.println("Y--> " + yy);
* System.out.println("<---------------->"); }
*/
}
}
}
try(ImageAnnotatorClient=ImageAnnotatorClient.create()){
BatchAnnotateImagesResponse=client.batchAnnotateImages(请求);
List responses=response.getResponsesList();
用于(注释ImageResponse res:responses){
if(res.hasError()){
System.out.format(“错误:%s%n”,res.getError().getMessage());
返回;
}
for(int i=0;i0){
descriptionText=annotation.getDescription().replaceAll(“\\s+”,”).trim();
System.out.println(“Text-->”+descriptionContext);
对于(int x=0;x”+xvertice);
System.out.println(“Y-->”+yvertice);
System.out.println(“”);
}
/*
*对于(int xx=0;xx<
*annotation.getBoundingPoly().getNormalizedVerticesCount();xx++{xp=
*annotation.getBoundingPoly().getNormalizedVertices(xx).getX();yy=
*注释.getBoundingPoly().getNormalizedVertices(xx).getY();
*
*System.out.println(“X-->”+xp);System.out.println(“Y-->”+yy);
*System.out.println(“”;}
*/
}
}
}
是的,这是可能的,在这里我留下一部分代码,您可以尝试,
主要的事情是找到你要处理的字段的顶点“x”和“y”
try (ImageAnnotatorClient client = ImageAnnotatorClient.create()) {
BatchAnnotateImagesResponse response = client.batchAnnotateImages(requests);
List<AnnotateImageResponse> responses = response.getResponsesList();
for (AnnotateImageResponse res : responses) {
if (res.hasError()) {
System.out.format("Error: %s%n", res.getError().getMessage());
return;
}
for (int i = 0; i < res.getTextAnnotationsCount(); i++) {
EntityAnnotation annotation = res.getTextAnnotations(i);
if (i > 0) {
descriptionText = annotation.getDescription().replaceAll("\\s+", "").trim();
System.out.println("Text--> " + descriptionText);
for (int x = 0; x < annotation.getBoundingPoly().getVerticesCount(); x++) {
xvertice = annotation.getBoundingPoly().getVertices(x).getX();
yvertice = annotation.getBoundingPoly().getVertices(x).getY();
System.out.println("X--> " + xvertice);
System.out.println("Y--> " + yvertice);
System.out.println("<---------------->");
}
/*
* for (int xx = 0; xx <
* annotation.getBoundingPoly().getNormalizedVerticesCount(); xx++) { xp =
* annotation.getBoundingPoly().getNormalizedVertices(xx).getX(); yy =
* annotation.getBoundingPoly().getNormalizedVertices(xx).getY();
*
* System.out.println("X--> " + xp); System.out.println("Y--> " + yy);
* System.out.println("<---------------->"); }
*/
}
}
}
try(ImageAnnotatorClient=ImageAnnotatorClient.create()){
BatchAnnotateImagesResponse=client.batchAnnotateImages(请求);
List responses=response.getResponsesList();
用于(注释ImageResponse res:responses){
if(res.hasError()){
System.out.format(“错误:%s%n”,res.getError().getMessage());
返回;
}
for(int i=0;i0){
descriptionText=annotation.getDescription().replaceAll(“\\s+”,”).trim();
System.out.println(“Text-->”+descriptionContext);
对于(int x=0;x”+xvertice);
System.out.println(“Y-->”+yvertice);
System.out.println(“”);
}
/*
*对于(int xx=0;xx<
*annotation.getBoundingPoly().getNormalizedVerticesCount();xx++{xp=
*annotation.getBoundingPoly().getNormalizedVertices(xx).getX();yy=
*注释.getBoundingPoly().getNormalizedVertices(xx).getY();
*
*System.out.println(“X-->”+xp);System.out.println(“Y-->”+yy);
*System.out.println(“”;}
*/
}
}
}