Where should the configuration file be located?

The following code is part of the camera calibration program in OpenCV. But I get an error when the program starts: it says

Could not open configuration file.

I put the configuration file in c:/Nn/default.xml, but I still get this error

Can you help me what is wrong with the code? Did I put the file in the wrong path?

int main(int argc, char* argv[])
{
help();
Settings s; 
const string inputSettingsFile = argc > 1 ? argv[1] : "c:/Nn/default.xml";
FileStorage fs(inputSettingsFile, FileStorage::READ); // Read the settings
if (!fs.isOpened())
{
    cout << "Could not open the configuration file: \"" << inputSettingsFile << "\"" <<            endl; 
    return -1;
}
fs["Settings"] >> s; 
fs.release();                                         // close Settings file

if (!s.goodInput)
{
    cout << "Invalid input detected. Application stopping. " << endl;
    return -1;
}

vector<vector<Point2f> > imagePoints;
Mat cameraMatrix, distCoeffs;
Size imageSize;
int mode = s.inputType == Settings::IMAGE_LIST ? CAPTURING : DETECTION;
clock_t prevTimestamp = 0;
const Scalar RED(0,0,255), GREEN(0,255,0);
const char ESC_KEY = 27;
+3
source share
4 answers

I agree with Ujjwal, I had the same problem because I included the * .lib and * d.lib files in the linker in the \ opencv \ build \ x86 \ vc10 \ lib folder.

VS2010 , , d ​​ "opencv\build\x86\vc10\lib" , . , .lib, d.

, "windoze", "c:/Nn/default.xml" "c:\\Nn\\default.xml".

+1

. F:\default.xml

.

0

. , : , , ( ..), , , - . $HOME Unix, , .; Windows, , c:\Documents and Settings\username\ApplicationData\appliname. Unix , ; bin , etc. (There is no reliable way under Unix, knowing where you were downloaded from.) On Windows, the configuration data goes in the same directory as the executable, and the program uses GetModuleFileNameit to find it.

-1
source

just make sure that you specify the correct .lib files in the linker input section (assuming you are using visual studio 2010). for debug mode use d.lib files and for use in release mode use lib files. I had the same problem as I solved it.

-1
source

All Articles