[packages/python-tesserocr] - up to 2.3.1 - remove references to legacy API (not exported by tesseract 4.0)

baggins baggins at pld-linux.org
Thu Aug 16 23:05:13 CEST 2018


commit b02afae566455819a781e966597ec72b8c678d97
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Thu Aug 16 23:04:32 2018 +0200

    - up to 2.3.1
    - remove references to legacy API (not exported by tesseract 4.0)

 python-tesserocr.spec | 12 +++++----
 tesseract4.patch      | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+), 5 deletions(-)
---
diff --git a/python-tesserocr.spec b/python-tesserocr.spec
index 2d22f4e..8c1dc7c 100644
--- a/python-tesserocr.spec
+++ b/python-tesserocr.spec
@@ -7,17 +7,18 @@
 %bcond_without	python2 # CPython 2.x module
 %bcond_without	python3 # CPython 3.x module
 
-%define 	module		tesserocr
-%define 	egg_name	tesserocr
+%define		module		tesserocr
+%define		egg_name	tesserocr
 %define		pypi_name	tesserocr
 Summary:	A simple, Pillow-friendly, Python wrapper around tesseract-ocr API using Cython
 Name:		python-%{pypi_name}
-Version:	2.2.2
-Release:	3
+Version:	2.3.1
+Release:	1
 License:	MIT
 Group:		Libraries/Python
 Source0:	https://files.pythonhosted.org/packages/source/t/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
-# Source0-md5:	e6c9c8f6f6720e16cd612146e20e7feb
+# Source0-md5:	99e2001affe861ae3a5aa2e9f233e2d7
+Patch0:		tesseract4.patch
 URL:		https://github.com/sirfz/tesserocr
 BuildRequires:	rpm-pythonprov
 BuildRequires:	rpmbuild(macros) >= 1.714
@@ -60,6 +61,7 @@ image files instead.
 
 %prep
 %setup -q -n %{pypi_name}-%{version}
+%patch0 -p1
 
 # Remove bundled egg-info
 %{__rm} -r %{egg_name}.egg-info
diff --git a/tesseract4.patch b/tesseract4.patch
new file mode 100644
index 0000000..5813085
--- /dev/null
+++ b/tesseract4.patch
@@ -0,0 +1,67 @@
+--- tesserocr-2.3.1/tesseract.pxd~	2018-02-04 20:28:35.000000000 +0100
++++ tesserocr-2.3.1/tesseract.pxd	2018-08-16 22:58:33.358727376 +0200
+@@ -198,19 +198,6 @@
+         cdef cppclass TessOsdRenderer(TessResultRenderer):
+             TessOsdRenderer(cchar_t *) except +
+ 
+-cdef extern from "tesseract/osdetect.h" nogil:
+-    struct OSBestResult:
+-        int orientation_id
+-        int script_id
+-        float sconfidence
+-        float oconfidence
+-
+-    ctypedef int (*get_best_script)(int)
+-
+-    struct OSResults:
+-        get_best_script get_best_script
+-        OSBestResult best_result
+-
+ cdef extern from "tesseract/baseapi.h" namespace "tesseract" nogil:
+ 
+     IF TESSERACT_VERSION >= 0x040000:
+@@ -312,7 +312,6 @@
+             int IsValidWord(cchar_t *)
+             bool IsValidCharacter(cchar_t *)
+             bool GetTextDirection(int *, float *)
+-            bool DetectOS(OSResults *);
+             cchar_t *GetUnichar(int)
+             const OcrEngineMode oem() const
+             void set_min_orientation_margin(double)
+@@ -386,7 +385,6 @@
+             int IsValidWord(cchar_t *)
+             bool IsValidCharacter(cchar_t *)
+             bool GetTextDirection(int *, float *)
+-            bool DetectOS(OSResults *);
+             cchar_t *GetUnichar(int)
+             const OcrEngineMode oem() const
+             void set_min_orientation_margin(double)
+--- tesserocr-2.3.1/tesserocr.pyx~	2018-08-13 19:35:16.000000000 +0200
++++ tesserocr-2.3.1/tesserocr.pyx	2018-08-16 23:00:17.290796571 +0200
+@@ -2292,26 +2292,6 @@
+         self._baseapi.GetTextDirection(&out_offset, &out_slope)
+         return out_offset, out_slope
+ 
+-    def DetectOS(self):
+-        """Estimate the Orientation and Script of the image.
+-
+-        Returns:
+-            `dict` or `None` if image was not successfully processed. dict contains:
+-                - orientation: Orientation ids [0..3] map to [0, 270, 180, 90] degree orientations of the
+-                  page respectively, where the values refer to the amount of clockwise
+-                  rotation to be applied to the page for the text to be upright and readable.
+-                - oconfidence: Orientation confidence.
+-                - script: Index of the script with the highest score for this orientation.
+-                - sconfidence: script confidence.
+-        """
+-        cdef OSResults results
+-        if self._baseapi.DetectOS(&results):
+-            return {'orientation': results.best_result.orientation_id,
+-                    'oconfidence': results.best_result.oconfidence,
+-                    'script': results.get_best_script(results.best_result.orientation_id),
+-                    'sconfidence': results.best_result.sconfidence}
+-        return None
+-
+     def GetUnichar(self, int unichar_id):
+         """Return the string form of the specified unichar.
+ 
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/python-tesserocr.git/commitdiff/b02afae566455819a781e966597ec72b8c678d97



More information about the pld-cvs-commit mailing list