初始化Darknet OpenCV

时间:2019-04-06 19:32:33

标签: c++ opencv4

尝试初始化暗网时出现此错误。

  

错误:cv :: dnn :: darknet :: ReadDarknetFromCfgStream中的断言失败(separator_index

有人知道会发生什么吗?

我正在使用yolov3.weightsyolov3.cfg

下面的代码。

我尝试了绝对文件路径

// Load names of classes
string classesFile = "B:/coco.names";
ifstream ifs(classesFile.c_str());
string line;
while (getline(ifs, line)) classes.push_back(line);

// Give the configuration and weight files for the model
String modelConfiguration = "B:/yolov3a.cfg";
String modelWeights = "B:/yolov3.weights";

// Load the network
Net net = readNetFromDarknet(modelConfiguration, modelWeights);
net.setPreferableBackend(DNN_BACKEND_OPENCV);
net.setPreferableTarget(DNN_TARGET_CPU);


//---------------

return 0;

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

如果.cfg文件中的'#'之后紧紧有空白行的注释行,则darknet_io.cpp中的行解析器似乎失败。

[net]
# This is OK!
# Testing
# batch=1
# subdivisions=1
# Training
batch=64
subdivisions=16
width=416
height=416
...

[net]
#This would FAIL!
#batch=1
#subdivisions=1
#Training
batch=64
...