Skip to content

Build DNN without Protobuf#23604

Merged
asmorkalov merged 2 commits intoopencv:4.xfrom
dkurt:dnn_no_protobuf
May 15, 2023
Merged

Build DNN without Protobuf#23604
asmorkalov merged 2 commits intoopencv:4.xfrom
dkurt:dnn_no_protobuf

Conversation

@dkurt
Copy link
Copy Markdown
Member

@dkurt dkurt commented May 11, 2023

Pull Request Readiness Checklist

DNN module can be built without Protobuf for Darknet, TFLite, OpenVINO, Torch (not PyTorch) models.

cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_LIST=dnn \
    -DWITH_PROTOBUF=OFF \
    -DWITH_OPENCL=OFF

7.1M    lib/libopencv_dnn.so.4.7.0
cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_LIST=dnn \
    -DWITH_OPENCL=OFF

3.9M    lib/libopencv_dnn.so.4.7.0

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@asmorkalov
Copy link
Copy Markdown
Contributor

@dkurt Thanks a lot for the PR! I tried it with my Ubuntu 18.04 and faced build issue:

cmake: cmake -DWITH_PROTOBUF=OFF ../opencv-master

build error:

[ 82%] Building CXX object modules/gapi/CMakeFiles/opencv_gapi.dir/src/api/gcomputation.cpp.o
CMakeFiles/opencv_java.dir/__/generator/src/cpp/opencv_java.cpp.o: In function `Java_org_opencv_dnn_Dnn_writeTextGraph_10':
opencv_java.cpp:(.text.Java_org_opencv_dnn_Dnn_writeTextGraph_10+0x11c): undefined reference to `cv::dnn::dnn4_v20221220::writeTextGraph(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
modules/java/jni/CMakeFiles/opencv_java.dir/build.make:239: recipe for target 'lib/libopencv_java470.so' failed
make[2]: *** [lib/libopencv_java470.so] Error 1
CMakeFiles/Makefile2:3340: recipe for target 'modules/java/jni/CMakeFiles/opencv_java.dir/all' failed
make[1]: *** [modules/java/jni/CMakeFiles/opencv_java.dir/all] Error 2

@dkurt
Copy link
Copy Markdown
Member Author

dkurt commented May 15, 2023

@asmorkalov, sure, thanks! Forgot to try with Java.

@asmorkalov asmorkalov merged commit a8d3d1f into opencv:4.x May 15, 2023
@asmorkalov
Copy link
Copy Markdown
Contributor

@dkurt It'll be great to disable Caffe, TF and ONNX tests, if protobuf is disabled. It may be yet another PR.

@dkurt dkurt deleted the dnn_no_protobuf branch May 15, 2023 10:01
@asmorkalov asmorkalov mentioned this pull request May 31, 2023
thewoz pushed a commit to thewoz/opencv that referenced this pull request Jan 4, 2024
Build DNN without Protobuf

DNN module can be built without Protobuf for Darknet, TFLite, OpenVINO, Torch (not PyTorch) models.

```
cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_LIST=dnn \
    -DWITH_PROTOBUF=OFF \
    -DWITH_OPENCL=OFF

7.1M    lib/libopencv_dnn.so.4.7.0
```


```
cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_LIST=dnn \
    -DWITH_OPENCL=OFF

3.9M    lib/libopencv_dnn.so.4.7.0
```

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
thewoz pushed a commit to thewoz/opencv that referenced this pull request May 29, 2024
Build DNN without Protobuf

DNN module can be built without Protobuf for Darknet, TFLite, OpenVINO, Torch (not PyTorch) models.

```
cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_LIST=dnn \
    -DWITH_PROTOBUF=OFF \
    -DWITH_OPENCL=OFF

7.1M    lib/libopencv_dnn.so.4.7.0
```


```
cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_LIST=dnn \
    -DWITH_OPENCL=OFF

3.9M    lib/libopencv_dnn.so.4.7.0
```

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
@jinboson
Copy link
Copy Markdown
Contributor

@dkurt It'll be great to disable Caffe, TF and ONNX tests, if protobuf is disabled. It may be yet another PR.

Is there a patch to disable the related tests ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants