我正在使用 opencv 读取和写入我的应用程序配置文件。 我有一个要存储在那里的 bool 值。它保存为一个整数:
camera: auto_gain: 1
我尝试通过以下方式阅读它:
auto_gain=static_cast<bool>(static_cast<int>(camera["auto_gain"]));
但我收到警告:
warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
在那种情况下解析 bool 的正确方法是什么?
最佳答案
如 this question 中所述,你应该使用:
auto_gain = static_cast<int>(camera["auto_gain"]) != 0;
关于c++ - OpenCV YAML 解析 bool ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13951179/