Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv_contrib
Commits
adff4073
Commit
adff4073
authored
Dec 02, 2016
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #880 from alalek:text_test
parents
57648c2c
e1f01baf
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
142 additions
and
38 deletions
+142
-38
CMakeLists.txt
modules/text/CMakeLists.txt
+14
-14
FindTesseract.cmake
modules/text/FindTesseract.cmake
+0
-24
FindTesseract.cmake
modules/text/cmake/FindTesseract.cmake
+23
-0
test_detection.cpp
modules/text/test/test_detection.cpp
+91
-0
test_main.cpp
modules/text/test/test_main.cpp
+6
-0
test_precomp.hpp
modules/text/test/test_precomp.hpp
+8
-0
No files found.
modules/text/CMakeLists.txt
View file @
adff4073
set
(
the_description
"Text Detection and Recognition"
)
ocv_define_module
(
text opencv_ml opencv_
highgui opencv_imgproc opencv_core opencv_features2d
WRAP python
)
ocv_define_module
(
text opencv_ml opencv_
imgproc opencv_core opencv_features2d OPTIONAL opencv_highgui
WRAP python
)
set
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
${
CMAKE_CURRENT_SOURCE_DIR
}
)
find_package
(
Tesseract
)
if
(
Tesseract_FOUND
)
if
(
NOT CMAKE_CROSSCOMPILING OR OPENCV_FIND_TESSERACT
)
set
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake
)
find_package
(
Tesseract QUIET
)
if
(
Tesseract_FOUND
)
message
(
STATUS
"Tesseract: YES"
)
set
(
HAVE_TESSERACT 1
)
else
()
ocv_include_directories
(
${
Tesseract_INCLUDE_DIR
}
)
ocv_target_link_libraries
(
${
the_module
}
${
Tesseract_LIBRARIES
}
)
else
()
message
(
STATUS
"Tesseract: NO"
)
endif
()
endif
()
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/text_config.hpp.in
${
CMAKE_BINARY_DIR
}
/text_config.hpp @ONLY
)
include_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
)
if
(
${
Tesseract_FOUND
}
)
include_directories
(
${
Tesseract_INCLUDE_DIR
}
)
endif
()
ocv_include_directories
(
${
CMAKE_CURRENT_BINARY_DIR
}
)
if
(
${
Tesseract_FOUND
}
)
target_link_libraries
(
opencv_text
${
Tesseract_LIBS
}
)
endif
()
ocv_add_testdata
(
samples/ contrib/text
FILES_MATCHING PATTERN
"*.xml"
PATTERN
"*.xml.gz"
REGEX
"scenetext[0-9]+.jpg"
COMPONENT
"tests"
)
modules/text/FindTesseract.cmake
deleted
100644 → 0
View file @
57648c2c
# Tesseract OCR
unset
(
Tesseract_FOUND
)
find_path
(
Tesseract_INCLUDE_DIR tesseract/baseapi.h
HINTS
/usr/include
/usr/local/include
)
find_library
(
Tesseract_LIBRARY NAMES tesseract
HINTS
/usr/lib
/usr/local/lib
)
find_library
(
Lept_LIBRARY NAMES lept
HINTS
/usr/lib
/usr/local/lib
)
set
(
Tesseract_LIBS
${
Tesseract_LIBRARY
}
${
Lept_LIBRARY
}
)
if
(
Tesseract_LIBS AND Tesseract_INCLUDE_DIR
)
set
(
Tesseract_FOUND 1
)
endif
()
modules/text/cmake/FindTesseract.cmake
0 → 100644
View file @
adff4073
# Tesseract OCR
if
(
COMMAND pkg_check_modules
)
pkg_check_modules
(
Tesseract tesseract lept
)
endif
()
if
(
NOT Tesseract_FOUND
)
find_path
(
Tesseract_INCLUDE_DIR tesseract/baseapi.h
HINTS
/usr/local/include
)
find_library
(
Tesseract_LIBRARY NAMES tesseract
HINTS
/usr/local/lib
)
find_library
(
Lept_LIBRARY NAMES lept
HINTS
/usr/local/lib
)
if
(
Tesseract_INCLUDE_DIR AND Tesseract_LIBRARY AND Lept_LIBRARY
)
set
(
Tesseract_INCLUDE_DIRS
${
Tesseract_INCLUDE_DIR
}
)
set
(
Tesseract_LIBRARIES
${
Tesseract_LIBRARY
}
${
Lept_LIBRARY
}
)
set
(
Tesseract_FOUND 1
)
endif
()
endif
()
modules/text/test/test_detection.cpp
0 → 100644
View file @
adff4073
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "test_precomp.hpp"
#include "opencv2/imgcodecs.hpp"
using
namespace
cv
;
using
namespace
cv
::
text
;
using
namespace
cvtest
;
namespace
{
// Just skip test in case of missed testdata
static
cv
::
String
findDataFile
(
const
String
&
path
)
{
return
cvtest
::
findDataFile
(
path
,
false
);
}
PARAM_TEST_CASE
(
Detection
,
std
::
string
,
bool
)
{
Ptr
<
ERFilter
>
er_filter1
;
Ptr
<
ERFilter
>
er_filter2
;
// SetUp doesn't handle SkipTestException
void
InitERFilter
()
{
String
nm1_file
=
findDataFile
(
"trained_classifierNM1.xml"
);
String
nm2_file
=
findDataFile
(
"trained_classifierNM2.xml"
);
// Create ERFilter objects with the 1st and 2nd stage default classifiers
er_filter1
=
createERFilterNM1
(
loadClassifierNM1
(
nm1_file
),
16
,
0.00015
f
,
0.13
f
,
0.2
f
,
true
,
0.1
f
);
er_filter2
=
createERFilterNM2
(
loadClassifierNM2
(
nm2_file
),
0.5
);
}
};
TEST_P
(
Detection
,
sample
)
{
InitERFilter
();
std
::
string
imageName
=
GET_PARAM
(
0
);
bool
anyDirection
=
GET_PARAM
(
1
);
std
::
cout
<<
"Image: "
<<
imageName
<<
std
::
endl
;
std
::
cout
<<
"Orientation: "
<<
(
anyDirection
?
"any"
:
"horiz"
)
<<
std
::
endl
;
Mat
src
=
cv
::
imread
(
findDataFile
(
imageName
));
ASSERT_FALSE
(
src
.
empty
());
// Extract channels to be processed individually
std
::
vector
<
Mat
>
channels
;
computeNMChannels
(
src
,
channels
);
// Append negative channels to detect ER- (bright regions over dark background)
for
(
size_t
c
=
channels
.
size
();
c
>
0
;
c
--
)
channels
.
push_back
(
255
-
channels
[
c
-
1
]);
std
::
vector
<
std
::
vector
<
ERStat
>
>
regions
(
channels
.
size
());
// Apply the default cascade classifier to each independent channel (could be done in parallel)
for
(
size_t
c
=
0
;
c
<
channels
.
size
();
c
++
)
{
er_filter1
->
run
(
channels
[
c
],
regions
[
c
]);
er_filter2
->
run
(
channels
[
c
],
regions
[
c
]);
}
// Detect character groups
std
::
vector
<
std
::
vector
<
Vec2i
>
>
region_groups
;
std
::
vector
<
Rect
>
groups_boxes
;
if
(
!
anyDirection
)
erGrouping
(
src
,
channels
,
regions
,
region_groups
,
groups_boxes
,
ERGROUPING_ORIENTATION_HORIZ
);
else
erGrouping
(
src
,
channels
,
regions
,
region_groups
,
groups_boxes
,
ERGROUPING_ORIENTATION_ANY
,
findDataFile
(
"trained_classifier_erGrouping.xml"
),
0.5
);
std
::
cout
<<
"Found groups: "
<<
groups_boxes
.
size
()
<<
std
::
endl
;
EXPECT_GT
(
groups_boxes
.
size
(),
3u
);
}
INSTANTIATE_TEST_CASE_P
(
Text
,
Detection
,
testing
::
Combine
(
testing
::
Values
(
"text/scenetext01.jpg"
,
"text/scenetext02.jpg"
,
"text/scenetext03.jpg"
,
"text/scenetext04.jpg"
,
"text/scenetext05.jpg"
,
"text/scenetext06.jpg"
),
testing
::
Bool
()
));
}
modules/text/test/test_main.cpp
0 → 100644
View file @
adff4073
#include "test_precomp.hpp"
CV_TEST_MAIN
(
""
,
cvtest
::
addDataSearchSubDirectory
(
"contrib"
),
cvtest
::
addDataSearchSubDirectory
(
"contrib/text"
)
)
modules/text/test/test_precomp.hpp
0 → 100644
View file @
adff4073
#ifndef __OPENCV_TEST_TEXT_PRECOMP_HPP__
#define __OPENCV_TEST_TEXT_PRECOMP_HPP__
#include "opencv2/core.hpp"
#include "opencv2/ts.hpp"
#include "opencv2/text.hpp"
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment