Chr*_*dor 9 google-cloud-vision
我刚刚测试了Google Cloud Vision API,以便在图片中读取文本(如果存在).
到目前为止,我安装了Maven服务器和Redis服务器.我只是按照本页中的说明操作.
https://github.com/GoogleCloudPlatform/cloud-vision/tree/master/java/text
到目前为止,我能够使用.jpg文件进行测试,是否可以使用tiff文件或pdf进行测试?
我使用以下命令:
java -cp target/text-1.0-SNAPSHOT-jar-with-dependencies.jar com.google.cloud.vision.samples.text.TextApp ../../data/text/
Run Code Online (Sandbox Code Playgroud)
在文本目录中,我有jpg格式的文件.
然后要读取转换后的文件,我不知道该怎么做,只是运行以下命令
java -cp target/text-1.0-SNAPSHOT-jar-with-dependencies.jar com.google.cloud.vision.samples.text.TextApp
Run Code Online (Sandbox Code Playgroud)
我收到消息,输入一个单词或短语来搜索转换后的文件.有没有办法看到整个文件转变?
谢谢!
Mil*_*nák 17
2018年4月6日,Google Cloud Vision API中添加了对文档文本检测中的PDF和TIFF文件的支持(请参阅发行说明).
根据文件:
Vision API可以检测和转录存储在Google云端存储中的PDF和TIFF文件中的文本.
必须使用asyncBatchAnnotate函数请求PDF和TIFF中的文档文本检测,该 函数执行异步请求并使用操作资源提供其状态.
PDF/TIFF请求的输出将写入在指定的Google云存储存储桶中创建的JSON文件.
例:
1)将文件上传到您的Google云端存储
2)发出POST请求以执行PDF/TIFF文档文本检测
请求:
POST https://vision.googleapis.com/v1p2beta1/files:asyncBatchAnnotate
Authorization: Bearer <your access token>
{
"requests":[
{
"inputConfig": {
"gcsSource": {
"uri": "gs://<your bucket name>/input.pdf"
},
"mimeType": "application/pdf"
},
"features": [
{
"type": "DOCUMENT_TEXT_DETECTION"
}
],
"outputConfig": {
"gcsDestination": {
"uri": "gs://<your bucket name>/output/"
},
"batchSize": 1
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
响应:
{
"name": "operations/9b1f9d773d216406"
}
Run Code Online (Sandbox Code Playgroud)
3)发出GET请求以检查文档文本检测是否已完成
请求:
GET https://vision.googleapis.com/v1/operations/9b1f9d773d216406
Authorization: Bearer <your access token>
Run Code Online (Sandbox Code Playgroud)
响应:
{
"name": "operations/9b1f9d773d216406",
"metadata": {
"@type": "type.googleapis.com/google.cloud.vision.v1p2beta1.OperationMetadata",
"state": "RUNNING",
"updateTime": "2018-06-17T20:18:09.117787733Z"
},
"done": true,
"response": {
"@type": "type.googleapis.com/google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesResponse",
"responses": [
{
"outputConfig": {
"gcsDestination": {
"uri": "gs://<your bucket name>/output/"
},
"batchSize": 1
}
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
4)检查指定的Google Cloud Storage文件夹中的结果
| 归档时间: |
|
| 查看次数: |
11740 次 |
| 最近记录: |