Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
a7660331a
tesseract
提交
6b8b1f00
T
tesseract
项目概览
a7660331a
/
tesseract
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
tesseract
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6b8b1f00
编写于
8月 04, 2021
作者:
S
Stefan Weil
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
unittest: Remove some dependencies on abseil
Signed-off-by:
N
Stefan Weil
<
sw@weilnetz.de
>
上级
d50baec7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
30 addition
and
38 deletion
+30
-38
Makefile.am
Makefile.am
+3
-3
unittest/mastertrainer_test.cc
unittest/mastertrainer_test.cc
+0
-1
unittest/recodebeam_test.cc
unittest/recodebeam_test.cc
+6
-10
unittest/resultiterator_test.cc
unittest/resultiterator_test.cc
+14
-15
unittest/textlineprojection_test.cc
unittest/textlineprojection_test.cc
+7
-9
未找到文件。
Makefile.am
浏览文件 @
6b8b1f00
...
...
@@ -1521,7 +1521,7 @@ qrsequence_test_LDADD = $(ABSEIL_LIBS) $(TESS_LIBS)
recodebeam_test_SOURCES
=
unittest/recodebeam_test.cc
recodebeam_test_CPPFLAGS
=
$(unittest_CPPFLAGS)
recodebeam_test_LDADD
=
$(
ABSEIL_LIBS)
$(
TRAINING_LIBS)
$(ICU_I18N_LIBS)
$(ICU_UC_LIBS)
recodebeam_test_LDADD
=
$(TRAINING_LIBS)
$(ICU_I18N_LIBS)
$(ICU_UC_LIBS)
rect_test_SOURCES
=
unittest/rect_test.cc
rect_test_CPPFLAGS
=
$(unittest_CPPFLAGS)
...
...
@@ -1529,7 +1529,7 @@ rect_test_LDADD = $(TESS_LIBS)
resultiterator_test_SOURCES
=
unittest/resultiterator_test.cc
resultiterator_test_CPPFLAGS
=
$(unittest_CPPFLAGS)
resultiterator_test_LDADD
=
$(
ABSEIL_LIBS)
$(
TRAINING_LIBS)
resultiterator_test_LDADD
=
$(TRAINING_LIBS)
resultiterator_test_LDADD
+=
$(LEPTONICA_LIBS)
$(ICU_I18N_LIBS)
$(ICU_UC_LIBS)
scanutils_test_SOURCES
=
unittest/scanutils_test.cc
...
...
@@ -1580,7 +1580,7 @@ tatweel_test_LDADD = $(TRAINING_LIBS)
textlineprojection_test_SOURCES
=
unittest/textlineprojection_test.cc
textlineprojection_test_CPPFLAGS
=
$(unittest_CPPFLAGS)
textlineprojection_test_LDADD
=
$(
ABSEIL_LIBS)
$(
TRAINING_LIBS)
$(LEPTONICA_LIBS)
textlineprojection_test_LDADD
=
$(TRAINING_LIBS)
$(LEPTONICA_LIBS)
tfile_test_SOURCES
=
unittest/tfile_test.cc
tfile_test_CPPFLAGS
=
$(unittest_CPPFLAGS)
...
...
unittest/mastertrainer_test.cc
浏览文件 @
6b8b1f00
...
...
@@ -32,7 +32,6 @@
#include "trainingsample.h"
#include "unicharset.h"
#include "absl/strings/numbers.h" // for safe_strto32
#include "absl/strings/str_split.h" // for absl::StrSplit
#include <string>
...
...
unittest/recodebeam_test.cc
浏览文件 @
6b8b1f00
...
...
@@ -22,8 +22,6 @@
#include "helpers.h"
#include "absl/strings/str_format.h" // for absl::StrFormat
namespace
tesseract
{
// Number of characters to test beam search with.
...
...
@@ -160,9 +158,9 @@ protected:
if
(
u_decoded
.
size
()
<
truth_utf8
.
size
())
{
const
char
*
str
=
ccutil_
.
unicharset
.
id_to_unichar
(
unichar_ids
[
u
]);
total_rating
+=
ratings
[
u
];
LOG
(
INFO
)
<<
absl
::
StrFormat
(
"%d:u_id=%d=%s, c=%g, r=%g, r_sum=%g @%d"
,
u
,
unichar_ids
[
u
],
str
,
certainties
[
u
],
ratings
[
u
],
total_rating
,
xcoords
[
u
])
<<
"
\n
"
;
LOG
(
INFO
)
<<
u
<<
":u_id="
<<
unichar_ids
[
u
]
<<
"="
<<
str
<<
", c="
<<
certainties
[
u
]
<<
", r="
<<
ratings
[
u
]
<<
"r_sum="
<<
total_rating
<<
" @"
<<
xcoords
[
u
]
<<
"
\n
"
;
if
(
str
[
0
]
==
' '
)
{
total_rating
=
0.0
f
;
}
...
...
@@ -184,11 +182,9 @@ protected:
}
w_decoded
+=
word
->
best_choice
->
unichar_string
().
c_str
();
}
LOG
(
INFO
)
<<
absl
::
StrFormat
(
"Word:%d = %s, c=%g, r=%g, perm=%d"
,
w
,
word
->
best_choice
->
unichar_string
().
c_str
(),
word
->
best_choice
->
certainty
(),
word
->
best_choice
->
rating
(),
word
->
best_choice
->
permuter
())
<<
"
\n
"
;
LOG
(
INFO
)
<<
"Word:"
<<
w
<<
" = "
<<
word
->
best_choice
->
unichar_string
()
<<
", c="
<<
word
->
best_choice
->
certainty
()
<<
", r="
<<
word
->
best_choice
->
rating
()
<<
", perm="
<<
word
->
best_choice
->
permuter
()
<<
"
\n
"
;
}
std
::
string
w_trunc
(
w_decoded
.
data
(),
truth_utf8
.
size
());
if
(
truth_utf8
!=
w_trunc
)
{
...
...
unittest/resultiterator_test.cc
浏览文件 @
6b8b1f00
...
...
@@ -5,7 +5,6 @@
#include <string>
#include "scrollview.h"
#include "absl/strings/str_format.h" // for absl::StrFormat
#include "include_gunit.h"
#include "log.h" // for LOG
...
...
@@ -99,7 +98,7 @@ protected:
pixWrite
(
outfile
.
c_str
(),
pix
,
IFF_PNG
);
}
pix
.
destroy
();
LOG
(
INFO
)
<<
absl
::
StrFormat
(
"At level %d: pix diff = %d
\n
"
,
level
,
pixcount
)
;
LOG
(
INFO
)
<<
"At level "
<<
level
<<
": pix diff = "
<<
pixcount
<<
"
\n
"
;
EXPECT_LE
(
pixcount
,
max_diff
);
// if (base::GetFlag(FLAGS_v) > 1) CHECK_LE(pixcount, max_diff);
}
...
...
@@ -293,7 +292,8 @@ TEST_F(ResultIteratorTest, EasyTest) {
// Test baseline of the first line.
int
x1
,
y1
,
x2
,
y2
;
r_it
->
Baseline
(
tesseract
::
RIL_TEXTLINE
,
&
x1
,
&
y1
,
&
x2
,
&
y2
);
LOG
(
INFO
)
<<
absl
::
StrFormat
(
"Baseline (%d,%d)->(%d,%d)"
,
x1
,
y1
,
x2
,
y2
)
<<
"
\n
"
;
LOG
(
INFO
)
<<
"Baseline ("
<<
x1
<<
','
<<
y1
<<
")->("
<<
x2
<<
','
<<
y2
<<
")
\n
"
;
// Make sure we have a decent vector.
EXPECT_GE
(
x2
,
x1
+
400
);
// The point 200,116 should be very close to the baseline.
...
...
@@ -315,9 +315,9 @@ TEST_F(ResultIteratorTest, EasyTest) {
float
confidence
=
r_it
->
Confidence
(
tesseract
::
RIL_WORD
);
EXPECT_GE
(
confidence
,
80.0
f
);
char
*
word_str
=
r_it
->
GetUTF8Text
(
tesseract
::
RIL_WORD
);
LOG
(
INFO
)
<<
absl
::
StrFormat
(
"Word %s in font %s, id %d, size %d, conf %g"
,
word_str
,
font
,
font_id
,
pointsize
,
confidence
)
<<
"
\n
"
;
LOG
(
INFO
)
<<
"Word "
<<
word_str
<<
" in font "
<<
font
<<
", id "
<<
font_id
<<
", size "
<<
pointsize
<<
", conf "
<<
confidence
<<
"
\n
"
;
delete
[]
word_str
;
EXPECT_FALSE
(
bold
);
EXPECT_FALSE
(
italic
);
...
...
@@ -372,8 +372,8 @@ TEST_F(ResultIteratorTest, SmallCapDropCapTest) {
&
pointsize
,
&
font_id
);
char
*
word_str
=
r_it
->
GetUTF8Text
(
tesseract
::
RIL_WORD
);
if
(
word_str
!=
nullptr
)
{
LOG
(
INFO
)
<<
absl
::
StrFormat
(
"Word %s is %s"
,
word_str
,
smallcaps
?
"SMALLCAPS"
:
"Normal"
)
<<
"
\n
"
;
LOG
(
INFO
)
<<
"Word "
<<
word_str
<<
" is "
<<
(
smallcaps
?
"SMALLCAPS"
:
"Normal"
)
<<
"
\n
"
;
if
(
r_it
->
SymbolIsDropcap
())
{
++
found_dropcaps
;
}
...
...
@@ -392,7 +392,7 @@ TEST_F(ResultIteratorTest, SmallCapDropCapTest) {
while
(
s_it
.
Next
(
tesseract
::
RIL_SYMBOL
)
&&
!
s_it
.
IsAtBeginningOf
(
tesseract
::
RIL_WORD
))
{
if
(
s_it
.
SymbolIsDropcap
())
{
char
*
sym_str
=
s_it
.
GetUTF8Text
(
tesseract
::
RIL_SYMBOL
);
LOG
(
ERROR
)
<<
absl
::
StrFormat
(
"Symbol %s of word %s is dropcap"
,
sym_str
,
word_str
)
;
LOG
(
ERROR
)
<<
"Symbol "
<<
sym_str
<<
" of word "
<<
word_str
<<
" is dropcap"
;
delete
[]
sym_str
;
}
EXPECT_FALSE
(
s_it
.
SymbolIsDropcap
());
...
...
@@ -433,8 +433,7 @@ TEST_F(ResultIteratorTest, SubSuperTest) {
result = r_it->GetUTF8Text(tesseract::RIL_SYMBOL);
if (strchr(kAllowedSupers, result[0]) == nullptr) {
char* word = r_it->GetUTF8Text(tesseract::RIL_WORD);
LOG(ERROR) << absl::StrFormat("Char %s in word %s is unexpected super!",
result, word);
LOG(ERROR) << "Char " << result << " in word " << word << " is unexpected super!";
delete [] word;
EXPECT_TRUE(strchr(kAllowedSupers, result[0]) != nullptr);
}
...
...
@@ -445,8 +444,8 @@ TEST_F(ResultIteratorTest, SubSuperTest) {
}
} while (r_it->Next(tesseract::RIL_SYMBOL));
delete r_it;
LOG(INFO) <<
absl::StrFormat("Subs = %d, supers= %d, normal = %d",
found_subs, found_supers, found_normal)
<< "\n";
LOG(INFO) <<
"Subs = " << found_subs << ", supers= " << found_supers
<< ", normal = " << found_normal
<< "\n";
EXPECT_GE(found_subs, 25);
EXPECT_GE(found_supers, 25);
EXPECT_GE(found_normal, 1350);
...
...
@@ -528,7 +527,7 @@ TEST_F(ResultIteratorTest, DISABLED_NonNullChoicesTest) {
do
{
char
*
word_str
=
r_it
->
GetUTF8Text
(
tesseract
::
RIL_WORD
);
if
(
word_str
!=
nullptr
)
{
LOG
(
INFO
)
<<
absl
::
StrFormat
(
"Word %s:"
,
word_str
)
<<
"
\n
"
;
LOG
(
INFO
)
<<
"Word "
<<
word_str
<<
":
\n
"
;
ResultIterator
s_it
=
*
r_it
;
do
{
tesseract
::
ChoiceIterator
c_it
(
s_it
);
...
...
@@ -571,7 +570,7 @@ TEST_F(ResultIteratorTest, NonNullConfidencesTest) {
const
char
*
char_str
=
s_it
.
GetUTF8Text
(
tesseract
::
RIL_SYMBOL
);
CHECK
(
char_str
!=
nullptr
);
float
confidence
=
s_it
.
Confidence
(
tesseract
::
RIL_SYMBOL
);
LOG
(
INFO
)
<<
absl
::
StrFormat
(
"Char %s has confidence %g
\n
"
,
char_str
,
confidence
)
;
LOG
(
INFO
)
<<
"Char "
<<
char_str
<<
" has confidence "
<<
confidence
<<
"
\n
"
;
delete
[]
char_str
;
}
while
(
!
s_it
.
IsAtFinalElement
(
tesseract
::
RIL_WORD
,
tesseract
::
RIL_SYMBOL
)
&&
s_it
.
Next
(
tesseract
::
RIL_SYMBOL
));
...
...
unittest/textlineprojection_test.cc
浏览文件 @
6b8b1f00
...
...
@@ -12,7 +12,6 @@
#include <allheaders.h>
#include <string> // for std::string
#include "absl/strings/str_format.h" // for absl::StrFormat
#include "include_gunit.h"
#include <tesseract/baseapi.h>
...
...
@@ -114,13 +113,12 @@ protected:
const
char
*
message
)
{
int
value
=
projection_
->
EvaluateBox
(
box
,
denorm_
,
false
);
if
(
greater_or_equal
!=
(
value
>
target_value
))
{
LOG
(
INFO
)
<<
absl
::
StrFormat
(
"EvaluateBox too %s:%d vs %d for %s word '%s' at:"
,
greater_or_equal
?
"low"
:
"high"
,
value
,
target_value
,
message
,
text
);
LOG
(
INFO
)
<<
"EvaluateBox too "
<<
(
greater_or_equal
?
"low"
:
"high"
)
<<
":"
<<
value
<<
" vs "
<<
target_value
<<
" for "
<<
message
<<
" word '"
<<
text
<<
"' at:"
;
box
.
print
();
value
=
projection_
->
EvaluateBox
(
box
,
denorm_
,
true
);
}
else
{
LOG
(
INFO
)
<<
absl
::
StrFormat
(
"EvaluateBox OK(%d) for %s word '%s'"
,
value
,
message
,
text
)
;
LOG
(
INFO
)
<<
"EvaluateBox OK("
<<
value
<<
") for "
<<
message
<<
" word '"
<<
text
<<
"'"
;
}
if
(
greater_or_equal
)
{
EXPECT_GE
(
value
,
target_value
);
...
...
@@ -136,14 +134,14 @@ protected:
int
true_dist
=
projection_
->
DistanceOfBoxFromBox
(
box
,
true_box
,
true
,
denorm_
,
false
);
int
false_dist
=
projection_
->
DistanceOfBoxFromBox
(
box
,
false_box
,
true
,
denorm_
,
false
);
if
(
false_dist
<=
true_dist
)
{
LOG
(
INFO
)
<<
absl
::
StrFormat
(
"Distance wrong:%d vs %d for %s word '%s' at:"
,
false_dist
,
true_dist
,
message
,
text
)
;
LOG
(
INFO
)
<<
"Distance wrong:"
<<
false_dist
<<
" vs "
<<
true_dist
<<
" for "
<<
message
<<
" word '"
<<
text
<<
"' at:"
;
true_box
.
print
();
projection_
->
DistanceOfBoxFromBox
(
box
,
true_box
,
true
,
denorm_
,
true
);
projection_
->
DistanceOfBoxFromBox
(
box
,
false_box
,
true
,
denorm_
,
true
);
}
else
{
LOG
(
INFO
)
<<
absl
::
StrFormat
(
"Distance OK(%d vs %d) for %s word '%s'"
,
false_dist
,
true_dist
,
message
,
text
)
;
LOG
(
INFO
)
<<
"Distance OK("
<<
false_dist
<<
" vs "
<<
true_dist
<<
") for "
<<
message
<<
" word '"
<<
text
<<
"'"
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录