3

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

Could not open the configuration file

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

Can you help me what is the wrong of the code? Did I place 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;
Mat
  • 202,337
  • 40
  • 393
  • 406
Nim4eng
  • 79
  • 1
  • 7

4 Answers4

1

I agree with Ujjwal, I was having the same issue because I included both the *.lib and *d.lib files in the linker under the folder \opencv\build\x86\vc10\lib.

If you are compiling in VS2010 in debug mode, only include the files ending in d under 'opencv\build\x86\vc10\lib' in your linker and it should fix the problem. If you are compiling in release mode only include the .lib files not ending in d.

Also, since you are using 'windoze' I would suggest changing your input file from "c:/Nn/default.xml" to "c:\\Nn\\default.xml".

ALM865
  • 1,078
  • 13
  • 21
0

I was facing the same problem.But I got it working by F:\default.xml

Give it a try.

Robert
  • 5,278
  • 43
  • 65
  • 115
Sagar
  • 416
  • 7
  • 23
-1

There is no standard solution. To start with, there are two types of configuration files: those supplied by the user to configure your program the way he likes (colors, etc.), and those that you use internally to avoid having to recompile and redeliver a new binary anytime some small external factor changes. The first are traditionally under $HOME under Unix, in a single file or a directory whose name starts with a .; under Windows, I think that they're usually under c:\DocumentsĀ andĀ Settings\username\ApplicationData\appliname. For the internal configuration data, under Unix, I is a general convention that the user set an environment variable which specifies a root; your executables are in a bin directory under this, and any configuration data in an etc directory. (There's no reliable way under Unix of knowing from where you were loaded.) Under Windows, the configuration data goes in the same directory as the executable, and the program uses GetModuleFileName to find this.

James Kanze
  • 150,581
  • 18
  • 184
  • 329
-1

just check that you are specifying correct .lib files in the linker input section( assuming that you are using visual studio 2010 ). for debug mode use ----d.lib files and for release mode use ----.lib files. I was having the same problem this is how I resolved it.

Ujjwal
  • 426
  • 1
  • 5
  • 16