aperrault / DetectText

Detect text with stroke width transform.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compilation error on Ubuntu 14.04

farirat opened this issue · comments

commented

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);

Did you try changing the C++ std while compiling.
$ g++ -o DetectText TextDetection.cpp FeaturesMain.cpp -lopencv_core -lopencv_highgui -lopencv_imgproc -I/path/to/current/directory -std=c++14

Use this and that will remove the not allowed in C++98 error. However there is a syntactical error in between as well. Whatever error is left after that please comment here.