公共类 MainActivity 扩展 AppCompatActivity {
private static final String API_KEY = "b8fo0q33XyuCTm0qbr6XCg";
static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
static final JsonFactory JSON_FACTORY = new JacksonFactory();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button myBtn = (Button) findViewById(R.id.button);
TextView t=(TextView) findViewById(R.id.text);
}
public void onClick(View v) {
try {
CSApi api = new CSApi(
HTTP_TRANSPORT,
JSON_FACTORY,
API_KEY
);
CSPostConfig imageToPost = CSPostConfig.newBuilder()
.withRemoteImageUrl("https://questions4thoughts.files.wordpress.com/2008/11/50rupees.png")
.build();
CSPostResult portResult = api.postImage(imageToPost);
System.out.println("Post result: " + portResult);
try{
Thread.sleep(30000);
CSGetResult scoredResult = api.getImage(portResult);
// t.setText(scoredResult);
}
catch (InterruptedException e){
e.getCause();
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
我是这个 api 的新手。我有发布和获取文件,但我也不知道如何使用它。当我运行应用程序时,它说不幸停止。我使用过cloudsight api,但没有使用它的来源。你能建议一些关于如何使用它的解决方案或一些其他免费的图像识别 API。