Giter Club home page Giter Club logo

detecttext's Introduction

DetectText

Detect text with stroke width transform.

Dependencies

OpenCV 2.4+, boost.

Compile

g++ -o DetectText TextDetection.cpp FeaturesMain.cpp -lopencv_core -lopencv_highgui -lopencv_imgproc -I/path/to/current/directory

where /path/to/current/directory is replaced with the absolute path to the current directory.

Using CMake

mkdir build
cd build
cmake ..
make

To run

./TextDetection input_file output_file dark_on_light where dark_on_light is 1 or 0, indicating whether the text is darker or lighter than the background.

More

Details on the algorithm can be found in: http://www.cs.cornell.edu/courses/cs4670/2010fa/projects/final/results/group_of_arp86_sk2357/Writeup.pdf

detecttext's People

Contributors

aperrault avatar minyongyoon avatar royshil avatar xthepoet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

detecttext's Issues

Compilation error (undefined reference) in OpenCV v3.2 in Ubuntu 18.04

I tried to compile and run in in a fresh Ubuntu 18.04 with the following packages installed:

  • libboost-all-dev
  • libopencv-dev
  • build-essential

I got the following compilation error:

user@host$ g++ -o DetectText TextDetection.cpp FeaturesMain.cpp -lopencv_core -lopencv_highgui -lopencv_imgproc -I$PWD -std=c++14
/tmp/cczWcHDX.o: In function `DetectText::textDetection(cv::Mat const&, bool)':
TextDetection.cpp:(.text+0x214b): undefined reference to `cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
TextDetection.cpp:(.text+0x27dc): undefined reference to `cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
TextDetection.cpp:(.text+0x2973): undefined reference to `cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
/tmp/ccuK5nnV.o: In function `loadByteImage(char const*)':
FeaturesMain.cpp:(.text+0xfc): undefined reference to `cv::imread(cv::String const&, int)'
/tmp/ccuK5nnV.o: In function `loadFloatImage(char const*)':
FeaturesMain.cpp:(.text+0x29c): undefined reference to `cv::imread(cv::String const&, int)'
/tmp/ccuK5nnV.o: In function `mainTextDetection(int, char**)':
FeaturesMain.cpp:(.text+0x5d6): undefined reference to `cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status

Not an issue but an enquiry

Can I use this code snippet into my android java project and
if I can will this code be efficient and could you please tell me which file to call I have no idea about C++ and started working on NDK for the first time .
Thanks in advance

Segmentation fault

I compiled it on centos as per your instructions in README. But it is giving Segmentation fault.

Any idea why?

Compilation error on Ubuntu 14.04

Getting the following error:

# g++ -o DetectText TextDetection.cpp FeaturesMain.cpp -lopencv_core -lopencv_highgui -lopencv_imgproc -I/path/to/current/directory
TextDetection.cpp: In function ‘std::vector<std::pair<cv::Point_<int>, cv::Point_<int> > > DetectText::findBoundingBoxes(std::vector<std::vector<DetectText::SWTPoint2d> >&, std::vector<DetectText::Chain>&, std::vector<std::pair<DetectText::SWTPoint2d, DetectText::SWTPoint2d> >&, cv::Mat&)’:
TextDetection.cpp:63:16: error: ISO C++ forbids declaration of ‘chainit’ with no type [-fpermissive]
     for (auto& chainit : chains) {
                ^
TextDetection.cpp:63:26: error: range-based ‘for’ loops are not allowed in C++98 mode
     for (auto& chainit : chains) {
                          ^
TextDetection.cpp:68:61: error: request for member ‘components’ in ‘chainit’, which is of non-class type ‘int’
         for (std::vector<int>::const_iterator cit = chainit.components.begin(); cit != chainit.components.end(); cit++) {
                                                             ^
TextDetection.cpp:68:96: error: request for member ‘components’ in ‘chainit’, which is of non-class type ‘int’
         for (std::vector<int>::const_iterator cit = chainit.components.begin(); cit != chainit.components.end(); cit++) {
                                                                                                ^
TextDetection.cpp: In function ‘std::vector<std::pair<cv::Point_<int>, cv::Point_<int> > > DetectText::findBoundingBoxes(std::vector<std::vector<DetectText::SWTPoint2d> >&, cv::Mat&)’:
TextDetection.cpp:86:16: error: ISO C++ forbids declaration of ‘compit’ with no type [-fpermissive]
     for (auto& compit : components) {
                ^
TextDetection.cpp:86:25: error: range-based ‘for’ loops are not allowed in C++98 mode
     for (auto& compit : components) {
                         ^
TextDetection.cpp:91:20: error: ISO C++ forbids declaration of ‘it’ with no type [-fpermissive]
         for (auto& it : compit) {
                    ^
TextDetection.cpp:91:25: error: range-based ‘for’ loops are not allowed in C++98 mode
         for (auto& it : compit) {
                         ^
TextDetection.cpp:92:37: error: request for member ‘y’ in ‘it’, which is of non-class type ‘int’
             miny = std::min(miny,it.y);
                                     ^
TextDetection.cpp:93:37: error: request for member ‘x’ in ‘it’, which is of non-class type ‘int’
             minx = std::min(minx,it.x);
                                     ^
TextDetection.cpp:94:37: error: request for member ‘y’ in ‘it’, which is of non-class type ‘int’
             maxy = std::max(maxy,it.y);
                                     ^
TextDetection.cpp:95:37: error: request for member ‘x’ in ‘it’, which is of non-class type ‘int’
             maxx = std::max(maxx,it.x);
                                     ^
TextDetection.cpp: In function ‘void DetectText::renderComponents(const cv::Mat&, std::vector<std::vector<DetectText::SWTPoint2d> >&, cv::Mat&)’:
TextDetection.cpp:144:13: error: ISO C++ forbids declaration of ‘component’ with no type [-fpermissive]
  for (auto& component : components) {
             ^
TextDetection.cpp:144:25: error: range-based ‘for’ loops are not allowed in C++98 mode
  for (auto& component : components) {
                         ^
TextDetection.cpp:145:20: error: ISO C++ forbids declaration of ‘pit’ with no type [-fpermissive]
         for (auto& pit : component) {
                    ^
TextDetection.cpp:145:26: error: range-based ‘for’ loops are not allowed in C++98 mode
         for (auto& pit : component) {
                          ^
TextDetection.cpp:146:34: error: request for member ‘y’ in ‘pit’, which is of non-class type ‘int’
             output.at<float>(pit.y, pit.x) = SWTImage.at<float>(pit.y, pit.x);
                                  ^
TextDetection.cpp:146:41: error: request for member ‘x’ in ‘pit’, which is of non-class type ‘int’
             output.at<float>(pit.y, pit.x) = SWTImage.at<float>(pit.y, pit.x);
                                         ^
TextDetection.cpp:146:69: error: request for member ‘y’ in ‘pit’, which is of non-class type ‘int’
             output.at<float>(pit.y, pit.x) = SWTImage.at<float>(pit.y, pit.x);
                                                                     ^
TextDetection.cpp:146:76: error: request for member ‘x’ in ‘pit’, which is of non-class type ‘int’
             output.at<float>(pit.y, pit.x) = SWTImage.at<float>(pit.y, pit.x);
                                                                            ^
TextDetection.cpp: In function ‘void DetectText::renderComponentsWithBoxes(cv::Mat&, std::vector<std::vector<DetectText::SWTPoint2d> >&, std::vector<std::pair<DetectText::SWTPoint2d, DetectText::SWTPoint2d> >&, cv::Mat&)’:
TextDetection.cpp:194:16: error: ISO C++ forbids declaration of ‘it’ with no type [-fpermissive]
     for (auto& it : compBB) {
                ^
TextDetection.cpp:194:21: error: range-based ‘for’ loops are not allowed in C++98 mode
     for (auto& it : compBB) {
                     ^
TextDetection.cpp:195:33: error: request for member ‘first’ in ‘it’, which is of non-class type ‘int’
         Point2i p0 = cvPoint(it.first.x,  it.first.y);
                                 ^
TextDetection.cpp:195:46: error: request for member ‘first’ in ‘it’, which is of non-class type ‘int’
         Point2i p0 = cvPoint(it.first.x,  it.first.y);
                                              ^
TextDetection.cpp:196:33: error: request for member ‘second’ in ‘it’, which is of non-class type ‘int’
         Point2i p1 = cvPoint(it.second.x, it.second.y);
                                 ^
TextDetection.cpp:196:46: error: request for member ‘second’ in ‘it’, which is of non-class type ‘int’
         Point2i p1 = cvPoint(it.second.x, it.second.y);
                                              ^
TextDetection.cpp:206:15: error: ‘it’ does not name a type
     for (auto it : bb) {
               ^
TextDetection.cpp:220:1: error: expected ‘;’ before ‘}’ token
 }
 ^
TextDetection.cpp:220:1: error: expected primary-expression before ‘}’ token
TextDetection.cpp:220:1: error: expected ‘;’ before ‘}’ token
TextDetection.cpp:220:1: error: expected primary-expression before ‘}’ token
TextDetection.cpp:220:1: error: expected ‘)’ before ‘}’ token
TextDetection.cpp:220:1: error: expected primary-expression before ‘}’ token
TextDetection.cpp:220:1: error: expected ‘;’ before ‘}’ token
TextDetection.cpp: In function ‘void DetectText::renderChainsWithBoxes(cv::Mat&, std::vector<std::vector<DetectText::SWTPoint2d> >&, std::vector<DetectText::Chain>&, std::vector<std::pair<DetectText::SWTPoint2d, DetectText::SWTPoint2d> >&, cv::Mat&)’:
TextDetection.cpp:233:22: error: range-based ‘for’ loops are not allowed in C++98 mode
     for (Chain& it : chains) {
                      ^
TextDetection.cpp:256:16: error: ISO C++ forbids declaration of ‘it’ with no type [-fpermissive]
     for (auto& it : bb) {
                ^
TextDetection.cpp:256:21: error: range-based ‘for’ loops are not allowed in C++98 mode
     for (auto& it : bb) {
                     ^
TextDetection.cpp:268:30: error: request for member ‘first’ in ‘it’, which is of non-class type ‘int’
         rectangle(output, it.first, it.second, c, 2);
                              ^
TextDetection.cpp:268:40: error: request for member ‘second’ in ‘it’, which is of non-class type ‘int’
         rectangle(output, it.first, it.second, c, 2);
                                        ^
TextDetection.cpp: In function ‘void DetectText::SWTMedianFilter(cv::Mat&, std::vector<DetectText::Ray>&)’:
TextDetection.cpp:474:16: error: ISO C++ forbids declaration of ‘rit’ with no type [-fpermissive]
     for (auto& rit : rays) {
                ^
TextDetection.cpp:474:22: error: range-based ‘for’ loops are not allowed in C++98 mode
     for (auto& rit : rays) {
                      ^
TextDetection.cpp:475:20: error: ISO C++ forbids declaration of ‘pit’ with no type [-fpermissive]
         for (auto& pit : rit.points) {
                    ^
TextDetection.cpp:475:26: error: range-based ‘for’ loops are not allowed in C++98 mode
         for (auto& pit : rit.points) {
                          ^
TextDetection.cpp:475:30: error: request for member ‘points’ in ‘rit’, which is of non-class type ‘int’
         for (auto& pit : rit.points) {
                              ^
TextDetection.cpp:476:17: error: request for member ‘SWT’ in ‘pit’, which is of non-class type ‘int’
             pit.SWT = SWTImage.at<float>(pit.y, pit.x);
                 ^
TextDetection.cpp:476:46: error: request for member ‘y’ in ‘pit’, which is of non-class type ‘int’
             pit.SWT = SWTImage.at<float>(pit.y, pit.x);
                                              ^
TextDetection.cpp:476:53: error: request for member ‘x’ in ‘pit’, which is of non-class type ‘int’
             pit.SWT = SWTImage.at<float>(pit.y, pit.x);
                                                     ^
TextDetection.cpp:478:23: error: request for member ‘points’ in ‘rit’, which is of non-class type ‘int’
         std::sort(rit.points.begin(), rit.points.end(), &Point2dSort);
                       ^
TextDetection.cpp:478:43: error: request for member ‘points’ in ‘rit’, which is of non-class type ‘int’
         std::sort(rit.points.begin(), rit.points.end(), &Point2dSort);
                                           ^
TextDetection.cpp:479:29: error: request for member ‘points’ in ‘rit’, which is of non-class type ‘int’
         float median = (rit.points[rit.points.size()/2]).SWT;
                             ^
TextDetection.cpp:479:40: error: request for member ‘points’ in ‘rit’, which is of non-class type ‘int’
         float median = (rit.points[rit.points.size()/2]).SWT;
                                        ^
TextDetection.cpp:480:20: error: ISO C++ forbids declaration of ‘pit’ with no type [-fpermissive]
         for (auto& pit : rit.points) {
                    ^
TextDetection.cpp:480:26: error: range-based ‘for’ loops are not allowed in C++98 mode
         for (auto& pit : rit.points) {
                          ^
TextDetection.cpp:480:30: error: request for member ‘points’ in ‘rit’, which is of non-class type ‘int’
         for (auto& pit : rit.points) {
                              ^
TextDetection.cpp:481:36: error: request for member ‘y’ in ‘pit’, which is of non-class type ‘int’
             SWTImage.at<float>(pit.y, pit.x) = std::min(pit.SWT, median);
                                    ^
TextDetection.cpp:481:43: error: request for member ‘x’ in ‘pit’, which is of non-class type ‘int’
             SWTImage.at<float>(pit.y, pit.x) = std::min(pit.SWT, median);
                                           ^
TextDetection.cpp:481:61: error: request for member ‘SWT’ in ‘pit’, which is of non-class type ‘int’
             SWTImage.at<float>(pit.y, pit.x) = std::min(pit.SWT, median);

Error during conversion to Opencv 2.4.2

Hi,
I am very much interested in using this algorithm for my text recognition system. Your code was using IplImages and older form of opencv and so decided to change it to cv::Mat and use the newer functions. But I am getting not getting the actual outputs which I had got for your code. I know it sounds weird but could you help me out on this.

Vivek

Cannot compile against opencv 2.4

I'm using ubuntu 14.04 and installing the opencv libs via:

apt-get install libopencv-core2.4 libopencv-core-dev

but when I compile it's telling me it can't find the opencv/cv.h header file. When I look in /usr/include I'm not seeing it there either, instead I'm seeing opencv2/opencv.hpp

in line 528... and after

...&&((_ptr)/right <= 3.0 || right/(_ptr) <= 3.0)

Correct me if I am wrong, but this is always true. If You have two real numbers, like 'a' and 'b', a/b or b/a should be less than 1. I think because of this, things get connected which should not be, and we will have huge components.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.