dnn: allow to use external protobuf
authorAlexander Alekhin <alexander.alekhin@intel.com>
Mon, 9 Jul 2018 14:19:35 +0000 (17:19 +0300)
committerAlexander Alekhin <alexander.alekhin@intel.com>
Mon, 9 Jul 2018 14:28:45 +0000 (17:28 +0300)
"custom layers" feature will not work properly in these builds.

modules/dnn/CMakeLists.txt
modules/dnn/src/caffe/caffe_io.cpp
modules/dnn/test/test_layers.cpp

index e306dde..a2f741c 100644 (file)
@@ -48,6 +48,10 @@ if(ANDROID)
   add_definitions(-DDISABLE_POSIX_MEMALIGN -DTH_DISABLE_HEAP_TRACKING)
 endif()
 
+if(NOT BUILD_PROTOBUF)
+  add_definitions(-DOPENCV_DNN_EXTERNAL_PROTOBUF=1)
+endif()
+
 add_definitions(-DHAVE_PROTOBUF=1)
 
 #suppress warnings in autogenerated caffe.pb.* files
index 730c752..9f4e31c 100644 (file)
@@ -1120,7 +1120,11 @@ bool ReadProtoFromTextFile(const char* filename, Message* proto) {
     std::ifstream fs(filename, std::ifstream::in);
     CHECK(fs.is_open()) << "Can't open \"" << filename << "\"";
     IstreamInputStream input(&fs);
+#ifndef OPENCV_DNN_EXTERNAL_PROTOBUF
     return google::protobuf::TextFormat::Parser(true).Parse(&input, proto);
+#else
+    return google::protobuf::TextFormat::Parser().Parse(&input, proto);
+#endif
 }
 
 bool ReadProtoFromBinaryFile(const char* filename, Message* proto) {
index 3d20df5..1a6aad0 100644 (file)
@@ -1149,7 +1149,11 @@ private:
     int outWidth, outHeight, zoomFactor;
 };
 
+#ifndef OPENCV_DNN_EXTERNAL_PROTOBUF
 TEST_P(Test_Caffe_layers, Interp)
+#else
+TEST_P(Test_Caffe_layers, DISABLED_Interp)  // requires patched protobuf (available in OpenCV source tree only)
+#endif
 {
     if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
         throw SkipTestException("");