diff --git a/src/caffe/util/io.cpp b/src/caffe/util/io.cpp
index d827176a387510c205a1f387872603f8f0436a80..c1f5a962cf42a088d78045b1c5eb10e14aab75df 100644 (file)
--- a/src/caffe/util/io.cpp
+++ b/src/caffe/util/io.cpp
// Copyright 2013 Yangqing Jia
#include <stdint.h>
+#include <fcntl.h>
+#include <google/protobuf/text_format.h>
+#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using cv::Vec3b;
using std::max;
using std::string;
+using google::protobuf::io::FileInputStream;
namespace caffe {
CHECK(cv::imwrite(filename, cv_img));
}
+void ReadProtoFromTextFile(const char* filename,
+ ::google::protobuf::Message* proto) {
+ int fd = open(filename, O_RDONLY);
+ FileInputStream* input = new FileInputStream(fd);
+ CHECK(google::protobuf::TextFormat::Parse(input, proto));
+ delete input;
+ close(fd);
+}
} // namespace caffe