Open-PupilEXT icon indicating copy to clipboard operation
Open-PupilEXT copied to clipboard

Stereo calibration file cannot be saved on windows if whitespace in path

Open BZandi opened this issue 2 years ago • 3 comments

If the user name of the working system has a space, saving the log files does not work. A current workaround is to save the log file directly on the hard disk like 'c:/' or similar.

The source of the issue and workaround was mentioned in this post https://github.com/openPupil/Open-PupilEXT/discussions/6

BZandi avatar Jan 22 '23 13:01 BZandi

Hi Babak,

from what i see one could use the QT function QDir::toNativeSeparators to normalize the path with whitespaces. This would probably solve this issue as well as #6 (the replace could be removed). Does this issue also occur for saving images in a path with whitespaces? For writing images, the path is initialized using QDir(...), which probably implicitly applies toNativeSeparators so thats maybe the reason it doesn't happen there.

I could write a short pull request for this, but wouldn't be able to test the code myself as i don't have the building system setup.

Best regards

lodemo avatar Jan 22 '23 22:01 lodemo

Dear Moritz, thanks for the suggestion! Sorry, I have just realised that I made a mistake in the title of the issue. Saving the log files should be fine but I will check to be sure. The issue is related to saving the stereo calibration file on windows as discussed here https://github.com/openPupil/Open-PupilEXT/discussions/6. I will change the title of this issue.

I will check by the end of the week whether saving log files or images is also affected if there is a space in the path.

BZandi avatar Jan 23 '23 18:01 BZandi

Hi Moritz, saving images as well as logs with a whitespace in path works fine. I tested it in both, single and stereo camera mode on windows.

Saving the calib file in stereo mode does not work with a whitespace in path. However, saving the calib file in single camera mode works fine. This should be related to filename.replace(" ", "");in line 232 of /src/subwindows/stereoCameraCalibrationView.cpp

void StereoCameraCalibrationView::onSaveClick() {
    QString filename = QFileDialog::getSaveFileName(this, tr("Save Calibration File"), "", tr("XML files (*.xml)"));

    if(!filename.isEmpty()) {
        filename.replace(" ", "");

        QFileInfo fileInfo(filename);
        // check if filename has extension, else append xml to it
        if(fileInfo.suffix().isEmpty()) {
            filename = filename + ".xml";
        }

        std::cout<<"Saving calibration file to settings directory: "<< filename.toStdString() <<std::endl;
        calibrationWorker->saveToFile(filename.toStdString().c_str());
    }
}

Do you want to write a short pull request for that issue?

BZandi avatar Jan 27 '23 09:01 BZandi