Rebuild (tesseract)
This commit is contained in:
parent
434a93e5e8
commit
6d1fca9290
@ -14,6 +14,11 @@ License: ASL 2.0
|
||||
URL: https://CRAN.R-project.org/package=%{packname}
|
||||
Source0: https://cran.r-project.org/src/contrib/%{packname}_%{packver}.tar.gz
|
||||
|
||||
# Fix leptonica include
|
||||
Patch0: R-tesseract_include.patch
|
||||
# Add support for tesseract 5
|
||||
Patch1: R-tesseract_tesseract5.patch
|
||||
|
||||
# Here's the R view of the dependencies world:
|
||||
# Depends:
|
||||
# Imports: R-Rcpp >= 0.12.12, R-pdftools >= 1.5, R-curl, R-rappdirs, R-digest
|
||||
@ -33,6 +38,7 @@ BuildRequires: R-spelling
|
||||
BuildRequires: R-knitr
|
||||
BuildRequires: R-tibble
|
||||
BuildRequires: R-rmarkdown
|
||||
BuildRequires: pkgconfig(lept)
|
||||
BuildRequires: pkgconfig(tesseract)
|
||||
|
||||
%description
|
||||
@ -43,7 +49,7 @@ algorithms and obtain the best possible results.
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q -c -n %{packname}
|
||||
%autosetup -p1 -c -n %{packname}
|
||||
|
||||
|
||||
%build
|
||||
|
7
R-tesseract_include.patch
Normal file
7
R-tesseract_include.patch
Normal file
@ -0,0 +1,7 @@
|
||||
diff -rupN --no-dereference a/tesseract/tools/test.cpp b/tesseract/tools/test.cpp
|
||||
--- a/tesseract/tools/test.cpp 2020-03-30 00:30:33.000000000 +0200
|
||||
+++ b/tesseract/tools/test.cpp 2021-12-11 22:49:04.133669737 +0100
|
||||
@@ -1,2 +1,2 @@
|
||||
#include <tesseract/baseapi.h>
|
||||
-#include <allheaders.h>
|
||||
+#include <leptonica/allheaders.h>
|
86
R-tesseract_tesseract5.patch
Normal file
86
R-tesseract_tesseract5.patch
Normal file
@ -0,0 +1,86 @@
|
||||
diff -rupN a/tesseract/src/tesseract.cpp b/tesseract/src/tesseract.cpp
|
||||
--- a/tesseract/src/tesseract.cpp 2021-09-17 12:44:09.000000000 +0200
|
||||
+++ b/tesseract/src/tesseract.cpp 2021-12-14 11:41:43.435908296 +0100
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "tesseract_types.h"
|
||||
+#if TESSERACT_MAJOR_VERSION < 5
|
||||
#include <tesseract/genericvector.h>
|
||||
+#endif
|
||||
|
||||
/* NB: libtesseract now insists that the engine is initiated in 'C' locale.
|
||||
* We do this as exemplified in the example code in the libc manual:
|
||||
@@ -42,7 +44,11 @@ Rcpp::List tesseract_config(){
|
||||
// [[Rcpp::export]]
|
||||
TessPtr tesseract_engine_internal(Rcpp::CharacterVector datapath, Rcpp::CharacterVector language, Rcpp::CharacterVector confpaths,
|
||||
Rcpp::CharacterVector opt_names, Rcpp::CharacterVector opt_values){
|
||||
+#if TESSERACT_MAJOR_VERSION < 5
|
||||
GenericVector<STRING> params, values;
|
||||
+#else
|
||||
+ std::vector<std::string> params, values;
|
||||
+#endif
|
||||
const char * path = NULL;
|
||||
const char * lang = NULL;
|
||||
char * configs[1000] = {0};
|
||||
@@ -88,7 +94,11 @@ TessPtr tesseract_engine_set_variable(Te
|
||||
|
||||
// [[Rcpp::export]]
|
||||
Rcpp::LogicalVector validate_params(Rcpp::CharacterVector params){
|
||||
+#if TESSERACT_MAJOR_VERSION < 5
|
||||
STRING str;
|
||||
+#else
|
||||
+ std::string str;
|
||||
+#endif
|
||||
tesseract::TessBaseAPI *api = make_analyze_api();
|
||||
Rcpp::LogicalVector out(params.length());
|
||||
for(int i = 0; i < params.length(); i++)
|
||||
@@ -101,16 +111,30 @@ Rcpp::LogicalVector validate_params(Rcpp
|
||||
// [[Rcpp::export]]
|
||||
Rcpp::List engine_info_internal(TessPtr ptr){
|
||||
tesseract::TessBaseAPI * api = get_engine(ptr);
|
||||
+#if TESSERACT_MAJOR_VERSION < 5
|
||||
GenericVector<STRING> langs;
|
||||
+#else
|
||||
+ std::vector<std::string> langs;
|
||||
+#endif
|
||||
api->GetAvailableLanguagesAsVector(&langs);
|
||||
Rcpp::CharacterVector available = Rcpp::CharacterVector::create();
|
||||
+#if TESSERACT_MAJOR_VERSION < 5
|
||||
for(int i = 0; i < langs.length(); i++)
|
||||
available.push_back(langs.get(i).string());
|
||||
+#else
|
||||
+ for(int i = 0; i < langs.size(); i++)
|
||||
+ available.push_back(langs[i]);
|
||||
+#endif
|
||||
langs.clear();
|
||||
api->GetLoadedLanguagesAsVector(&langs);
|
||||
Rcpp::CharacterVector loaded = Rcpp::CharacterVector::create();
|
||||
+#if TESSERACT_MAJOR_VERSION < 5
|
||||
for(int i = 0; i < langs.length(); i++)
|
||||
loaded.push_back(langs.get(i).string());
|
||||
+#else
|
||||
+ for(int i = 0; i < langs.size(); i++)
|
||||
+ loaded.push_back(langs[i]);
|
||||
+#endif
|
||||
return Rcpp::List::create(
|
||||
#ifndef LEGACY_TESSERACT_API
|
||||
Rcpp::_["datapath"] = api->GetDatapath(),
|
||||
@@ -135,11 +159,19 @@ Rcpp::String print_params(std::string fi
|
||||
|
||||
// [[Rcpp::export]]
|
||||
Rcpp::CharacterVector get_param_values(TessPtr ptr, Rcpp::CharacterVector params){
|
||||
+#if TESSERACT_MAJOR_VERSION < 5
|
||||
STRING str;
|
||||
+#else
|
||||
+ std::string str;
|
||||
+#endif
|
||||
tesseract::TessBaseAPI * api = get_engine(ptr);
|
||||
Rcpp::CharacterVector out(params.length());
|
||||
for(int i = 0; i < params.length(); i++)
|
||||
+#if TESSERACT_MAJOR_VERSION < 5
|
||||
out[i] = api->GetVariableAsString(params.at(i), &str) ? Rcpp::String(str.string()) : NA_STRING;
|
||||
+#else
|
||||
+ out[i] = api->GetVariableAsString(params.at(i), &str) ? Rcpp::String(str) : NA_STRING;
|
||||
+#endif
|
||||
return out;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user