Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Every thing works fine except for: CommandLineParser has no member named ‘about’,print message,has,check

#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv/cv.h> /// include most of core headers
#include <opencv/highgui.h> // include GUI-related headers

using namespace cv;
using namespace std;


// OpenCV command line parser functions
// Keys accecpted by command line parser

const char* keys =
        {
                "{help h usage ? | | print this message}"
                        "{@video | | Video file, if not defined try to use webcamera}"
        };
int main(int ac, const char** av)
{

    CommandLineParser parser(ac,av,keys);
    parser.about("Chapter 2. v1.0.0");
    //If requires help show
    if (parser.has("help"))
    {
        parser.printMessage();
        return 0;
    }
    String videoFile= parser.get<String>(0);
// Check if params are correctly parsed in his variables
    if (!parser.check())
    {
        parser.printErrors();
        return 0;
    }
    cv::VideoCapture cap;
    const std::string kWinName1 = "Exercise 1 - Original Image";
    const std::string kWinName2 = "Exercise 1 - Thresholded Image";

    std::cout << "Startup (Press ESC to quit)" << std::endl;
    namedWindow( kWinName1, CV_WINDOW_AUTOSIZE);
    cv::namedWindow( kWinName2, CV_WINDOW_NORMAL);
    initVideoStream(cap);

    int slider_value = 100;
    cv::createTrackbar( "Threshold", "Exercise 1 - Thresholded Image", &slider_value, 255, trackbarHandler, &slider_value);

    Mat img_bgr;
    cv::Mat img_gray;
    cv::Mat img_filtered;

    while (1) {

        cap >> img_bgr;

        if(img_bgr.empty()){
            printf("Could not query frame. Trying to reinitialize.\n");
            initVideoStream(cap);
            cv::waitKey(1000); /// Wait for one sec.
            continue;
        }
        cv::cvtColor( img_bgr, img_gray, CV_BGR2GRAY );

        //threshold( img_gray, img_filtered, slider_value, 255, CV_THRESH_BINARY);
       adaptiveThreshold(img_gray, img_filtered, 255, CV_ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY, 33, 8);

        cv::imshow(kWinName1, img_bgr);
        cv::imshow(kWinName2, img_filtered);

        char key = (char) cv::waitKey (0);
        if (key == 27) break;
    }

    cv::destroyWindow (kWinName1);
    cv::destroyWindow (kWinName2);
    std::cout << "Finished\n";
}

Every thing works fine except for: CommandLineParser has no member named ‘about’,print message,has,check

 #include <iostream>
 #include <opencv2/opencv.hpp>
 #include <opencv2/core/core.hpp>
 #include <opencv/cv.h> /// include most of core headers
 #include <opencv/highgui.h> // include GUI-related headers

 using namespace cv;
 using namespace std;


 // OpenCV command line parser functions
 // Keys accecpted by command line parser

 const char* keys =
         {
                 "{help h usage ? | | print this message}"
                         "{@video | | Video file, if not defined try to use webcamera}"
         };
 int main(int ac, const char** av)
 {

     CommandLineParser parser(ac,av,keys);
     parser.about("Chapter 2. v1.0.0");
     //If requires help show
     if (parser.has("help"))
     {
         parser.printMessage();
         return 0;
     }
     String videoFile= parser.get<String>(0);
 // Check if params are correctly parsed in his variables
     if (!parser.check())
     {
         parser.printErrors();
         return 0;
     }
     cv::VideoCapture cap;
     const std::string kWinName1 = "Exercise 1 - Original Image";
     const std::string kWinName2 = "Exercise 1 - Thresholded Image";

     std::cout << "Startup (Press ESC to quit)" << std::endl;
     namedWindow( kWinName1, CV_WINDOW_AUTOSIZE);
     cv::namedWindow( kWinName2, CV_WINDOW_NORMAL);
     initVideoStream(cap);

     int slider_value = 100;
     cv::createTrackbar( "Threshold", "Exercise 1 - Thresholded Image", &slider_value, 255, trackbarHandler, &slider_value);

     Mat img_bgr;
     cv::Mat img_gray;
     cv::Mat img_filtered;

     while (1) {

         cap >> img_bgr;

         if(img_bgr.empty()){
             printf("Could not query frame. Trying to reinitialize.\n");
             initVideoStream(cap);
             cv::waitKey(1000); /// Wait for one sec.
             continue;
         }
         cv::cvtColor( img_bgr, img_gray, CV_BGR2GRAY );

         //threshold( img_gray, img_filtered, slider_value, 255, CV_THRESH_BINARY);
        adaptiveThreshold(img_gray, img_filtered, 255, CV_ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY, 33, 8);

         cv::imshow(kWinName1, img_bgr);
         cv::imshow(kWinName2, img_filtered);

         char key = (char) cv::waitKey (0);
         if (key == 27) break;
     }

     cv::destroyWindow (kWinName1);
     cv::destroyWindow (kWinName2);
     std::cout << "Finished\n";
 }



Error Output:
    /usr/local/clion-2016.1.3/bin/cmake/bin/cmake
--build /home/sose16cpp/.CLion2016.1/system/cmake/generated/augmented_1-aa43292c/aa43292c/Debug
--target augmented_1 -- -j 4
    Scanning dependencies of target augmented_1
    [ 50%] Building CXX object CMakeFiles/augmented_1.dir/main.cpp.o
    /home/sose16cpp/ClionProjects/augmented_1/main.cpp: In function ‘int main(int, const char**)’:
    /home/sose16cpp/ClionProjects/augmented_1/main.cpp:40:12: error: ‘class cv::CommandLineParser’ has no member named ‘about’
         parser.about("Chapter 2. v1.0.0");
                ^
    In file included from /usr/local/include/opencv2/opencv.hpp:49:0,
                     from /home/sose16cpp/ClionProjects/augmented_1/main.cpp:3:
    /usr/local/include/opencv2/core/core.hpp:4807:10: error: ‘bool cv::CommandLineParser::has(const string&)’ is protected
         bool has(const std::string& keys);
              ^
    /home/sose16cpp/ClionProjects/augmented_1/main.cpp:42:26: error: within this context
         if (parser.has("help"))
                              ^
    /home/sose16cpp/ClionProjects/augmented_1/main.cpp:44:16: error: ‘class cv::CommandLineParser’ has no member named ‘printMessage’
             parser.printMessage();
                    ^
    /home/sose16cpp/ClionProjects/augmented_1/main.cpp:49:17: error: ‘class cv::CommandLineParser’ has no member named ‘check’
         if (!parser.check())
                     ^
    /home/sose16cpp/ClionProjects/augmented_1/main.cpp:51:16: error: ‘class cv::CommandLineParser’ has no member named ‘printErrors’
             parser.printErrors();
                    ^

Every thing works fine except for: CommandLineParser has no member named ‘about’,print message,has,check

        #include <iostream>
        #include <opencv2/opencv.hpp>
        #include <opencv2/core/core.hpp>
        #include <opencv/cv.h> /// include most of core headers
        #include <opencv/highgui.h> // include GUI-related headers

        using namespace cv;
        using namespace std;


        // OpenCV command line parser functions
        // Keys accecpted by command line parser

        const char* keys =
                {
                        "{help h usage ? | | print this message}"
                                "{@video | | Video file, if not defined try to use webcamera}"
                };
        int main(int ac, const char** av)
        {

            CommandLineParser parser(ac,av,keys);
            parser.about("Chapter 2. v1.0.0");
            //If requires help show
            if (parser.has("help"))
            {
                parser.printMessage();
                return 0;
            }
            String videoFile= parser.get<String>(0);
        // Check if params are correctly parsed in his variables
            if (!parser.check())
            {
                parser.printErrors();
                return 0;
            }
            cv::VideoCapture cap;
            const std::string kWinName1 = "Exercise 1 - Original Image";
            const std::string kWinName2 = "Exercise 1 - Thresholded Image";

            std::cout << "Startup (Press ESC to quit)" << std::endl;
            namedWindow( kWinName1, CV_WINDOW_AUTOSIZE);
            cv::namedWindow( kWinName2, CV_WINDOW_NORMAL);
            initVideoStream(cap);

            int slider_value = 100;
            cv::createTrackbar( "Threshold", "Exercise 1 - Thresholded Image", &slider_value, 255, trackbarHandler, &slider_value);

            Mat img_bgr;
            cv::Mat img_gray;
            cv::Mat img_filtered;

            while (1) {

                cap >> img_bgr;

                if(img_bgr.empty()){
                    printf("Could not query frame. Trying to reinitialize.\n");
                    initVideoStream(cap);
                    cv::waitKey(1000); /// Wait for one sec.
                    continue;
                }
                cv::cvtColor( img_bgr, img_gray, CV_BGR2GRAY );

                //threshold( img_gray, img_filtered, slider_value, 255, CV_THRESH_BINARY);
               adaptiveThreshold(img_gray, img_filtered, 255, CV_ADAPTIVE_THRESH_MEAN_C, CV_THRESH_BINARY, 33, 8);

                cv::imshow(kWinName1, img_bgr);
                cv::imshow(kWinName2, img_filtered);

                char key = (char) cv::waitKey (0);
                if (key == 27) break;
            }

            cv::destroyWindow (kWinName1);
            cv::destroyWindow (kWinName2);
            std::cout << "Finished\n";
        }



Error Output:
    /usr/local/clion-2016.1.3/bin/cmake/bin/cmake
--build /home/sose16cpp/.CLion2016.1/system/cmake/generated/augmented_1-aa43292c/aa43292c/Debug
/home/mh/.CLion2016.1/system/cmake/generated/augmented_1-aa43292c/aa43292c/Debug
--target augmented_1 -- -j 4
    Scanning dependencies of target augmented_1
    [ 50%] Building CXX object CMakeFiles/augmented_1.dir/main.cpp.o
    /home/sose16cpp/ClionProjects/augmented_1/main.cpp: /home/mh/ClionProjects/augmented_1/main.cpp: In function ‘int main(int, const char**)’:
    /home/sose16cpp/ClionProjects/augmented_1/main.cpp:40:12: /home/mh/ClionProjects/augmented_1/main.cpp:40:12: error: ‘class cv::CommandLineParser’ has no member named ‘about’
         parser.about("Chapter 2. v1.0.0");
                ^
    In file included from /usr/local/include/opencv2/opencv.hpp:49:0,
                     from /home/sose16cpp/ClionProjects/augmented_1/main.cpp:3:
/home/mh/ClionProjects/augmented_1/main.cpp:3:
    /usr/local/include/opencv2/core/core.hpp:4807:10: error: ‘bool cv::CommandLineParser::has(const string&)’ is protected
         bool has(const std::string& keys);
              ^
    /home/sose16cpp/ClionProjects/augmented_1/main.cpp:42:26: /home/mh/ClionProjects/augmented_1/main.cpp:42:26: error: within this context
         if (parser.has("help"))
                              ^
    /home/sose16cpp/ClionProjects/augmented_1/main.cpp:44:16: /home/mh/ClionProjects/augmented_1/main.cpp:44:16: error: ‘class cv::CommandLineParser’ has no member named ‘printMessage’
             parser.printMessage();
                    ^
    /home/sose16cpp/ClionProjects/augmented_1/main.cpp:49:17: /home/mh/ClionProjects/augmented_1/main.cpp:49:17: error: ‘class cv::CommandLineParser’ has no member named ‘check’
         if (!parser.check())
                     ^
    /home/sose16cpp/ClionProjects/augmented_1/main.cpp:51:16: /home/mh/ClionProjects/augmented_1/main.cpp:51:16: error: ‘class cv::CommandLineParser’ has no member named ‘printErrors’
             parser.printErrors();
                    ^