caffe之SSD算法词袋解析
2017-07-27 00:20
211 查看
text解析接口函数:
https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.text_format
代码如下:
makefile文件如下:
https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.text_format
代码如下:
#include "caffe/proto/caffe.pb.h" #include <caffe/caffe.hpp> #include <iostream> #include <fstream> #include <string> #include <fcntl.h> #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/text_format.h> using namespace caffe; using namespace std; int main(int argc, char const *argv[]){ LabelMap labelmap; int fd = open(argv[1], O_RDONLY | 0); CHECK_NE(fd, -1) << "File not found: " << argv[1]; google::protobuf::io::FileInputStream fileInput(fd); fileInput.SetCloseOnDelete( true ); bool success = google::protobuf::TextFormat::Merge(&fileInput,&labelmap); for(int i = 0; i < labelmap.item_size(); i++) { const LabelMapItem& vociterm = labelmap.item(i); cout<< "Name:"<< vociterm.name() << endl; cout<<"label:"<< vociterm.label() << endl; cout<<"display_name:"<<vociterm.display_name()<< endl; } close(fd); return success; }
makefile文件如下:
CAFFEROOT=../../deeplearning/ssd/caffe CAFFEINC=-I$(CAFFEROOT)/include\ -I$(CAFFEROOT)/build/src\ -I/usr/local/Cellar/openblas/0.2.19_1/include\ -I./include CAFFELIB=-L$(CAFFEROOT)/build/lib\ -L/usr/local/lib\ -lcaffe -lglog -lboost_system -lgflags -lprotobuf CAFFEFLAGS=-D CPU_ONLY OPENCVINC=$(shell pkg-config opencv --cflags) OPENCVLIBS=$(shell pkg-config opencv --libs) SRC=parse_caffe_itermap.cpp all: g++ -o parse_voc $(SRC) $(CAFFEFLAGS) $(CAFFELIB) $(CAFFEINC) $(OPENCVINC) $(OPENCVLIBS) clean: rm -rf parse_voc
相关文章推荐
- SSD(single shot multibox detector)算法及Caffe代码详解
- SSD算法及Caffe代码详解(最详细版本)
- SSD(Single Shot Multibox Detector)算法及Caffe代码详解
- SSD(single shot multibox detector)算法及Caffe代码详解
- SSD(single shot multibox detector)算法及Caffe代码详解
- SSD(single shot multibox detector)算法及Caffe代码详解
- SSD(single shot multibox detector)算法及Caffe代码详解[转]
- caffe中solver优化代码解析1
- MP4文件格式的解析,以及MP4文件的分割算法
- Caffe命令行解析及log日志文件生成
- caffe之python接口实战 :brewing-logreg 官方教程源码解析
- 从头到尾彻底解析Hash 表算法
- C语言找出数组中的特定元素的算法解析
- 算法一 (3个著名加密算法(MD5、RSA、DES)的解析)
- 数据结构知识——树的三种不同遍历算法解析
- Ubuntu16.04+caffe-ssd+cuda8.0+cudnn5.1
- MXNet框架的SSD算法代码介绍(一):train.py
- 图的DFS和BFS算法解析
- Caffe源码解析caffe.cpp