加载网络模型与读取各层信息
全部代码
#include<iostream>
#include<opencv2\opencv.hpp>
#include<opencv2\dnn.hpp>
using namespace cv::dnn;
using namespace std;
using namespace cv;
string model = "D:/opencv-4.1.0/models/ssd/MobileNetSSD_deploy.caffemodel";
string cfg = "D:/opencv-4.1.0/models/ssd/MobileNetSSD_deploy.prototxt";
int main() {
Net net;
net= readNetFromCaffe(cfg, model);
vector<string>layer_names = net.getLayerNames();
for (int i = 0; i < layer_names.size(); i++) {
int id = net.getLayerId(layer_names[i]);
auto layer = net.getLayer(id);
printf("layer_id:%d,type:%s,name:%s\n", id, layer->type.c_str(), layer->name.c_str());
}
waitKey(0);
return 0;
}
|