I successfully build OpenCV in docker - see here My build command is the following:
# install OpenCV
RUN cd /opt && \
wget https://github.com/daveselinger/opencv/archive/3.1.0-with-cuda8.zip -O opencv-3.1.0.zip -nv && \
unzip opencv-3.1.0.zip && \
mv opencv-3.1.0-with-cuda8 opencv-3.1.0 && \
cd opencv-3.1.0 && \
rm -rf build && \
mkdir build && \
cd build && \
cmake -D CUDA_ARCH_BIN=3.2 \
-D CUDA_ARCH_PTX=3.2 \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_TBB=ON \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
-D WITH_V4L=ON \
-D BUILD_TIFF=ON \
-D WITH_QT=ON \
-D ENABLE_PRECOMPILED_HEADERS=OFF \
# -D USE_GStreamer=ON \
-D WITH_OPENGL=ON .. \
make -j4 && \
make install && \
echo "/usr/local/lib" | sudo tee -a /etc/ld.so.conf.d/opencv.conf && \
ldconfig
and it works as expected. But when I try to build with contribs adding
-D OPENCV_EXTRA_MODULES_PATH=opencv_contrib/modules .. && \
it does not work: returned a non-zero code: 1