3

次のコードは、OpenCVのカメラキャリブレーションプログラムの一部です。しかし、プログラムを実行するとエラーが発生します。

構成ファイルを開くことができませんでした

構成ファイルを配置しましたc:/Nn/default.xmlが、それでもこのエラーが発生します

コードの何が問題になっているのか教えていただけますか?ファイルを間違ったパスに配置しましたか?

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;
4

4 に答える 4

1

私は Ujjwal に同意します。\opencv\build\x86\vc10\lib フォルダーの下のリンカーに *.lib と *d.lib ファイルの両方を含めたため、同じ問題が発生していました。

VS2010 でデバッグ モードでコンパイルしている場合は、リンカーの「opencv\build\x86\vc10\lib」の下にある d で終わるファイルのみを含めると、問題が解決するはずです。リリース モードでコンパイルする場合は、末尾が d でない .lib ファイルのみを含めます。

また、「windoze」を使用しているため、入力ファイルを「c:/Nn/default.xml」から「c:\\Nn\\default.xml」に変更することをお勧めします。

于 2014-02-05T04:18:07.350 に答える
0

私は同じ問題に直面していました.しかし、私はそれを働かせましたF:\default.xml

試してみる。

于 2015-11-27T11:15:27.993 に答える
-1

リンカー入力セクションで正しい.libファイルを指定していることを確認してください(Visual Studio 2010を使用していると仮定します)。デバッグモードの場合は----d.libファイルを使用し、リリースモードの場合は----。libファイルを使用します。私は同じ問題を抱えていました。これが私がそれを解決した方法です。

于 2013-02-08T10:11:32.840 に答える
-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.

于 2012-05-15T16:10:44.673 に答える