#include <opencv2/opencv.hpp>
#include <iostream>
#include <Vector>
using namespace std;
using namespace cv;
using namespace cv::dnn;
int main()
{
system("color F0");
string model = "bvlc_googlenet.caffemodel";
string config = "bvlc_googlenet.prototxt";
// + model
Net net = dnn::readNet(model, config);
if (net.empty())
{
cout << "请确认是否输入空的模型文件" << endl;
return -1;
}
//获取各层信息
vector<String>layerNames = net.getLayerNames();
for (int i = 0; i < layerNames.size(); i++)
{
//read net ID
int ID = net.getLayerId(layerNames[i]);
//read net ID informations
Ptr<Layer>layer = net.getLayer(ID);
// output net informations
cout << "网络层数" << ID << " 网络层数" << layerNames[i] << endl << "网络层类型" << layer->type.c_str() << endl;
}
return 0;
}
|