I want to use PDF/TIFF Document Text Detection service from google cloud [closed]

☆樱花仙子☆ 提交于 2019-12-25 00:57:25

问题


Google cloud vision api is very powerful and now they have support for pdf format, but the documentation is getting me confused, can someone pls guide a noob how to set up and process a pdf file using vision api.

kind of like starter tutorial

ref: https://cloud.google.com/vision/docs/pdf#vision-web-detection-gcs-protocol

The confusion is how to pass the command arguments, and send my sample file and retrieve the results in csv or json format

Should i use my windows command line or cloudshell on google cloud

There is good starter reference for other services , if you look at this https://cloud.google.com/vision/docs/ocr#vision-detect-labels-gcloud, they have clearly given commands to use in different envs


回答1:


You could use the following curl command as a base and run it within your Google Cloud Shell session:

curl -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) --header "Content-Type: application/json"   --request POST   --data '{ "requests":[  {"inputConfig": { "gcsSource": {  "uri": "gs://<Your Bucket>/<Your PDF FIle>"},"mimeType":"application/pdf"},"features": [{"type":"DOCUMENT_TEXT_DETECTION"}],"outputConfig": {"gcsDestination":{"uri": "gs://<Your destination bucket/"},"batchSize": 2}}]}' https://vision.googleapis.com/v1/files:asyncBatchAnnotate

Then, you'll get an operation object as a response like this: "name": "operations/<This is your operation ID>".

After that, you'll get your results with the GET request, for instance:

curl --request GET https://vision.googleapis.com/v1/operations/<The Operation ID>?key=<Your API Key>


来源:https://stackoverflow.com/questions/52614091/i-want-to-use-pdf-tiff-document-text-detection-service-from-google-cloud

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!