0
    for(directory_iterator i(l_path),end_iter; i != end_iter; i++){
    string im_name = filename;
    //string im_name = i->path().filename().string();
    string l_filename = l_path + im_name;
    im_name.replace(im_name.begin(),im_name.begin() + 4, string("right"));
    string r_filename = r_path + im_name;
    Mat lim = imread(l_filename),rim = imread(r_filename);
    if(!lim.empty() && !rim.empty()){
        l_images.push_back(lim);
        r_images.push_back(rim);
    }

}

The above crashes on start up and yes the path is there but for some reason it won't run. I have tried this with out the path and it runs. I have no idea what is going wrong. Thanks for any help you can give. below is where i declare it. I am using the latest build of boost and qt creator with open cv to get disparity images for stereo vision, this is what i am using to make the xml file for calibration.

filename = DISTFOLDER + string("stereo_calib.xml");

calib = new calibrator(LEFTFOLDER,RIGHTFOLDER,1.f,5,4,"lImage.png");
calib->calc_image_points(true);
bool done = calib->calibrate();

if(!done){
    qDebug("stereo calibration failed");
}
calib->save_info(filename);
tengence
  • 61
  • 9
  • I wonder why don't you use `boost::filesystem::path` for paths, but that's another question... – mike.dld Feb 27 '14 at 06:56
  • Please elaborate how/where exactly does it crash. The issue is more for you to debug than for us to guess. Also, I'm not sure which line of the second listing actually calls the code in the first one. – mike.dld Feb 27 '14 at 06:59
  • Sorry for not elaborating, basically what happens is that the program crashes before it gets to iterate through the file path. I know the path is there i just don't know why it isn't finding it – tengence Feb 27 '14 at 07:41
  • how would i change the code to work with the path ,sorry i am new to using boost – tengence Feb 27 '14 at 07:43
  • If it doesn't exactly "crash" but terminate because of unhandled exception, you have two options: 1) set a breakpoint on `std::exception` constructor; 2) wrap your code with `try`/`catch`. – mike.dld Feb 27 '14 at 09:11

1 Answers1

0

Even with try{... }catch blocks it still crashes in QT, I don't know what I changed in my code or the QT environment since it used to work.

Note that when running the app from QT Creator run console it crushes, but running the app directly either from cmd or via explorer works just fine.

The Problem I believe is within QT environment variables being messed up.

The only solution is to append QCoreApplication::applicationDirPath ().toStdString() to the boost::filesystem::directory_iterator iterator(string("tools/adb/"));and make sure the string is what boost expects for path strings.

The try catch block outputs

is_directory failed with The system cannot find the path specified

Here is my current code:

try {
    boost::filesystem::directory_iterator iterator(string("tools/adb/"));

    for(; iterator != boost::filesystem::directory_iterator(); ++iterator) {
        if(is_directory(iterator->path())) { 
            cout << (iterator->path()) << endl;

            adb_s str;
            str.path=iterator->path().string();
            boost::replace_all(str.path, "/", "\\");
            str.path+="\\";
            adb_path.push_back(str);
        }
    }
} catch(const boost::filesystem::filesystem_error& e) {
    if(e.code() == boost::system::errc::permission_denied) { 
        std::cout << "Search permission is denied for one of the directories ";
        std::cout << "in the path prefix of \n";
    } else {
        std::cout << "is_directory failed with ";
        std::cout << e.code().message() << '\n';
    }
}
Remi Guan
  • 21,506
  • 17
  • 64
  • 87
Storm
  • 1
  • 2