// -*- C++ -*- // Copyright 2006-2007 Deutsches Forschungszentrum fuer Kuenstliche Intelligenz // or its licensors, as applicable. // // You may not use this file except under the terms of the accompanying license. // // Licensed under the Apache License, Version 2.0 (the "License"); you // may not use this file except in compliance with the License. You may // obtain a copy of the License at http: www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Project: // File: // Purpose: // Responsible: tmb // Reviewer: // Primary Repository: // Web Sites: www.iupr.org, www.dfki.de #ifndef h_ocroscript_util__ #define h_ocroscript_util__ #include "colib.h" #include "imgio.h" #include "imglib.h" //#include "triv-hocr.h" #include "ocr-layout-rast.h" //#include "ocr-recognize-page.h" #include "ocr-binarize-sauvola.h" #include "langmod-shortest-path.h" #include "segmentation.h" #ifdef HAVE_TESSERACT #include "tesseract.h" #endif #include "ocr-utils.h" #include "bpnet.h" #include "ocrcomponents.h" #ifdef HAVE_FST #include "fstutil.h" #endif namespace ocropus { // print an array (for debugging) enum {pa_max = 20}; template inline void debug_array(colib::narray &a) { fprintf(stderr,"[n=%d min=%g max=%g] ",a.length1d(),double(min(a)),double(max(a))); if(a.rank()==1) { fprintf(stderr,"[%d] ",a.dim(0)); int i; for(i=0;i",i); int j; for(j=0;j result(new colib::intarray()); for(int i=0;ipush(a[i]); return result.move(); } inline colib::intarray *as_intarray(colib::nustring &a) { colib::autodel result(new colib::intarray()); for(int i=0;ipush(a[i].value); return result.move(); } inline colib::intarray *as_intarray(colib::bytearray &a) { colib::autodel result(new colib::intarray()); for(int i=0;ipush(a[i]); return result.move(); } inline char *as_string(colib::bytearray &a) { char *result = (char *)malloc(a.length()+1); for(int i=0;i result(new colib::intarray()); utf8_decode(*result,s); return result.move(); } inline const char *utf8(colib::intarray &a) { return malloc_utf8_encode(a); } #endif