Skip to content

Commit

Permalink
fix issue 9659 and doc (PaddlePaddle#8690)
Browse files Browse the repository at this point in the history
  • Loading branch information
LDOUBLEV authored Dec 23, 2022
1 parent ca8de0c commit 414bf18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion deploy/cpp_infer/docs/windows_vs2019_build.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ CUDA_LIB、CUDNN_LIB、TENSORRT_DIR、WITH_GPU、WITH_TENSORRT
```
cd /d D:\projects\cpp\PaddleOCR\deploy\cpp_infer
```
可执行文件`ppocr.exe`即为样例的预测程序,其主要使用方法如下,更多使用方法可以参考[说明文档](../readme.md)`运行demo`部分。
可执行文件`ppocr.exe`即为样例的预测程序,其主要使用方法如下,更多使用方法可以参考[说明文档](../readme_ch.md)`运行demo`部分。

```shell
# 切换终端编码为utf8
Expand Down
16 changes: 8 additions & 8 deletions ppocr/postprocess/db_postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ def boxes_from_bitmap(self, pred, _bitmap, dest_width, dest_height):
np.round(box[:, 0] / width * dest_width), 0, dest_width)
box[:, 1] = np.clip(
np.round(box[:, 1] / height * dest_height), 0, dest_height)
boxes.append(box.astype(np.int16))
boxes.append(box.astype("int32"))
scores.append(score)
return np.array(boxes, dtype=np.int16), scores
return np.array(boxes, dtype="int32"), scores

def unclip(self, box, unclip_ratio):
poly = Polygon(box)
Expand Down Expand Up @@ -185,15 +185,15 @@ def box_score_fast(self, bitmap, _box):
'''
h, w = bitmap.shape[:2]
box = _box.copy()
xmin = np.clip(np.floor(box[:, 0].min()).astype(np.int), 0, w - 1)
xmax = np.clip(np.ceil(box[:, 0].max()).astype(np.int), 0, w - 1)
ymin = np.clip(np.floor(box[:, 1].min()).astype(np.int), 0, h - 1)
ymax = np.clip(np.ceil(box[:, 1].max()).astype(np.int), 0, h - 1)
xmin = np.clip(np.floor(box[:, 0].min()).astype("int32"), 0, w - 1)
xmax = np.clip(np.ceil(box[:, 0].max()).astype("int32"), 0, w - 1)
ymin = np.clip(np.floor(box[:, 1].min()).astype("int32"), 0, h - 1)
ymax = np.clip(np.ceil(box[:, 1].max()).astype("int32"), 0, h - 1)

mask = np.zeros((ymax - ymin + 1, xmax - xmin + 1), dtype=np.uint8)
box[:, 0] = box[:, 0] - xmin
box[:, 1] = box[:, 1] - ymin
cv2.fillPoly(mask, box.reshape(1, -1, 2).astype(np.int32), 1)
cv2.fillPoly(mask, box.reshape(1, -1, 2).astype("int32"), 1)
return cv2.mean(bitmap[ymin:ymax + 1, xmin:xmax + 1], mask)[0]

def box_score_slow(self, bitmap, contour):
Expand All @@ -214,7 +214,7 @@ def box_score_slow(self, bitmap, contour):
contour[:, 0] = contour[:, 0] - xmin
contour[:, 1] = contour[:, 1] - ymin

cv2.fillPoly(mask, contour.reshape(1, -1, 2).astype(np.int32), 1)
cv2.fillPoly(mask, contour.reshape(1, -1, 2).astype("int32"), 1)
return cv2.mean(bitmap[ymin:ymax + 1, xmin:xmax + 1], mask)[0]

def __call__(self, outs_dict, shape_list):
Expand Down

0 comments on commit 414bf18

Please sign in to comment.