Skip to content

Commit d29284c

Browse files
committed
text: cleanup dnn text detection part
1 parent c33629e commit d29284c

18 files changed

+271
-2802
lines changed

modules/text/CMakeLists.txt

Lines changed: 19 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,24 @@
11
set(the_description "Text Detection and Recognition")
2-
3-
if(POLICY CMP0023)
4-
message(STATUS "Explicitly setting policy CMP0023 to OLD")
5-
cmake_policy(SET CMP0023 OLD)
6-
endif(POLICY CMP0023)
7-
8-
# Using cmake scripts and modules
9-
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
10-
11-
set(TEXT_DEPS opencv_ml opencv_highgui opencv_imgproc opencv_core opencv_features2d opencv_calib3d)
12-
13-
find_package(Caffe)
14-
if(Caffe_FOUND)
15-
message(STATUS "Caffe: YES")
16-
set(HAVE_CAFFE 1)
17-
else()
18-
message(STATUS "Caffe: NO")
19-
# list(APPEND TEXT_DEPS opencv_dnn)
20-
endif()
21-
22-
#internal dependencies
23-
find_package(Protobuf)
24-
if(Protobuf_FOUND)
25-
message(STATUS "Protobuf: YES")
26-
set(HAVE_PROTOBUF 1)
27-
else()
28-
message(STATUS "Protobuf: NO")
29-
endif()
30-
31-
find_package(Glog)
32-
if(Glog_FOUND)
33-
message(STATUS "Glog: YES")
34-
set(HAVE_GLOG 1)
35-
else()
36-
message(STATUS "Glog: NO")
37-
endif()
38-
39-
ocv_define_module(text opencv_ml opencv_imgproc opencv_core opencv_features2d opencv_calib3d OPTIONAL opencv_dnn WRAP python)
40-
#ocv_define_module(text ${TEXT_DEPS} WRAP python)
41-
42-
#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
43-
44-
find_package(Tesseract)
45-
if(${Tesseract_FOUND})
46-
message(STATUS "Tesseract: YES")
47-
include_directories(${Tesseract_INCLUDE_DIR})
48-
target_link_libraries(opencv_text ${Tesseract_LIBS})
49-
add_definitions(-DHAVE_TESSERACT)
50-
else()
51-
message(STATUS "Tesseract: NO")
2+
ocv_define_module(text opencv_ml opencv_imgproc opencv_core opencv_features2d opencv_dnn OPTIONAL WRAP python java)
3+
4+
if(NOT CMAKE_CROSSCOMPILING OR OPENCV_FIND_TESSERACT)
5+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
6+
find_package(Tesseract QUIET)
7+
if(Tesseract_FOUND)
8+
message(STATUS "Tesseract: YES")
9+
set(HAVE_TESSERACT 1)
10+
ocv_include_directories(${Tesseract_INCLUDE_DIR})
11+
ocv_target_link_libraries(${the_module} ${Tesseract_LIBRARIES})
12+
else()
13+
message(STATUS "Tesseract: NO")
5214
endif()
15+
endif()
5316

17+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/text_config.hpp.in
18+
${CMAKE_BINARY_DIR}/text_config.hpp @ONLY)
5419

55-
if(HAVE_CAFFE AND HAVE_GLOG AND HAVE_PROTOBUF)
56-
include_directories(${Caffe_INCLUDE_DIR})
57-
find_package(HDF5 COMPONENTS HL REQUIRED)
58-
include_directories(SYSTEM ${HDF5_INCLUDE_DIRS} ${HDF5_HL_INCLUDE_DIR})
59-
list(APPEND Caffe_LINKER_LIBS ${HDF5_LIBRARIES})
60-
find_package(Boost 1.46 REQUIRED COMPONENTS system thread filesystem)
61-
include_directories(SYSTEM ${Boost_INCLUDE_DIR})
62-
include_directories(SYSTEM ${CUDA_INCLUDE_DIR})
63-
link_directories(SYSTEM ${CUDA_LIBS})
64-
# include_directories(SYSTEM /usr/local/cuda-8.0/targets/x86_64-linux/include/ usr/local/cuda-8.0/include/ /usr/local/cuda-7.5/targets/x86_64-linux/include/ )
65-
#link_directories(SYSTEM /usr/local/cuda-8.0/targets/x86_64-linux/lib/ usr/local/cuda-8.0/lib/ /usr/local/cuda-7.5/targets/x86_64-linux/lib/ /usr/lib/openblas-base/lib /usr/local/cuda-8.0/lib64)
66-
list(APPEND Caffe_LINKER_LIBS ${Boost_LIBRARIES})
67-
target_link_libraries(opencv_text atlas blas ${Caffe_LIBS} ${Glog_LIBS} ${Protobuf_LIBS} ${HDF5_LIBRARIES} ${Boost_LIBRARIES})
68-
add_definitions(-DHAVE_CAFFE)
69-
endif() #HAVE_CAFFE
70-
71-
message(STATUS "TEXT CAFFE SEARCH")
72-
if()
73-
message(STATUS "TEXT NO CAFFE CONFLICT")
74-
else()
75-
message(STATUS "TEXT CAFFE CONFLICT")
76-
endif()
20+
ocv_include_directories(${CMAKE_CURRENT_BINARY_DIR})
7721

78-
if(HAVE_opencv_dnn)
79-
message(STATUS "dnn module found")
80-
add_definitions(-DHAVE_DNN)
81-
set(HAVE_DNN 1)
82-
else()
83-
message(STATUS "dnn module not found")
84-
endif()
22+
ocv_add_testdata(samples/ contrib/text
23+
FILES_MATCHING PATTERN "*.xml" PATTERN "*.xml.gz" REGEX "scenetext[0-9]+.jpg"
24+
)

modules/text/FindCaffe.cmake

Lines changed: 0 additions & 14 deletions
This file was deleted.

modules/text/FindGlog.cmake

Lines changed: 0 additions & 10 deletions
This file was deleted.

modules/text/FindProtobuf.cmake

Lines changed: 0 additions & 10 deletions
This file was deleted.

modules/text/FindTesseract.cmake

Lines changed: 0 additions & 22 deletions
This file was deleted.

modules/text/README.md

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -56,74 +56,3 @@ Intro
5656
-----
5757

5858
The text module now have a text detection and recognition using deep CNN. The text detector deep CNN that takes an image which may contain multiple words. This outputs a list of Rects with bounding boxes and probability of text there. The text recognizer provides a probabillity over a given vocabulary for each of these rects.
59-
60-
Two backends are supported 1) caffe 2) opencv-dnn
61-
62-
63-
64-
65-
Instalation of Caffe backend
66-
----------------------------
67-
* Please note a custom caffe based on SSD branch is required, the link of the custom caffe is provided below
68-
The caffe wrapping backend has the requirements caffe does.
69-
* Caffe can be built against OpenCV, if the caffe backend is enabled, a circular bependency arises.
70-
The simplest solution is to build caffe without support for OpenCV.
71-
* Only the OS supported by Caffe are supported by the backend.
72-
The scripts describing the module have been developed in ubuntu 16.04 and assume such a system.
73-
Other UNIX systems including OSX should be easy to adapt.
74-
75-
Sample script for building Caffe
76-
77-
```bash
78-
#!/bin/bash
79-
SRCROOT="${HOME}/caffe_inst/"
80-
mkdir -p "$SRCROOT"
81-
cd "$SRCROOT"
82-
git clone https://github.com/sghoshcvc/TextBoxes.git
83-
cd TextBoxes
84-
cat Makefile.config.example > Makefile.config
85-
echo 'USE_OPENCV := 0' >> Makefile.config
86-
echo 'INCLUDE_DIRS += /usr/include/hdf5/serial/' >> Makefile.config
87-
echo 'LIBRARY_DIRS += /usr/lib/x86_64-linux-gnu/hdf5/serial/' >> Makefile.config
88-
89-
90-
echo "--- /tmp/caffe/include/caffe/net.hpp 2017-05-28 04:55:47.929623902 +0200
91-
+++ caffe/distribute/include/caffe/net.hpp 2017-05-28 04:51:33.437090768 +0200
92-
@@ -234,6 +234,7 @@
93-
94-
template <typename T>
95-
friend class Net;
96-
+ virtual ~Callback(){}
97-
};
98-
const vector<Callback*>& before_forward() const { return before_forward_; }
99-
void add_before_forward(Callback* value) {
100-
">/tmp/cleanup_caffe.diff
101-
102-
patch < /tmp/cleanup_caffe.diff
103-
104-
105-
make -j 6
106-
107-
make pycaffe
108-
109-
make distribute
110-
```
111-
112-
113-
```bash
114-
#!/bin/bash
115-
cd $OPENCV_BUILD_DIR #You must set this
116-
CAFFEROOT="${HOME}/caffe_inst/" #If you used the previous code to compile Caffe in ubuntu 16.04
117-
118-
cmake -DCaffe_LIBS:FILEPATH="$CAFFEROOT/caffe/distribute/lib/libcaffe.so" -DBUILD_opencv_ts:BOOL="0" -DBUILD_opencv_dnn:BOOL="0" -DBUILD_opencv_dnn_modern:BOOL="0" -DCaffe_INCLUDE_DIR:PATH="$CAFFEROOT/caffe/distribute/include" -DWITH_MATLAB:BOOL="0" -DBUILD_opencv_cudabgsegm:BOOL="0" -DWITH_QT:BOOL="1" -DBUILD_opencv_cudaoptflow:BOOL="0" -DBUILD_opencv_cudastereo:BOOL="0" -DBUILD_opencv_cudafilters:BOOL="0" -DBUILD_opencv_cudev:BOOL="1" -DOPENCV_EXTRA_MODULES_PATH:PATH="$OPENCV_CONTRIB/modules" ./
119-
120-
121-
```
122-
where $OPECV_CONTRIB is the root directory containing opencv_contrib module
123-
124-
Instalation of Caffe backend
125-
----------------------------
126-
127-
Use of opencv-dnn does not need any additional library.
128-
129-
The recent opencv-3.3.0 needs to be build with extra modules to use text module.

modules/text/cmake/FindTesseract.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ endif()
55
if(NOT Tesseract_FOUND)
66
find_path(Tesseract_INCLUDE_DIR tesseract/baseapi.h
77
HINTS
8+
/usr/include
89
/usr/local/include)
910

1011
find_library(Tesseract_LIBRARY NAMES tesseract
1112
HINTS
13+
/usr/lib
1214
/usr/local/lib)
1315

1416
find_library(Lept_LIBRARY NAMES lept
1517
HINTS
18+
/usr/lib
1619
/usr/local/lib)
1720

1821
if(Tesseract_INCLUDE_DIR AND Tesseract_LIBRARY AND Lept_LIBRARY)

modules/text/include/opencv2/text.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ grouping horizontally aligned text, and the method proposed by Lluis Gomez and D
9393
in @cite Gomez13 @cite Gomez14 for grouping arbitrary oriented text (see erGrouping).
9494
9595
To see the text detector at work, have a look at the textdetection demo:
96-
<https://github.com/Itseez/opencv_contrib/blob/master/modules/text/samples/textdetection.cpp>
96+
<https://github.com/opencv/opencv_contrib/blob/master/modules/text/samples/textdetection.cpp>
9797
9898
@defgroup text_recognize Scene Text Recognition
9999
@}

modules/text/include/opencv2/text/erfilter.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ component tree of the image. :
6565
*/
6666
struct CV_EXPORTS ERStat
6767
{
68-
6968
public:
7069
//! Constructor
7170
explicit ERStat(int level = 256, int pixel = 0, int x = 0, int y = 0);

0 commit comments

Comments
 (0)