Commit dc48968f authored by sghoshcvc's avatar sghoshcvc

removed blanks, fixed Cmake issue

parent c697e41b
set(the_description "Text Detection and Recognition") set(the_description "Text Detection and Recognition")
if(POLICY CMP0023)
message(STATUS "Explicitly setting policy CMP0023 to OLD")
cmake_policy(SET CMP0023 OLD)
endif(POLICY CMP0023)
# Using cmake scripts and modules # Using cmake scripts and modules
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
......
...@@ -49,20 +49,22 @@ Notes ...@@ -49,20 +49,22 @@ Notes
3. You are encouraged to search the Net for some better pre-trained classifiers, as well as classifiers for other languages. 3. You are encouraged to search the Net for some better pre-trained classifiers, as well as classifiers for other languages.
Word spotting CNN Text Detection CNN
================= =================
Intro Intro
----- -----
A word spotting CNN is a CNN that takes an image assumed to contain a single word and provides a probabillity over a given vocabulary. 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.
Although other backends will be supported, for the moment only the Caffe backend is supported.
Two backends are supported 1) caffe 2) opencv-dnn
Instalation of Caffe backend Instalation of Caffe backend
---------------------------- ----------------------------
* Please note a custom caffe based on SSD branch is required, the link of the custom caffe is provided below
The caffe wrapping backend has the requirements caffe does. The caffe wrapping backend has the requirements caffe does.
* Caffe can be built against OpenCV, if the caffe backend is enabled, a circular bependency arises. * Caffe can be built against OpenCV, if the caffe backend is enabled, a circular bependency arises.
The simplest solution is to build caffe without support for OpenCV. The simplest solution is to build caffe without support for OpenCV.
...@@ -77,10 +79,8 @@ Sample script for building Caffe ...@@ -77,10 +79,8 @@ Sample script for building Caffe
SRCROOT="${HOME}/caffe_inst/" SRCROOT="${HOME}/caffe_inst/"
mkdir -p "$SRCROOT" mkdir -p "$SRCROOT"
cd "$SRCROOT" cd "$SRCROOT"
git clone https://github.com/BVLC/caffe.git git clone https://github.com/sghoshcvc/TextBoxes.git
cd caffe cd TextBoxes
git checkout 91b09280f5233cafc62954c98ce8bc4c204e7475
git branch 91b09280f5233cafc62954c98ce8bc4c204e7475
cat Makefile.config.example > Makefile.config cat Makefile.config.example > Makefile.config
echo 'USE_OPENCV := 0' >> Makefile.config echo 'USE_OPENCV := 0' >> Makefile.config
echo 'INCLUDE_DIRS += /usr/include/hdf5/serial/' >> Makefile.config echo 'INCLUDE_DIRS += /usr/include/hdf5/serial/' >> Makefile.config
...@@ -115,77 +115,15 @@ make distribute ...@@ -115,77 +115,15 @@ make distribute
cd $OPENCV_BUILD_DIR #You must set this cd $OPENCV_BUILD_DIR #You must set this
CAFFEROOT="${HOME}/caffe_inst/" #If you used the previous code to compile Caffe in ubuntu 16.04 CAFFEROOT="${HOME}/caffe_inst/" #If you used the previous code to compile Caffe in ubuntu 16.04
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="/home/anguelos/work/projects/opencv_gsoc/opencv_contrib/modules" ./ 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" ./
``` ```
where $OPECV_CONTRIB is the root directory containing opencv_contrib module
Text Detection CNN
=================
Intro
-----
A text detection CNN is a CNN that takes an image which may contain multiple words. This outputs a list of Rects with bounding boxes and probability of text there.
Although other backends will be supported, for the moment only the Caffe backend is supported.
Instalation of Caffe backend Instalation of Caffe backend
---------------------------- ----------------------------
* Please note a custom caffe based on SSD branch is required, the link of the custom caffe is provided below
The caffe wrapping backend has the requirements caffe does.
* Caffe can be built against OpenCV, if the caffe backend is enabled, a circular bependency arises.
The simplest solution is to build caffe without support for OpenCV.
* Only the OS supported by Caffe are supported by the backend.
The scripts describing the module have been developed in ubuntu 16.04 and assume such a system.
Other UNIX systems including OSX should be easy to adapt.
Sample script for building Caffe Use of opencv-dnn does not need any additional library.
```bash The recent opencv-3.3.0 needs to be build with extra modules to use text module.
#!/bin/bash
SRCROOT="${HOME}/caffe_inst/"
mkdir -p "$SRCROOT"
cd "$SRCROOT"
git clone https://github.com/sghoshcvc/TextBoxes.git
cd TextBoxes
cat Makefile.config.example > Makefile.config
echo 'USE_OPENCV := 0' >> Makefile.config
echo 'INCLUDE_DIRS += /usr/include/hdf5/serial/' >> Makefile.config
echo 'LIBRARY_DIRS += /usr/lib/x86_64-linux-gnu/hdf5/serial/' >> Makefile.config
echo "--- /tmp/caffe/include/caffe/net.hpp 2017-05-28 04:55:47.929623902 +0200
+++ caffe/distribute/include/caffe/net.hpp 2017-05-28 04:51:33.437090768 +0200
@@ -234,6 +234,7 @@
template <typename T>
friend class Net;
+ virtual ~Callback(){}
};
const vector<Callback*>& before_forward() const { return before_forward_; }
void add_before_forward(Callback* value) {
">/tmp/cleanup_caffe.diff
patch < /tmp/cleanup_caffe.diff
make -j 6
make pycaffe
make distribute
```
```bash
#!/bin/bash
cd $OPENCV_BUILD_DIR #You must set this
CAFFEROOT="${HOME}/caffe_inst/" #If you used the previous code to compile Caffe in ubuntu 16.04
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="/home/anguelos/work/projects/opencv_gsoc/opencv_contrib/modules" ./
```
...@@ -657,7 +657,6 @@ CV_EXPORTS_W Ptr<OCRBeamSearchDecoder::ClassifierCallback> loadOCRBeamSearchClas ...@@ -657,7 +657,6 @@ CV_EXPORTS_W Ptr<OCRBeamSearchDecoder::ClassifierCallback> loadOCRBeamSearchClas
//Classifiers should provide diferent backends //Classifiers should provide diferent backends
//For the moment only caffe is implemeted
enum{ enum{
OCR_HOLISTIC_BACKEND_NONE, //No back end OCR_HOLISTIC_BACKEND_NONE, //No back end
......
...@@ -45,8 +45,6 @@ ...@@ -45,8 +45,6 @@
#include "opencv2/text.hpp" #include "opencv2/text.hpp"
//#include "text_config.hpp"
#ifdef HAVE_TESSERACT #ifdef HAVE_TESSERACT
#include <tesseract/baseapi.h> #include <tesseract/baseapi.h>
#include <tesseract/resultiterator.h> #include <tesseract/resultiterator.h>
......
...@@ -91,7 +91,6 @@ protected: ...@@ -91,7 +91,6 @@ protected:
} }
#ifdef HAVE_CAFFE #ifdef HAVE_CAFFE
Ptr<caffe::Net<float> > net_; Ptr<caffe::Net<float> > net_;
#endif #endif
...@@ -160,10 +159,6 @@ public: ...@@ -160,10 +159,6 @@ public:
this->outputGeometry_.height =net_->output_blobs()[0]->height(); this->outputGeometry_.height =net_->output_blobs()[0]->height();
this->outputGeometry_.width = net_->output_blobs()[0]->width(); this->outputGeometry_.width = net_->output_blobs()[0]->width();
#else #else
CV_Error(Error::StsError,"Caffe not available during compilation!"); CV_Error(Error::StsError,"Caffe not available during compilation!");
#endif #endif
......
#ifndef __OPENCV_TEXT_CONFIG_HPP__ #ifndef __OPENCV_TEXT_CONFIG_HPP__
#define __OPENCV_TEXT_CONFIG_HPP__ #define __OPENCV_TEXT_CONFIG_HPP__
// HAVE QT5
//#cmakedefine HAVE_QT5GUI
// HAVE CAFFE
//#cmakedefine HAVE_CAFFE
// HAVE OCR Tesseract
//#cmakedefine HAVE_TESSERACT
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment