Ask Your Question
0

getting out of arguments

asked 2020-12-07 04:45:45 -0500

nico50 gravatar image

The problem i'm trying to build something around the openvc advanced stitching solver. (the lower level API).
However that asumes all is given in command line arguments, this is not practical for me. Is there a way to provide inline code to add an image series ?
So without using command line arguments, I need this essentially for all arguments.

be able to do in psudo code
args.images = "c:\img\plan1 c:\imgplan2 c:\imgplan3"

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
1

answered 2020-12-07 08:03:52 -0500

kbarni gravatar image

Another solution that I often use is to create a text file containing the image names and pass that filename as argument.

The text file can be created with ls *.jpg > process.txt (or dir *.jpg > process.txt in Windows).

Then read the file line by line:

ifstream myfile(argv[1]);
while(!myfile.eof()){
    getline(myfile,imagefilename);
    cv::imread(img,imagefilename);
    //...process img...
}
myfile.close();
edit flag offensive delete link more
1

answered 2020-12-07 05:49:35 -0500

berak gravatar image

updated 2020-12-07 05:53:46 -0500

those samples are not "written in stone", you're allowed (and even encouraged !) to hack them to fit your needs ;)

see, the only thing required here is that you fill the vector<String> img_names; list from the argument parsing, so maybe you can make good use of cv::glob() and (assuming, your image names can be nicely sorted lexicographically), add a case like:

    else if (string(argv[i]) == "--folder")
    {
        string folder = argv[i+1];
        i++;
        cv::glob(folder, img_names); // read folder content into img_names
    }

to the cmdline parsing.

note: you probably need images numbered like: img007 (leading zeros), else img10 comes after img1 and before img2 !

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-12-07 04:45:45 -0500

Seen: 111 times

Last updated: Dec 07 '20