|
|
@@ -202,92 +202,89 @@ Additionally, PaddleX provides three other deployment methods, detailed as follo
|
|
|
|
|
|
Below are the API references and multi-language service invocation examples:
|
|
|
|
|
|
-<details>
|
|
|
-<summary>API Reference</summary>
|
|
|
-
|
|
|
-对于服务提供的所有操作:
|
|
|
+<details>
|
|
|
+<summary>API Reference</summary>
|
|
|
+
|
|
|
+For all operations provided by the service:
|
|
|
|
|
|
-- 响应体以及POST请求的请求体均为JSON数据(JSON对象)。
|
|
|
-- 当请求处理成功时,响应状态码为`200`,响应体的属性如下:
|
|
|
+- Both the response body and the request body for POST requests are JSON data (JSON objects).
|
|
|
+- When the request is processed successfully, the response status code is `200`, and the response body attributes are as follows:
|
|
|
|
|
|
- |名称|类型|含义|
|
|
|
- |-|-|-|
|
|
|
- |`errorCode`|`integer`|错误码。固定为`0`。|
|
|
|
- |`errorMsg`|`string`|错误说明。固定为`"Success"`。|
|
|
|
+ | Name | Type | Description |
|
|
|
+ |------|------|-------------|
|
|
|
+ |`errorCode`|`integer`|Error code. Fixed as `0`.|
|
|
|
+ |`errorMsg`|`string`|Error message. Fixed as `"Success"`.|
|
|
|
|
|
|
- 响应体还可能有`result`属性,类型为`object`,其中存储操作结果信息。
|
|
|
+ The response body may also have a `result` attribute of type `object`, which stores the operation result information.
|
|
|
|
|
|
-- 当请求处理未成功时,响应体的属性如下:
|
|
|
+- When the request is not processed successfully, the response body attributes are as follows:
|
|
|
|
|
|
- |名称|类型|含义|
|
|
|
- |-|-|-|
|
|
|
- |`errorCode`|`integer`|错误码。与响应状态码相同。|
|
|
|
- |`errorMsg`|`string`|错误说明。|
|
|
|
+ | Name | Type | Description |
|
|
|
+ |------|------|-------------|
|
|
|
+ |`errorCode`|`integer`|Error code. Same as the response status code.|
|
|
|
+ |`errorMsg`|`string`|Error message.|
|
|
|
|
|
|
-服务提供的操作如下:
|
|
|
+Operations provided by the service:
|
|
|
|
|
|
- **`infer`**
|
|
|
|
|
|
- 定位并识别图中的表格。
|
|
|
+ Locate and recognize tables in images.
|
|
|
|
|
|
`POST /table-recognition`
|
|
|
|
|
|
- - 请求体的属性如下:
|
|
|
+ - Request body attributes:
|
|
|
|
|
|
- |名称|类型|含义|是否必填|
|
|
|
- |-|-|-|-|
|
|
|
- |`image`|`string`|服务可访问的图像文件的URL或图像文件内容的Base64编码结果。|是|
|
|
|
- |`inferenceParams`|`object`|推理参数。|否|
|
|
|
+ | Name | Type | Description | Required |
|
|
|
+ |------|------|-------------|----------|
|
|
|
+ |`image`|`string`|The URL of an image file accessible by the service or the Base64 encoded result of the image file content.|Yes|
|
|
|
+ |`inferenceParams`|`object`|Inference parameters.|No|
|
|
|
|
|
|
- `inferenceParams`的属性如下:
|
|
|
+ Properties of `inferenceParams`:
|
|
|
|
|
|
- |名称|类型|含义|是否必填|
|
|
|
- |-|-|-|-|
|
|
|
- |`maxLongSide`|`integer`|推理时,若文本检测模型的输入图像较长边的长度大于`maxLongSide`,则将对图像进行缩放,使其较长边的长度等于`maxLongSide`。|否|
|
|
|
+ | Name | Type | Description | Required |
|
|
|
+ |------|------|-------------|----------|
|
|
|
+ |`maxLongSide`|`integer`|During inference, if the length of the longer side of the input image for the text detection model is greater than `maxLongSide`, the image will be scaled so that the length of the longer side equals `maxLongSide`.|No|
|
|
|
|
|
|
- - 请求处理成功时,响应体的`result`具有如下属性:
|
|
|
+ - When the request is processed successfully, the `result` of the response body has the following attributes:
|
|
|
|
|
|
- |名称|类型|含义|
|
|
|
- |-|-|-|
|
|
|
- |`tables`|`array`|表格位置和内容。|
|
|
|
- |`layoutImage`|`string`|版面区域检测结果图。图像为JPEG格式,使用Base64编码。|
|
|
|
- |`ocrImage`|`string`|OCR结果图。图像为JPEG格式,使用Base64编码。|
|
|
|
+ | Name | Type | Description |
|
|
|
+ |------|------|-------------|
|
|
|
+ |`tables`|`array`|Positions and contents of tables.|
|
|
|
+ |`layoutImage`|`string`|Layout area detection result image. The image is in JPEG format and encoded using Base64.|
|
|
|
+ |`ocrImage`|`string`|OCR result image. The image is in JPEG format and encoded using Base64.|
|
|
|
|
|
|
- `tables`中的每个元素为一个`object`,具有如下属性:
|
|
|
+ Each element in `tables` is an `object` with the following attributes:
|
|
|
|
|
|
- |名称|类型|含义|
|
|
|
- |-|-|-|
|
|
|
- |`bbox`|`array`|表格位置。数组中元素依次为边界框左上角x坐标、左上角y坐标、右下角x坐标以及右下角y坐标。|
|
|
|
- |`html`|`string`|HTML格式的表格识别结果。|
|
|
|
+ | Name | Type | Description |
|
|
|
+ |------|------|-------------|
|
|
|
+ |`bbox`|`array`|Table position. The elements in the array are the x-coordinate of the top-left corner, the y-coordinate of the top-left corner, the x-coordinate of the bottom-right corner, and the y-coordinate of the bottom-right corner of the bounding box, respectively.|
|
|
|
+ |`html`|`string`|Table recognition result in HTML format.|
|
|
|
|
|
|
</details>
|
|
|
|
|
|
<details>
|
|
|
-<summary>Multilingual Service Invocation Examples</summary>
|
|
|
+<summary>Multilingual Service Invocation Examples</summary>
|
|
|
+
|
|
|
+<details>
|
|
|
+<summary>Python</summary>
|
|
|
|
|
|
-<details>
|
|
|
-<summary>Python</summary>
|
|
|
-
|
|
|
```python
|
|
|
import base64
|
|
|
import requests
|
|
|
|
|
|
-API_URL = "http://localhost:8080/table-recognition" # 服务URL
|
|
|
+API_URL = "http://localhost:8080/table-recognition"
|
|
|
image_path = "./demo.jpg"
|
|
|
ocr_image_path = "./ocr.jpg"
|
|
|
-layout_image_path = "./table.jpg"
|
|
|
+layout_image_path = "./layout.jpg"
|
|
|
|
|
|
-# 对本地图像进行Base64编码
|
|
|
with open(image_path, "rb") as file:
|
|
|
image_bytes = file.read()
|
|
|
image_data = base64.b64encode(image_bytes).decode("ascii")
|
|
|
|
|
|
-payload = {"image": image_data} # Base64编码的文件内容或者图像URL
|
|
|
+payload = {"image": image_data}
|
|
|
|
|
|
-# 调用API
|
|
|
response = requests.post(API_URL, json=payload)
|
|
|
|
|
|
-# 处理接口返回数据
|
|
|
assert response.status_code == 200
|
|
|
result = response.json()["result"]
|
|
|
with open(ocr_image_path, "wb") as file:
|
|
|
@@ -299,12 +296,12 @@ print(f"Output image saved at {layout_image_path}")
|
|
|
print("\nDetected tables:")
|
|
|
print(result["tables"])
|
|
|
```
|
|
|
-
|
|
|
+
|
|
|
</details>
|
|
|
|
|
|
-<details>
|
|
|
-<summary>C++</summary>
|
|
|
-
|
|
|
+<details>
|
|
|
+<summary>C++</summary>
|
|
|
+
|
|
|
```cpp
|
|
|
#include <iostream>
|
|
|
#include "cpp-httplib/httplib.h" // https://github.com/Huiyicc/cpp-httplib
|
|
|
@@ -315,13 +312,12 @@ int main() {
|
|
|
httplib::Client client("localhost:8080");
|
|
|
const std::string imagePath = "./demo.jpg";
|
|
|
const std::string ocrImagePath = "./ocr.jpg";
|
|
|
- const std::string layoutImagePath = "./table.jpg";
|
|
|
+ const std::string layoutImagePath = "./layout.jpg";
|
|
|
|
|
|
httplib::Headers headers = {
|
|
|
{"Content-Type", "application/json"}
|
|
|
};
|
|
|
|
|
|
- // 对本地图像进行Base64编码
|
|
|
std::ifstream file(imagePath, std::ios::binary | std::ios::ate);
|
|
|
std::streamsize size = file.tellg();
|
|
|
file.seekg(0, std::ios::beg);
|
|
|
@@ -338,9 +334,8 @@ int main() {
|
|
|
jsonObj["image"] = encodedImage;
|
|
|
std::string body = jsonObj.dump();
|
|
|
|
|
|
- // 调用API
|
|
|
auto response = client.Post("/table-recognition", headers, body, "application/json");
|
|
|
- // 处理接口返回数据
|
|
|
+
|
|
|
if (response && response->status == 200) {
|
|
|
nlohmann::json jsonResponse = nlohmann::json::parse(response->body);
|
|
|
auto result = jsonResponse["result"];
|
|
|
@@ -382,12 +377,12 @@ int main() {
|
|
|
return 0;
|
|
|
}
|
|
|
```
|
|
|
-
|
|
|
+
|
|
|
</details>
|
|
|
|
|
|
-<details>
|
|
|
-<summary>Java</summary>
|
|
|
-
|
|
|
+<details>
|
|
|
+<summary>Java</summary>
|
|
|
+
|
|
|
```java
|
|
|
import okhttp3.*;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
@@ -401,21 +396,19 @@ import java.util.Base64;
|
|
|
|
|
|
public class Main {
|
|
|
public static void main(String[] args) throws IOException {
|
|
|
- String API_URL = "http://localhost:8080/table-recognition"; // 服务URL
|
|
|
- String imagePath = "./demo.jpg"; // 本地图像
|
|
|
+ String API_URL = "http://localhost:8080/table-recognition";
|
|
|
+ String imagePath = "./demo.jpg";
|
|
|
String ocrImagePath = "./ocr.jpg";
|
|
|
- String layoutImagePath = "./table.jpg";
|
|
|
+ String layoutImagePath = "./layout.jpg";
|
|
|
|
|
|
- // 对本地图像进行Base64编码
|
|
|
File file = new File(imagePath);
|
|
|
byte[] fileContent = java.nio.file.Files.readAllBytes(file.toPath());
|
|
|
String imageData = Base64.getEncoder().encodeToString(fileContent);
|
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
ObjectNode params = objectMapper.createObjectNode();
|
|
|
- params.put("image", imageData); // Base64编码的文件内容或者图像URL
|
|
|
+ params.put("image", imageData);
|
|
|
|
|
|
- // 创建 OkHttpClient 实例
|
|
|
OkHttpClient client = new OkHttpClient();
|
|
|
MediaType JSON = MediaType.Companion.get("application/json; charset=utf-8");
|
|
|
RequestBody body = RequestBody.Companion.create(params.toString(), JSON);
|
|
|
@@ -424,7 +417,6 @@ public class Main {
|
|
|
.post(body)
|
|
|
.build();
|
|
|
|
|
|
- // 调用API并处理接口返回数据
|
|
|
try (Response response = client.newCall(request).execute()) {
|
|
|
if (response.isSuccessful()) {
|
|
|
String responseBody = response.body().string();
|
|
|
@@ -454,116 +446,113 @@ public class Main {
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
-
|
|
|
+
|
|
|
</details>
|
|
|
|
|
|
-<details>
|
|
|
-<summary>Go</summary>
|
|
|
-
|
|
|
+<details>
|
|
|
+<summary>Go</summary>
|
|
|
+
|
|
|
```go
|
|
|
package main
|
|
|
|
|
|
import (
|
|
|
- "bytes"
|
|
|
- "encoding/base64"
|
|
|
- "encoding/json"
|
|
|
- "fmt"
|
|
|
- "io/ioutil"
|
|
|
- "net/http"
|
|
|
+ "bytes"
|
|
|
+ "encoding/base64"
|
|
|
+ "encoding/json"
|
|
|
+ "fmt"
|
|
|
+ "io/ioutil"
|
|
|
+ "net/http"
|
|
|
)
|
|
|
|
|
|
func main() {
|
|
|
- API_URL := "http://localhost:8080/table-recognition"
|
|
|
- imagePath := "./demo.jpg"
|
|
|
- ocrImagePath := "./ocr.jpg"
|
|
|
- layoutImagePath := "./table.jpg"
|
|
|
-
|
|
|
- // 对本地图像进行Base64编码
|
|
|
- imageBytes, err := ioutil.ReadFile(imagePath)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("Error reading image file:", err)
|
|
|
- return
|
|
|
- }
|
|
|
- imageData := base64.StdEncoding.EncodeToString(imageBytes)
|
|
|
-
|
|
|
- payload := map[string]string{"image": imageData} // Base64编码的文件内容或者图像URL
|
|
|
- payloadBytes, err := json.Marshal(payload)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("Error marshaling payload:", err)
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- // 调用API
|
|
|
- client := &http.Client{}
|
|
|
- req, err := http.NewRequest("POST", API_URL, bytes.NewBuffer(payloadBytes))
|
|
|
- if err != nil {
|
|
|
- fmt.Println("Error creating request:", err)
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- res, err := client.Do(req)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("Error sending request:", err)
|
|
|
- return
|
|
|
- }
|
|
|
- defer res.Body.Close()
|
|
|
-
|
|
|
- // 处理接口返回数据
|
|
|
- body, err := ioutil.ReadAll(res.Body)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("Error reading response body:", err)
|
|
|
- return
|
|
|
- }
|
|
|
- type Response struct {
|
|
|
- Result struct {
|
|
|
- OcrImage string `json:"ocrImage"`
|
|
|
+ API_URL := "http://localhost:8080/table-recognition"
|
|
|
+ imagePath := "./demo.jpg"
|
|
|
+ ocrImagePath := "./ocr.jpg"
|
|
|
+ layoutImagePath := "./layout.jpg"
|
|
|
+
|
|
|
+ imageBytes, err := ioutil.ReadFile(imagePath)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error reading image file:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ imageData := base64.StdEncoding.EncodeToString(imageBytes)
|
|
|
+
|
|
|
+ payload := map[string]string{"image": imageData}
|
|
|
+ payloadBytes, err := json.Marshal(payload)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error marshaling payload:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ client := &http.Client{}
|
|
|
+ req, err := http.NewRequest("POST", API_URL, bytes.NewBuffer(payloadBytes))
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error creating request:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ res, err := client.Do(req)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error sending request:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer res.Body.Close()
|
|
|
+
|
|
|
+ body, err := ioutil.ReadAll(res.Body)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error reading response body:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ type Response struct {
|
|
|
+ Result struct {
|
|
|
+ OcrImage string `json:"ocrImage"`
|
|
|
TableImage string `json:"layoutImage"`
|
|
|
- Tables []map[string]interface{} `json:"tables"`
|
|
|
- } `json:"result"`
|
|
|
- }
|
|
|
- var respData Response
|
|
|
- err = json.Unmarshal([]byte(string(body)), &respData)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("Error unmarshaling response body:", err)
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- ocrImageData, err := base64.StdEncoding.DecodeString(respData.Result.OcrImage)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("Error decoding base64 image data:", err)
|
|
|
- return
|
|
|
- }
|
|
|
- err = ioutil.WriteFile(ocrImagePath, ocrImageData, 0644)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("Error writing image to file:", err)
|
|
|
- return
|
|
|
- }
|
|
|
+ Tables []map[string]interface{} `json:"tables"`
|
|
|
+ } `json:"result"`
|
|
|
+ }
|
|
|
+ var respData Response
|
|
|
+ err = json.Unmarshal([]byte(string(body)), &respData)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error unmarshaling response body:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ ocrImageData, err := base64.StdEncoding.DecodeString(respData.Result.OcrImage)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error decoding base64 image data:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = ioutil.WriteFile(ocrImagePath, ocrImageData, 0644)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error writing image to file:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
fmt.Printf("Image saved at %s.jpg\n", ocrImagePath)
|
|
|
|
|
|
layoutImageData, err := base64.StdEncoding.DecodeString(respData.Result.TableImage)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("Error decoding base64 image data:", err)
|
|
|
- return
|
|
|
- }
|
|
|
- err = ioutil.WriteFile(layoutImagePath, layoutImageData, 0644)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("Error writing image to file:", err)
|
|
|
- return
|
|
|
- }
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error decoding base64 image data:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = ioutil.WriteFile(layoutImagePath, layoutImageData, 0644)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("Error writing image to file:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
fmt.Printf("Image saved at %s.jpg\n", layoutImagePath)
|
|
|
|
|
|
- fmt.Println("\nDetected tables:")
|
|
|
- for _, category := range respData.Result.Tables {
|
|
|
- fmt.Println(category)
|
|
|
- }
|
|
|
+ fmt.Println("\nDetected tables:")
|
|
|
+ for _, category := range respData.Result.Tables {
|
|
|
+ fmt.Println(category)
|
|
|
+ }
|
|
|
}
|
|
|
```
|
|
|
-
|
|
|
+
|
|
|
</details>
|
|
|
|
|
|
-<details>
|
|
|
-<summary>C#</summary>
|
|
|
-
|
|
|
+<details>
|
|
|
+<summary>C#</summary>
|
|
|
+
|
|
|
```csharp
|
|
|
using System;
|
|
|
using System.IO;
|
|
|
@@ -578,24 +567,21 @@ class Program
|
|
|
static readonly string API_URL = "http://localhost:8080/table-recognition";
|
|
|
static readonly string imagePath = "./demo.jpg";
|
|
|
static readonly string ocrImagePath = "./ocr.jpg";
|
|
|
- static readonly string layoutImagePath = "./table.jpg";
|
|
|
+ static readonly string layoutImagePath = "./layout.jpg";
|
|
|
|
|
|
static async Task Main(string[] args)
|
|
|
{
|
|
|
var httpClient = new HttpClient();
|
|
|
|
|
|
- // 对本地图像进行Base64编码
|
|
|
byte[] imageBytes = File.ReadAllBytes(imagePath);
|
|
|
string image_data = Convert.ToBase64String(imageBytes);
|
|
|
|
|
|
- var payload = new JObject{ { "image", image_data } }; // Base64编码的文件内容或者图像URL
|
|
|
+ var payload = new JObject{ { "image", image_data } };
|
|
|
var content = new StringContent(payload.ToString(), Encoding.UTF8, "application/json");
|
|
|
|
|
|
- // 调用API
|
|
|
HttpResponseMessage response = await httpClient.PostAsync(API_URL, content);
|
|
|
response.EnsureSuccessStatusCode();
|
|
|
|
|
|
- // 处理接口返回数据
|
|
|
string responseBody = await response.Content.ReadAsStringAsync();
|
|
|
JObject jsonResponse = JObject.Parse(responseBody);
|
|
|
|
|
|
@@ -614,12 +600,12 @@ class Program
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
-
|
|
|
+
|
|
|
</details>
|
|
|
|
|
|
-<details>
|
|
|
-<summary>Node.js</summary>
|
|
|
-
|
|
|
+<details>
|
|
|
+<summary>Node.js</summary>
|
|
|
+
|
|
|
```js
|
|
|
const axios = require('axios');
|
|
|
const fs = require('fs');
|
|
|
@@ -627,27 +613,24 @@ const fs = require('fs');
|
|
|
const API_URL = 'http://localhost:8080/table-recognition'
|
|
|
const imagePath = './demo.jpg'
|
|
|
const ocrImagePath = "./ocr.jpg";
|
|
|
-const layoutImagePath = "./table.jpg";
|
|
|
+const layoutImagePath = "./layout.jpg";
|
|
|
|
|
|
let config = {
|
|
|
method: 'POST',
|
|
|
maxBodyLength: Infinity,
|
|
|
url: API_URL,
|
|
|
data: JSON.stringify({
|
|
|
- 'image': encodeImageToBase64(imagePath) // Base64编码的文件内容或者图像URL
|
|
|
+ 'image': encodeImageToBase64(imagePath)
|
|
|
})
|
|
|
};
|
|
|
|
|
|
-// 对本地图像进行Base64编码
|
|
|
function encodeImageToBase64(filePath) {
|
|
|
const bitmap = fs.readFileSync(filePath);
|
|
|
return Buffer.from(bitmap).toString('base64');
|
|
|
}
|
|
|
|
|
|
-// 调用API
|
|
|
axios.request(config)
|
|
|
.then((response) => {
|
|
|
- // 处理接口返回数据
|
|
|
const result = response.data["result"];
|
|
|
|
|
|
const imageBuffer = Buffer.from(result["ocrImage"], 'base64');
|
|
|
@@ -669,25 +652,23 @@ axios.request(config)
|
|
|
console.log(error);
|
|
|
});
|
|
|
```
|
|
|
-
|
|
|
+
|
|
|
</details>
|
|
|
|
|
|
-<details>
|
|
|
-<summary>PHP</summary>
|
|
|
-
|
|
|
+<details>
|
|
|
+<summary>PHP</summary>
|
|
|
+
|
|
|
```php
|
|
|
<?php
|
|
|
|
|
|
-$API_URL = "http://localhost:8080/table-recognition"; // 服务URL
|
|
|
+$API_URL = "http://localhost:8080/table-recognition";
|
|
|
$image_path = "./demo.jpg";
|
|
|
$ocr_image_path = "./ocr.jpg";
|
|
|
-$layout_image_path = "./table.jpg";
|
|
|
+$layout_image_path = "./layout.jpg";
|
|
|
|
|
|
-// 对本地图像进行Base64编码
|
|
|
$image_data = base64_encode(file_get_contents($image_path));
|
|
|
-$payload = array("image" => $image_data); // Base64编码的文件内容或者图像URL
|
|
|
+$payload = array("image" => $image_data);
|
|
|
|
|
|
-// 调用API
|
|
|
$ch = curl_init($API_URL);
|
|
|
curl_setopt($ch, CURLOPT_POST, true);
|
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
|
|
|
@@ -695,7 +676,6 @@ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
$response = curl_exec($ch);
|
|
|
curl_close($ch);
|
|
|
|
|
|
-// 处理接口返回数据
|
|
|
$result = json_decode($response, true)["result"];
|
|
|
file_put_contents($ocr_image_path, base64_decode($result["ocrImage"]));
|
|
|
echo "Output image saved at " . $ocr_image_path . "\n";
|
|
|
@@ -708,7 +688,7 @@ print_r($result["tables"]);
|
|
|
|
|
|
?>
|
|
|
```
|
|
|
-
|
|
|
+
|
|
|
</details>
|
|
|
</details>
|
|
|
<br/>
|