Skip to content

πŸ“„ Awesome OCR multiple programing languages toolkits based on ONNX Runtime, OpenVINO, MNN, PaddlePaddle, TensorRT and PyTorch.

Fix ocrweb/b64decode bug

SWHL5240fa771b74
diff --git a/ocrweb/api.py b/ocrweb/api.py
index 0b9a4df..873c0ff 100644
--- a/ocrweb/api.py
+++ b/ocrweb/api.py
@@ -20,7 +20,7 @@ def ocr():
url_get = request.get_json()
img_str = url_get.get('file')
- image = base64.b64decode(img_str)
+ image = base64.b64decode(img_str + '=' * (-len(img_str) % 4))
nparr = np.frombuffer(image, np.uint8)
image = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
if image.ndim == 2:
diff --git a/ocrweb/main.py b/ocrweb/main.py
index 380592f..c0fb4c3 100644
--- a/ocrweb/main.py
+++ b/ocrweb/main.py
@@ -26,7 +26,7 @@ def ocr():
url_get = request.get_json()
img_str = str(url_get).split(',')[1]
- image = base64.b64decode(img_str)
+ image = base64.b64decode(img_str + '=' * (-len(img_str) % 4))
nparr = np.frombuffer(image, np.uint8)
image = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
if image.ndim == 2: