gpt4 book ai didi

java - Watson Visual Recognition API 文本转字符串

转载 作者:行者123 更新时间:2023-12-02 13:40:17 25 4
gpt4 key购买 nike

我知道这可能是一个愚蠢的问题,但我很难将视觉识别从 recognizeText 转换为我可以使用和操作的字符串。

这是用 Java 编写的。

有人可以帮忙吗?这可能与挖掘方法并找到正确的组合有关......

package com.mycompany.app;

import com.ibm.watson.developer_cloud.visual_recognition.v3.VisualRecognition;

import com.ibm.watson.developer_cloud.visual_recognition.v3.model.*;

import java.io.File;
import java.util.concurrent.ExecutionException;
public class App
{
public static void main( String[] args ) throws ExecutionException, InterruptedException {
VisualRecognition service = new VisualRecognition(VisualRecognition.VERSION_DATE_2016_05_20);
service.setApiKey("a46d79a8aa20ed4b1ad3bc25a449c15d212d5db7");

ClassifierOptions p = new ClassifierOptions.Builder().classifierName("letters").addClass("H", new File("src/pictures/CapitalH.zip")).addClass("h", new File("src/pictures/LowercaseH.zip")).build();

File f1 = new File("src/pictures/CapitalH.zip");
File f2 = new File("src/pictures/LowercaseH.zip");
File f3 = new File("src/pictures/HiM.zip");

//VisualClassifier c1 = service.createClassifier("H", f1, f2);
//service.createClassifier(p).execute();
//VisualClassifier c1 = new VisualClassifier();
//VisualClass cc1 = (VisualClass) service.createClassifier(p);

service.createClassifier(p);
VisualRecognitionOptions ops; //find out how to add classifications for letters to this, then add this to visualClassification

ClassifyImagesOptions pp = new ClassifyImagesOptions.Builder().images(f3).classifierIds("H").build();

ClassifyImagesOptions ppp = new ClassifyImagesOptions.Builder().images(f3).build();

VisualClassification result = service.classify(pp).execute();

VisualRecognitionOptions now = new VisualRecognitionOptions.Builder().images(f3).build();
//System.out.println(service.recognizeText(now).execute());

//System.out.println(service.recognizeText(now));

RecognizedText t = service.recognizeText(now).execute();
t = service.recognizeText(now).rx().join();
String s = service.recognizeText(now).rx().toString();

//System.out.println(service.getClassifiers());
//System.out.println(result);



}
}

最佳答案

在此行之后,尝试打印出t:

RecognizedText t = service.recognizeText(now).execute();

您应该会看到格式化 JSON 对象中的文本。

关于java - Watson Visual Recognition API 文本转字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42770442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com