Ask Your Question
0

parser.has() alway retruning true

asked 2016-06-03 07:45:34 -0500

Florence gravatar image

Hello,

I´m trying to use CommandLineParser and I have a problem : even if I don´t put anything when I lauch the program (only ./prog ), the function parser.has returns true, as if something was given on the command line.

If someone has an idea of what I am doing wrong, it would be very helpful !

Thanks :)

Here is the code :

const char* keys =
    {
        "{help          |                   | show help message }"
        "{type          |                   | type of the camera}"
        "{camera_number |                   | camera number     }"
    };


int main(int argc, char* argv[])
{

        CommandLineParser parser(argc, argv, keys);

        bool t = parser.has("type");
        cout << " t = " << t << endl;

        bool cm = parser.has("camera_number"); 
        cout << "cm = " << cm << endl; 

        return 0;
}
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2016-06-05 09:24:54 -0500

I tried to reproduce this issue on OpenCV 3.1+Windows 10.
But, I could not reproduce this issue.

So, could you please tell us information of your environment(Platform, Compiler, OpenCV version)?
You can get these information from cv::getBuildInformation().

And, this issue might be related to this ticket. https://github.com/Itseez/opencv/issu...

edit flag offensive delete link more

Comments

Hello,

After your answer I tried to rewrite the same programm in a other file, and it worked... I looked in the previous one if there were hidden characters that may have cause a problem, and I couldn´t find anything...

So thanks a lot for your answer, problem solved I guess :)

Florence gravatar imageFlorence ( 2016-06-07 02:31:03 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-06-03 07:45:34 -0500

Seen: 84 times

Last updated: Jun 05 '16