convert not done yet.
Browse files- .vscode/launch.json +16 -0
- convert_ocr_result.py +14 -0
.vscode/launch.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
// Use IntelliSense to learn about possible attributes.
|
| 3 |
+
// Hover to view descriptions of existing attributes.
|
| 4 |
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
| 5 |
+
"version": "0.2.0",
|
| 6 |
+
"configurations": [
|
| 7 |
+
|
| 8 |
+
{
|
| 9 |
+
"name": "Python Debugger: Current File",
|
| 10 |
+
"type": "debugpy",
|
| 11 |
+
"request": "launch",
|
| 12 |
+
"program": "${file}",
|
| 13 |
+
"console": "integratedTerminal"
|
| 14 |
+
}
|
| 15 |
+
]
|
| 16 |
+
}
|
convert_ocr_result.py
CHANGED
|
@@ -4,5 +4,19 @@
|
|
| 4 |
|
| 5 |
# see huggingface/project/ocr/tools/flask_auto_selection.py
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
pass
|
|
|
|
| 4 |
|
| 5 |
# see huggingface/project/ocr/tools/flask_auto_selection.py
|
| 6 |
|
| 7 |
+
import numpy as np
|
| 8 |
+
import cv2
|
| 9 |
+
import json
|
| 10 |
+
import base64
|
| 11 |
+
|
| 12 |
if __name__ == '__main__':
|
| 13 |
+
imgData = np.fromfile('pdfs/jp/徐一平日本语句型辞典/0001.jpg', dtype=np.uint8)
|
| 14 |
+
img = cv2.imdecode(imgData, cv2.IMREAD_UNCHANGED)
|
| 15 |
+
img_bytes = img.tobytes()
|
| 16 |
+
base64_str = base64.b64encode(img_bytes).decode('utf-8')
|
| 17 |
+
|
| 18 |
+
# imgdata2 = base64.b64decode(base64_str)
|
| 19 |
+
# imgdata2 = np.frombuffer(imgdata2, np.uint8)
|
| 20 |
+
# img2 = cv2.imdecode(imgdata2, -1)
|
| 21 |
+
|
| 22 |
pass
|