Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mve fails on filenames with spaces #501

Open
linusmartensson opened this issue Feb 27, 2020 · 1 comment
Open

mve fails on filenames with spaces #501

linusmartensson opened this issue Feb 27, 2020 · 1 comment

Comments

@linusmartensson
Copy link

Hi!
I'm running the active version of mve in the ODM docker container.

From this, I have an intermediate nvm file with a set of images generated through ODM wherein the filenames contain spaces.

When mve attempts to load this file, it introduces an error on

in >> nvm_cam.filename;
where the filename is interpreted as ending on the first space, then gobbling up and turning the remainder of the nvm file into garbage.
We can handle this case by some trial and error handling in bundle_io at the above location:

//Gobble up any leading whitespace
in >> std::ws; 

//Read a full line of camera details
std::string camline = std::getline(in, camline);
std::istringstream line(camline);

//Read out parts of the filename until we find an actual file
line >> nvm_cam.filename;
while(!std::ifstream(nvm_cam.filename)) { 
    std::string tmp; 
    line >> tmp; 
    nvm_cam.filename += " " + tmp;
    if(!line) break;
}
if(!line) {
    //We've gobbled up the whole camera line searching for a missing file, so skip it.
    //Since later data may be dependent on the camera ordering however, 
    //we still push the invalid camera and parameter bundle. There may be other ways
    //to handle this.
    nvm_cam.filename = "<invalid camera, file not found: '" + nvm_cam.filename + "'>";
    bundle_cams.push_back(bundle_cam); nvm_cams.push_back(nvm_cam); 
    continue; 
}
//Replace remaining uses of 'in' within the loop with 'line'

With this, mve should be able to handle this weakness in the nvm file format without breaking otherwise correct files nor fail disastrously on missing camera files.

To fully avoid any inconsistencies (given that nvm doesn't have any escape characters), we would have to go one step further and parse a camera line in reverse, extracting each numeric token and then interpreting the remainder as a file name. I think this may be overkill though.

@simonfuhrmann
Copy link
Owner

Thanks for reporting, I will take a closer look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants