From b86222c30532acf778fa71b4f73a383b8bb12019 Mon Sep 17 00:00:00 2001 From: Leif <4603009@qq.com> Date: Thu, 22 Apr 2021 18:48:42 +0800 Subject: [PATCH] Fix a bug in PPOCRLabel Solve the problem that the exported image is displayed as a mirror image after counterclockwise labeling --- PPOCRLabel/README.md | 4 +--- PPOCRLabel/README_ch.md | 2 +- PPOCRLabel/libs/utils.py | 9 +++++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/PPOCRLabel/README.md b/PPOCRLabel/README.md index 633d042b..13500f89 100644 --- a/PPOCRLabel/README.md +++ b/PPOCRLabel/README.md @@ -29,9 +29,7 @@ PaddleOCR models has been built in PPOCRLabel, please refer to [PaddleOCR instal ### 2. Install PPOCRLabel -#### Windows + Anaconda - -Download and install [Anaconda](https://www.anaconda.com/download/#download) (Python 3+) +#### Windows ``` pip install pyqt5 diff --git a/PPOCRLabel/README_ch.md b/PPOCRLabel/README_ch.md index c214698f..8c0f1a0d 100644 --- a/PPOCRLabel/README_ch.md +++ b/PPOCRLabel/README_ch.md @@ -31,7 +31,7 @@ PPOCRLabel是一款适用于OCR领域的半自动化图形标注工具,内置P PPOCRLabel内置PaddleOCR模型,故请参考[PaddleOCR安装文档](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/doc/doc_ch/installation.md)准备好PaddleOCR,并确保PaddleOCR安装成功。 ### 2. 安装PPOCRLabel -#### Windows + Anaconda +#### Windows ``` pip install pyqt5 diff --git a/PPOCRLabel/libs/utils.py b/PPOCRLabel/libs/utils.py index cb1c92e7..9be930a7 100644 --- a/PPOCRLabel/libs/utils.py +++ b/PPOCRLabel/libs/utils.py @@ -124,6 +124,15 @@ def natural_sort(list, key=lambda s:s): def get_rotate_crop_image(img, points): + # Use Green's theory to judge clockwise or counterclockwise + # author: biyanhua + d = 0.0 + for index in range(-1, 3): + d += -0.5 * (points[index + 1][1] + points[index][1]) * ( + points[index + 1][0] - points[index][0]) + if d < 0: # counterclockwise + tmp = np.array(points) + points[1], points[3] = tmp[3], tmp[1] try: img_crop_width = int( -- GitLab