From f0c8a793b55c702950720495730c1cbfbbca4d17 Mon Sep 17 00:00:00 2001 From: Simon Harris Date: Thu, 10 Jan 2019 01:35:48 +1100 Subject: [PATCH 1/2] Support building OpenCV headless If the environment variable HEADLESS=yes then we will build OpenCV without QT, GTK, and WIN32UI. --- opencv/cppbuild.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/opencv/cppbuild.sh b/opencv/cppbuild.sh index 0f52b4ffabc..2f91bda4957 100755 --- a/opencv/cppbuild.sh +++ b/opencv/cppbuild.sh @@ -52,6 +52,11 @@ BUILD_X="-DBUILD_ANDROID_EXAMPLES=OFF -DBUILD_ANDROID_PROJECTS=OFF -DBUILD_TESTS # support for OpenMP is NOT thread-safe so make sure to never enable it and use pthreads instead WITH_X="-DWITH_1394=OFF -DWITH_FFMPEG=OFF -DWITH_GSTREAMER=OFF -DWITH_IPP=OFF -DWITH_LAPACK=OFF -DWITH_OPENCL=ON -DWITH_OPENMP=OFF -DOPENCV_ENABLE_NONFREE=ON" +# support headless +if [[ "$HEADLESS" == "yes" ]]; then + WITH_X="$WITH_X -DWITH_WIN32UI=OFF -DWITH_QT=OFF -DWITH_GTK=OFF" +fi + BUILD_CONTRIB_X="-DBUILD_opencv_stereo=OFF -DBUILD_opencv_plot=ON -DBUILD_opencv_fuzzy=OFF -DBUILD_opencv_aruco=ON -DBUILD_opencv_adas=OFF -DBUILD_opencv_bgsegm=ON -DBUILD_opencv_bioinspired=ON -DBUILD_opencv_ccalib=OFF -DBUILD_opencv_datasets=OFF -DBUILD_opencv_dnn_modern=OFF -DBUILD_opencv_dnn_objdetect=OFF -DBUILD_opencv_freetype=OFF -DBUILD_opencv_dpm=OFF -DBUILD_opencv_face=ON -DBUILD_opencv_hfs=OFF -DBUILD_opencv_latentsvm=OFF -DBUILD_opencv_line_descriptor=OFF -DBUILD_opencv_matlab=OFF -DBUILD_opencv_optflow=ON -DBUILD_opencv_phase_unwrapping=ON -DBUILD_opencv_plot=ON -DBUILD_opencv_reg=OFF -DBUILD_opencv_rgbd=OFF -DBUILD_opencv_saliency=ON -DBUILD_opencv_structured_light=ON -DBUILD_opencv_surface_matching=OFF -DBUILD_opencv_text=ON -DBUILD_opencv_tracking=ON -DBUILD_opencv_xfeatures2d=ON -DBUILD_opencv_ximgproc=ON -DBUILD_opencv_xobjdetect=OFF -DBUILD_opencv_xphoto=ON -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-$OPENCV_VERSION/modules" GPU_FLAGS="-DWITH_CUDA=OFF" From a092bb15856763ea2c1b3dfc786332b57880b4b9 Mon Sep 17 00:00:00 2001 From: Simon Harris Date: Thu, 10 Jan 2019 15:28:46 +1100 Subject: [PATCH 2/2] Fixes HEADLESS: unbound variable Assigns default value of `no`. There are other ways to handle this but I liked that this makes the default behaviour pretty clear. --- opencv/cppbuild.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opencv/cppbuild.sh b/opencv/cppbuild.sh index 2f91bda4957..25844a95422 100755 --- a/opencv/cppbuild.sh +++ b/opencv/cppbuild.sh @@ -53,7 +53,7 @@ BUILD_X="-DBUILD_ANDROID_EXAMPLES=OFF -DBUILD_ANDROID_PROJECTS=OFF -DBUILD_TESTS WITH_X="-DWITH_1394=OFF -DWITH_FFMPEG=OFF -DWITH_GSTREAMER=OFF -DWITH_IPP=OFF -DWITH_LAPACK=OFF -DWITH_OPENCL=ON -DWITH_OPENMP=OFF -DOPENCV_ENABLE_NONFREE=ON" # support headless -if [[ "$HEADLESS" == "yes" ]]; then +if [[ "${HEADLESS:-no}" == "yes" ]]; then WITH_X="$WITH_X -DWITH_WIN32UI=OFF -DWITH_QT=OFF -DWITH_GTK=OFF" fi