aperrault / detecttext Goto Github PK
View Code? Open in Web Editor NEWDetect text with stroke width transform.
License: GNU General Public License v3.0
Detect text with stroke width transform.
License: GNU General Public License v3.0
I wonder that when the function""findLegallyConnectedComponents " is planning to return,but it stuck into returning .Could someone help me with that?
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
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
I compiled it on centos as per your instructions in README. But it is giving Segmentation fault.
Any idea why?
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
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
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);
...&&((_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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.