I have been struggling for a while by the failure to open file using FileStorage: It is part of the code from: \opencv\sources\samples\cpp\tutorial_code\calib3d\camera_calibration\camera_calibration.cpp:
FileStorage fs(inputSettingsFile, FileStorage::READ); // Read the settings
if (!fs.isOpened())
{
cout << "Could not open the configuration file: \"" << inputSettingsFile << "\"" << endl;
return -1;
}
It always failed. Tried absolute path also, still fails. Environment: Opencv version: 2.4.8, windows 7 (32-bit) and Visual Studio 2010. (Actually, tried 2.4.2 and VS2008, same problem) Anything I am missing?
To verify permission, added regular cpp file read before FileStorage. the regular cpp file read works fine:
int main()
{
////Use two ways to open and read the file "in_VID5.xml"
string inputSettingsFile = "in_VID5.xml";
//// Method 1: cpp read file - ok
ifstream myfile(inputSettingsFile);
string line;
if(myfile.is_open())
{
while (getline(myfile, line))
{
////It does come here
cout << line <<'\n';
}
myfile.close();
}
Sleep(1000);
////Method 2: opencv read file - fails
FileStorage fs(inputSettingsFile, FileStorage::READ); // Read the settings
if (!fs.isOpened())
{
////It fails
cout << "Could not open the configuration file: \"" << inputSettingsFile << "\"" << endl;
return -1;
}
return 0;
}
".xml"
,".yml"
or".yaml"
? Please select theedit
button on your post and respond to us. I take it that you don't have enough reputation to comment yet. - David G