summaryrefslogtreecommitdiff
path: root/src/caffe/util/io.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/caffe/util/io.cpp')
-rw-r--r--src/caffe/util/io.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/caffe/util/io.cpp b/src/caffe/util/io.cpp
index 6f033142..f2b1dd98 100644
--- a/src/caffe/util/io.cpp
+++ b/src/caffe/util/io.cpp
@@ -3,9 +3,11 @@
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/text_format.h>
#include <opencv2/core/core.hpp>
+#ifdef USE_OPENCV
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/highgui/highgui_c.h>
#include <opencv2/imgproc/imgproc.hpp>
+#endif // USE_OPENCV
#include <stdint.h>
#include <algorithm>
@@ -67,6 +69,7 @@ void WriteProtoToBinaryFile(const Message& proto, const char* filename) {
CHECK(proto.SerializeToOstream(&output));
}
+#ifdef USE_OPENCV
cv::Mat ReadImageToCVMat(const string& filename,
const int height, const int width, const bool is_color) {
cv::Mat cv_img;
@@ -98,6 +101,7 @@ cv::Mat ReadImageToCVMat(const string& filename,
cv::Mat ReadImageToCVMat(const string& filename) {
return ReadImageToCVMat(filename, 0, 0, true);
}
+
// Do the file extension and encoding match?
static bool matchExt(const std::string & fn,
std::string en) {
@@ -111,6 +115,7 @@ static bool matchExt(const std::string & fn,
return true;
return false;
}
+
bool ReadImageToDatum(const string& filename, const int label,
const int height, const int width, const bool is_color,
const std::string & encoding, Datum* datum) {
@@ -135,6 +140,7 @@ bool ReadImageToDatum(const string& filename, const int label,
return false;
}
}
+#endif // USE_OPENCV
bool ReadFileToDatum(const string& filename, const int label,
Datum* datum) {
@@ -156,6 +162,7 @@ bool ReadFileToDatum(const string& filename, const int label,
}
}
+#ifdef USE_OPENCV
cv::Mat DecodeDatumToCVMatNative(const Datum& datum) {
cv::Mat cv_img;
CHECK(datum.encoded()) << "Datum not encoded";
@@ -227,6 +234,5 @@ void CVMatToDatum(const cv::Mat& cv_img, Datum* datum) {
}
datum->set_data(buffer);
}
-
-
+#endif // USE_OPENCV
} // namespace caffe