我在调试模式下编译了下面的程序,没有任何错误。我可以从命令行运行 .exe 文件,但是当我尝试在 Visual Studio 中调试代码时,会从该行抛出异常
DetectionInternalSettings* internal_settings =
DetectionInternalSettingsFactory::createFromFileSystem(
"C:/data/card_detection_engine.yaml");
在命令行和调试模式下运行的行为不同之前遇到过这种情况的任何人。
int main(int argc, char **argv)
{
DetectionSettings settings;
try
{
DetectionInternalSettings* internal_settings =
DetectionInternalSettingsFactory::createFromFileSystem("../data/card_detection_engine.yaml");
}
catch (const MyException &e)
{
fprintf(stderr, "Exception raised: %s\n", e.what().c_str());
return 1;
}
return 0;
}
我还进入了异常详细信息,这里是 ocrcarddetectionengine_sample.exe 中 0x76E1C41F 处的第一次机会异常:Microsoft C++ 异常:内存位置 0x003FF0D0 处的 YAML::TypedBadConversion。
更多相关代码createFromFileSystem
DetectionInternalSettingsFactory::createFromFileSystem(const std::string &configPath) throw (MyException)
{
return new DetectionInternalSettingsImpl(configPath);
}
struct DetectionInternalSettingsImpl : public DetectionInternalSettings {
DetectionInternalSettingsImpl(const std::string &config_path) {
if (config.ReadFromFilesystem(config_path)) {
throw MyException("Bad configuration path.");
}
}
~DetectionInternalSettingsImpl() { }
Core::Detector::Configuration config;
};