mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-24 02:59:07 +08:00
unittest: Fix and enable applybox_test
It needs an update of the test submodule. The tests only pass with a small modification of the ground truth texts (kTruthTextWords, kTruthTextLine). Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
abd1c3d879
commit
46f65bf0c2
2
test
2
test
@ -1 +1 @@
|
||||
Subproject commit 5fc323c76c409cb21962a4182cb893d3da3040ba
|
||||
Subproject commit b101b9a269b9511237c0d32128e1200d272c6bfd
|
@ -58,6 +58,7 @@ AM_CPPFLAGS += -isystem $(top_srcdir)/googletest/googletest/include \
|
||||
|
||||
check_PROGRAMS = \
|
||||
apiexample_test \
|
||||
applybox_test \
|
||||
bitvector_test \
|
||||
cleanapi_test \
|
||||
colpartition_test \
|
||||
@ -93,6 +94,9 @@ apiexample_test_SOURCES = apiexample_test.cc
|
||||
apiexample_test_LDFLAGS = $(OPENCL_LDFLAGS) $(LEPTONICA_LIBS)
|
||||
apiexample_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS) $(LEPTONICA_LIBS)
|
||||
|
||||
applybox_test_SOURCES = applybox_test.cc
|
||||
applybox_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
|
||||
|
||||
bitvector_test_SOURCES = bitvector_test.cc
|
||||
bitvector_test_LDADD = $(GTEST_LIBS) $(TESS_LIBS)
|
||||
|
||||
|
@ -1,30 +1,40 @@
|
||||
// (C) Copyright 2017, 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 <string>
|
||||
#include "leptonica/include/allheaders.h"
|
||||
#include "tesseract/api/baseapi.h"
|
||||
#include "tesseract/ccmain/resultiterator.h"
|
||||
#include "tesseract/ccstruct/boxread.h"
|
||||
#include "tesseract/ccstruct/rect.h"
|
||||
#include "allheaders.h"
|
||||
#include "baseapi.h"
|
||||
#include "boxread.h"
|
||||
#include "rect.h"
|
||||
#include "resultiterator.h"
|
||||
|
||||
#include "include_gunit.h"
|
||||
|
||||
namespace {
|
||||
|
||||
using tesseract::ResultIterator;
|
||||
|
||||
const char* kTruthTextWords = "To simple burn running of goods lately.\n\n";
|
||||
const char* kTruthTextLine = "Tosimpleburnrunningofgoodslately.\n\n";
|
||||
const char* kTruthTextWords = "To simple burn running of goods lately.\n";
|
||||
const char* kTruthTextLine = "Tosimpleburnrunningofgoodslately.\n";
|
||||
|
||||
// The fixture for testing Tesseract.
|
||||
class ApplyBoxTest : public testing::Test {
|
||||
protected:
|
||||
string TestDataNameToPath(const string& name) {
|
||||
return file::JoinPath(FLAGS_test_srcdir,
|
||||
"testdata/" + name);
|
||||
std::string TestDataNameToPath(const std::string& name) {
|
||||
return file::JoinPath(TESTING_DIR, name);
|
||||
}
|
||||
string TessdataPath() {
|
||||
return file::JoinPath(FLAGS_test_srcdir,
|
||||
"tessdata");
|
||||
std::string TessdataPath() {
|
||||
return TESSDATA_DIR;
|
||||
}
|
||||
string OutputNameToPath(const string& name) {
|
||||
std::string OutputNameToPath(const std::string& name) {
|
||||
return file::JoinPath(FLAGS_test_tmpdir, name);
|
||||
}
|
||||
|
||||
@ -63,7 +73,7 @@ class ApplyBoxTest : public testing::Test {
|
||||
delete [] ocr_text;
|
||||
// Test the boxes by reading the target box file in parallel with the
|
||||
// bounding boxes in the ocr output.
|
||||
string box_filename = TestDataNameToPath(target_box_file);
|
||||
std::string box_filename = TestDataNameToPath(target_box_file);
|
||||
FILE* box_file = OpenBoxFile(STRING(box_filename.c_str()));
|
||||
ASSERT_TRUE(box_file != NULL);
|
||||
int height = pixGetHeight(src_pix_);
|
||||
@ -91,7 +101,7 @@ class ApplyBoxTest : public testing::Test {
|
||||
}
|
||||
|
||||
Pix* src_pix_;
|
||||
string ocr_text_;
|
||||
std::string ocr_text_;
|
||||
tesseract::TessBaseAPI api_;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user