mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-01 07:59:05 +08:00
commit
23afe833f9
@ -527,7 +527,6 @@ install(FILES
|
||||
src/ccstruct/publictypes.h
|
||||
|
||||
#from ccutil/makefile.am
|
||||
src/ccutil/basedir.h
|
||||
src/ccutil/errcode.h
|
||||
src/ccutil/fileerr.h
|
||||
src/ccutil/genericvector.h
|
||||
|
@ -23,7 +23,6 @@
|
||||
# include "config_auto.h"
|
||||
#endif
|
||||
|
||||
#include "basedir.h"
|
||||
#include "control.h"
|
||||
# include "matchdefs.h"
|
||||
#include "pageres.h"
|
||||
|
@ -38,7 +38,7 @@ libtesseract_ccstruct_la_SOURCES = \
|
||||
linlsq.cpp matrix.cpp mod128.cpp normalis.cpp \
|
||||
ocrblock.cpp ocrpara.cpp ocrrow.cpp otsuthr.cpp \
|
||||
pageres.cpp pdblock.cpp points.cpp polyaprx.cpp polyblk.cpp \
|
||||
params_training_featdef.cpp publictypes.cpp \
|
||||
params_training_featdef.cpp \
|
||||
quadlsq.cpp quspline.cpp ratngs.cpp rect.cpp rejctmap.cpp \
|
||||
seam.cpp split.cpp statistc.cpp stepblob.cpp \
|
||||
vecfuncs.cpp werd.cpp
|
||||
|
@ -1,40 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// File: publictypes.cpp
|
||||
// Description: Types used in both the API and internally
|
||||
// Author: Ray Smith
|
||||
// Created: Wed Mar 03 11:17:09 PST 2010
|
||||
//
|
||||
// (C) Copyright 2010, Google Inc.
|
||||
// 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.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "publictypes.h"
|
||||
|
||||
/** String name for each block type. Keep in sync with PolyBlockType. */
|
||||
const char* kPolyBlockNames[] = {
|
||||
"Unknown",
|
||||
"Flowing Text",
|
||||
"Heading Text",
|
||||
"Pullout Text",
|
||||
"Equation",
|
||||
"Inline Equation",
|
||||
"Table",
|
||||
"Vertical Text",
|
||||
"Caption Text",
|
||||
"Flowing Image",
|
||||
"Heading Image",
|
||||
"Pullout Image",
|
||||
"Horizontal Line",
|
||||
"Vertical Line",
|
||||
"Noise",
|
||||
"" // End marker for testing that sizes match.
|
||||
};
|
@ -2,7 +2,6 @@
|
||||
// File: publictypes.h
|
||||
// Description: Types used in both the API and internally
|
||||
// Author: Ray Smith
|
||||
// Created: Wed Mar 03 09:22:53 PST 2010
|
||||
//
|
||||
// (C) Copyright 2010, Google Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -47,7 +46,7 @@ constexpr int kResolutionEstimationFactor = 10;
|
||||
/**
|
||||
* Possible types for a POLY_BLOCK or ColPartition.
|
||||
* Must be kept in sync with kPBColors in polyblk.cpp and PTIs*Type functions
|
||||
* below, as well as kPolyBlockNames in publictypes.cpp.
|
||||
* below, as well as kPolyBlockNames in layout_test.cc.
|
||||
* Used extensively by ColPartition, and POLY_BLOCK.
|
||||
*/
|
||||
enum PolyBlockType {
|
||||
@ -90,9 +89,6 @@ inline bool PTIsPulloutType(PolyBlockType type) {
|
||||
return type == PT_PULLOUT_IMAGE || type == PT_PULLOUT_TEXT;
|
||||
}
|
||||
|
||||
/** String name for each block type. Keep in sync with PolyBlockType. */
|
||||
extern const char* kPolyBlockNames[];
|
||||
|
||||
namespace tesseract {
|
||||
/**
|
||||
* +------------------+ Orientation Example:
|
||||
|
@ -16,7 +16,7 @@ pkginclude_HEADERS = \
|
||||
unichar.h
|
||||
|
||||
noinst_HEADERS = \
|
||||
ambigs.h basedir.h bits16.h bitvector.h ccutil.h clst.h doubleptr.h elst2.h \
|
||||
ambigs.h bits16.h bitvector.h ccutil.h clst.h doubleptr.h elst2.h \
|
||||
elst.h errcode.h fileerr.h \
|
||||
genericheap.h globaloc.h host.h \
|
||||
indexmapbidi.h kdpair.h lsterr.h \
|
||||
@ -28,7 +28,7 @@ noinst_HEADERS = \
|
||||
noinst_LTLIBRARIES = libtesseract_ccutil.la
|
||||
|
||||
libtesseract_ccutil_la_SOURCES = \
|
||||
ambigs.cpp basedir.cpp bitvector.cpp \
|
||||
ambigs.cpp bitvector.cpp \
|
||||
ccutil.cpp clst.cpp \
|
||||
elst2.cpp elst.cpp errcode.cpp \
|
||||
globaloc.cpp indexmapbidi.cpp \
|
||||
|
@ -1,44 +0,0 @@
|
||||
/**********************************************************************
|
||||
* File: basedir.cpp (Formerly getpath.c)
|
||||
* Description: Find the directory location of the current executable using
|
||||
*PATH. Author: Ray Smith Created: Mon Jul 09 09:06:39 BST 1990
|
||||
*
|
||||
* (C) Copyright 1990, Hewlett-Packard Ltd.
|
||||
** 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.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#include "basedir.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
// Assuming that code_path is the name of some file in a desired directory,
|
||||
// returns the given code_path stripped back to the last slash, leaving
|
||||
// the last slash in place. If there is no slash, returns ./ assuming that
|
||||
// the input was the name of something in the current directory.
|
||||
// Useful for getting to the directory of argv[0], but does not search
|
||||
// any paths.
|
||||
TESS_API void truncate_path(const char *code_path, STRING* trunc_path) {
|
||||
int trunc_index = -1;
|
||||
if (code_path != nullptr) {
|
||||
const char* last_slash = strrchr(code_path, '/');
|
||||
if (last_slash != nullptr && last_slash + 1 - code_path > trunc_index)
|
||||
trunc_index = last_slash + 1 - code_path;
|
||||
last_slash = strrchr(code_path, '\\');
|
||||
if (last_slash != nullptr && last_slash + 1 - code_path > trunc_index)
|
||||
trunc_index = last_slash + 1 - code_path;
|
||||
}
|
||||
*trunc_path = code_path;
|
||||
if (trunc_index >= 0)
|
||||
trunc_path->truncate_at(trunc_index);
|
||||
else
|
||||
*trunc_path = "./";
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
/**********************************************************************
|
||||
* File: basedir.h (Formerly getpath.h)
|
||||
* Description: Header file for getpath.c. Provides relocatability of data.
|
||||
* Author: Ray Smith
|
||||
* Created: Mon Jul 09 09:13:03 BST 1990
|
||||
*
|
||||
* (C) Copyright 1990, Hewlett-Packard Ltd.
|
||||
** 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.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef BASEDIR_H
|
||||
#define BASEDIR_H
|
||||
|
||||
#include "platform.h"
|
||||
#include "strngs.h"
|
||||
|
||||
// Returns the given code_path truncated to the last slash.
|
||||
// Useful for getting to the directory of argv[0], but does not search
|
||||
// any paths.
|
||||
TESS_API void truncate_path(const char *code_path, STRING* trunc_path);
|
||||
|
||||
#endif
|
@ -18,7 +18,7 @@
|
||||
// cl_amd_fp64: AMD extension
|
||||
// use build option outside to define fp_t
|
||||
/////////////////////////////////////////////
|
||||
const char *kernel_src = KERNEL(
|
||||
static const char* kernel_src = KERNEL(
|
||||
\n#ifdef KHR_DP_EXTENSION\n
|
||||
\n#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n
|
||||
\n#elif AMD_DP_EXTENSION\n
|
||||
|
@ -22,7 +22,7 @@ noinst_HEADERS = \
|
||||
alignedblob.h baselinedetect.h bbgrid.h blkocc.h blobgrid.h \
|
||||
ccnontextdetect.h cjkpitch.h colfind.h colpartition.h colpartitionset.h \
|
||||
colpartitiongrid.h \
|
||||
devanagari_processing.h drawedg.h drawtord.h edgblob.h edgloop.h \
|
||||
devanagari_processing.h drawtord.h edgblob.h edgloop.h \
|
||||
equationdetectbase.h \
|
||||
fpchop.h gap_map.h imagefind.h linefind.h makerow.h oldbasel.h \
|
||||
pithsync.h pitsync1.h scanedg.h sortflts.h strokewidth.h \
|
||||
@ -37,7 +37,7 @@ libtesseract_textord_la_SOURCES = \
|
||||
alignedblob.cpp baselinedetect.cpp bbgrid.cpp blkocc.cpp blobgrid.cpp \
|
||||
ccnontextdetect.cpp cjkpitch.cpp colfind.cpp colpartition.cpp colpartitionset.cpp \
|
||||
colpartitiongrid.cpp devanagari_processing.cpp \
|
||||
drawedg.cpp drawtord.cpp edgblob.cpp edgloop.cpp \
|
||||
drawtord.cpp edgblob.cpp edgloop.cpp \
|
||||
equationdetectbase.cpp \
|
||||
fpchop.cpp gap_map.cpp imagefind.cpp linefind.cpp makerow.cpp oldbasel.cpp \
|
||||
pithsync.cpp pitsync1.cpp scanedg.cpp sortflts.cpp strokewidth.cpp \
|
||||
|
@ -1,81 +0,0 @@
|
||||
/**********************************************************************
|
||||
* File: drawedg.cpp (Formerly drawedge.c)
|
||||
* Description: Collection of functions to draw things to do with edge
|
||||
* detection.
|
||||
* Author: Ray Smith
|
||||
* Created: Thu Jun 06 13:29:20 BST 1991
|
||||
*
|
||||
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
||||
** 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.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#include "drawedg.h"
|
||||
|
||||
// Include automatically generated configuration file if running autoconf.
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config_auto.h"
|
||||
#endif
|
||||
|
||||
#ifndef GRAPHICS_DISABLED
|
||||
|
||||
/** title of window */
|
||||
#define IMAGE_WIN_NAME "Edges"
|
||||
#define IMAGE_XPOS 250
|
||||
/** default position */
|
||||
#define IMAGE_YPOS 0
|
||||
|
||||
/**
|
||||
* @name create_edges_window
|
||||
*
|
||||
* Create the edges window.
|
||||
* @param page_tr size of image
|
||||
*/
|
||||
|
||||
ScrollView* create_edges_window(ICOORD page_tr) {
|
||||
ScrollView* image_win; //image window
|
||||
|
||||
//create the window
|
||||
image_win = new ScrollView (IMAGE_WIN_NAME, IMAGE_XPOS, IMAGE_YPOS, 0, 0, page_tr.x (), page_tr.y ());
|
||||
return image_win; //window
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @name draw_raw_edge
|
||||
*
|
||||
* Draw the raw steps to the given window in the given colour.
|
||||
* @param fd window to draw in
|
||||
* @param start start of loop
|
||||
* @param colour colour to draw in
|
||||
*/
|
||||
|
||||
void draw_raw_edge(ScrollView* fd,
|
||||
CRACKEDGE *start,
|
||||
ScrollView::Color colour) {
|
||||
CRACKEDGE *edgept; //current point
|
||||
|
||||
fd->Pen(colour);
|
||||
edgept = start;
|
||||
fd->SetCursor(edgept->pos.x (), edgept->pos.y ());
|
||||
do {
|
||||
do
|
||||
edgept = edgept->next;
|
||||
//merge straight lines
|
||||
while (edgept != start && edgept->prev->stepx == edgept->stepx && edgept->prev->stepy == edgept->stepy);
|
||||
|
||||
//draw lines
|
||||
fd->DrawTo(edgept->pos.x (), edgept->pos.y ());
|
||||
}
|
||||
while (edgept != start);
|
||||
}
|
||||
|
||||
#endif // GRAPHICS_DISABLED
|
@ -1,37 +0,0 @@
|
||||
/**********************************************************************
|
||||
* File: drawedg.h (Formerly drawedge.h)
|
||||
* Description: Collection of functions to draw things to do with edge
|
||||
*detection.
|
||||
* Author: Ray Smith
|
||||
* Created: Thu Jun 06 13:29:20 BST 1991
|
||||
*
|
||||
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
||||
** 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.
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef DRAWEDG_H
|
||||
#define DRAWEDG_H
|
||||
#ifndef GRAPHICS_DISABLED
|
||||
|
||||
#include "scrollview.h"
|
||||
#include "crakedge.h"
|
||||
|
||||
ScrollView* create_edges_window( //make window
|
||||
ICOORD page_tr //size of image
|
||||
);
|
||||
void draw_raw_edge( //draw the cracks
|
||||
ScrollView* fd, //window to draw in
|
||||
CRACKEDGE *start, //start of loop
|
||||
ScrollView::Color colour //colour to draw in
|
||||
);
|
||||
#endif
|
||||
#endif
|
@ -17,7 +17,6 @@
|
||||
**********************************************************************/
|
||||
|
||||
#include "scanedg.h"
|
||||
#include "drawedg.h"
|
||||
#include "edgloop.h"
|
||||
#include "edgblob.h"
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
/**********************************************************************
|
||||
* File: edgloop.cpp (Formerly edgeloop.c)
|
||||
* Description: Functions to clean up an outline before approximation.
|
||||
* Author: Ray Smith
|
||||
* Created: Tue Mar 26 16:56:25 GMT 1991
|
||||
* Author: Ray Smith
|
||||
*
|
||||
* (C) Copyright 1991, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -17,9 +16,8 @@
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
#include "scanedg.h"
|
||||
#include "drawedg.h"
|
||||
#include "edgloop.h"
|
||||
#include "scanedg.h"
|
||||
#include "edgloop.h"
|
||||
|
||||
// Include automatically generated configuration file if running autoconf.
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
1
sw.cpp
1
sw.cpp
@ -116,7 +116,6 @@ void build(Solution &s)
|
||||
"src/ccstruct/publictypes.h",
|
||||
|
||||
//from ccutil/makefile.am
|
||||
"src/ccutil/basedir.h",
|
||||
"src/ccutil/errcode.h",
|
||||
"src/ccutil/fileerr.h",
|
||||
"src/ccutil/genericvector.h",
|
||||
|
@ -63,14 +63,6 @@ class TesseractTest : public testing::Test {
|
||||
}
|
||||
};
|
||||
|
||||
// Tests that array sizes match their intended size.
|
||||
TEST_F(TesseractTest, ArraySizeTest) {
|
||||
int size = 0;
|
||||
for (size = 0; kPolyBlockNames[size][0] != '\0'; ++size)
|
||||
;
|
||||
EXPECT_EQ(size, PT_COUNT);
|
||||
}
|
||||
|
||||
// Tests that Tesseract gets exactly the right answer on phototest.
|
||||
TEST_F(TesseractTest, BasicTesseractTest) {
|
||||
tesseract::TessBaseAPI api;
|
||||
|
@ -31,6 +31,26 @@ using tesseract::MutableIterator;
|
||||
using tesseract::PageIteratorLevel;
|
||||
using tesseract::ResultIterator;
|
||||
|
||||
/** String name for each block type. Keep in sync with PolyBlockType. */
|
||||
static const char* kPolyBlockNames[] = {
|
||||
"Unknown",
|
||||
"Flowing Text",
|
||||
"Heading Text",
|
||||
"Pullout Text",
|
||||
"Equation",
|
||||
"Inline Equation",
|
||||
"Table",
|
||||
"Vertical Text",
|
||||
"Caption Text",
|
||||
"Flowing Image",
|
||||
"Heading Image",
|
||||
"Pullout Image",
|
||||
"Horizontal Line",
|
||||
"Vertical Line",
|
||||
"Noise",
|
||||
"" // End marker for testing that sizes match.
|
||||
};
|
||||
|
||||
const char* kStrings8087_054[] = {
|
||||
"dat", "Dalmatian", "", "DAMAGED DURING", "margarine,", nullptr};
|
||||
const PolyBlockType kBlocks8087_054[] = {PT_HEADING_TEXT, PT_FLOWING_TEXT,
|
||||
@ -171,6 +191,14 @@ class LayoutTest : public testing::Test {
|
||||
tesseract::TessBaseAPI api_;
|
||||
};
|
||||
|
||||
// Tests that array sizes match their intended size.
|
||||
TEST_F(LayoutTest, ArraySizeTest) {
|
||||
int size = 0;
|
||||
for (size = 0; kPolyBlockNames[size][0] != '\0'; ++size)
|
||||
;
|
||||
EXPECT_EQ(size, PT_COUNT);
|
||||
}
|
||||
|
||||
// Tests that Tesseract gets the important blocks and in the right order
|
||||
// on a UNLV page numbered 8087_054.3B.tif. (Dubrovnik)
|
||||
TEST_F(LayoutTest, UNLV8087_054) {
|
||||
|
Loading…
Reference in New Issue
Block a user