我正在使用opencv提供的the code进行相机校准。 我已经编辑的设置文件,包含我自己的目录,它看起来像这样:Opencv,读取XML文件进行相机校准时出错
<?xml version="1.0"?>
<opencv_storage>
<images>
"20170720_024951.jpg"
"20170720_025001.jpg"
"20170720_025014.jpg"
"20170720_025023.jpg"
"20170720_025034.jpg"
"20170720_025048.jpg"
"20170720_025103.jpg"
"20170720_025115.jpg"
"20170720_025124.jpg"
"20170720_025133.jpg"
"20170720_025147.jpg"
"20170720_025155.jpg"
"20170720_025211.jpg"
</images>
我提供完整的图像路径,但得到这个错误:
Invalid input detected. Application stopping.
这里是部分代码在其中,我发现了错误:
Settings s;
const string inputSettingsFile = "C:/Users/user/Documents/Visual Studio 2013/Projects/calibration/x.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
//! [file_read]
//FileStorage fout("settings.yml", FileStorage::WRITE); // write config as YAML
//fout << "Settings" << s;
if (!s.goodInput)
{
cout << "Invalid input detected. Application stopping. " << endl;
return -1;
}
由oencv提供的原始文件在属性(图像的路径)周围不包含“”,所以我试图首先将图像的路径插入XML文件而不使用使用双引号“path/image .JPG” - >路径/图像,但下列异常发生:
OpenCV Error: Parsing error (C:/Users/user/Documents/Visual Studio 2013/Projects/calebration/x.xml(1): Attribute value should be put into single or double quotes) in icvXMLParseTag, file C:\builds\master_PackSlave-win64-vc12-shared\opencv\modules\core\src\persistence.cpp, line 2157
,加入后‘’被人所建议的,异常消失,但仍停留在第一个错误(这是在告诉我假设 xml文件的格式不正确)
你试过使用反斜杠\而不是斜杠/ ??不知道这是在XML的情况下,但你可能需要转义反斜杠 – api55
非常感谢你,我已经尝试了\和/但还有其他问题,解决了我的答案在下面! –