I'm trying to install opencv on ubuntu. so far I have downloaded opencv 3.1 and done this:
mkdir build
cd build/
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_CUBLAS=ON -DCUDA_NVCC_FLAGS="-D_FORCE_INLINES" ..
but when I try to make it, by using make it shows these kind of errors:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:63:16: error: expected constructor, destructor, or type conversion before ‘(’ token
__MATHCALL_VEC (cos,, (Mdouble __x));
or
/usr/include/c++/5/cmath:199:11: error: ‘::cos’ has not been declared
and so on. what can I do to fix this?
Related
I'm trying to build a docker image with the latest opencv version 4.1.0 to be able to use cudafeatures2D. I have cuda 9.0 installed but every time i try to compile opencv from source it says it doesn't find CUDA.
I'm using the build runtime image FROM nvidia/cuda:9.0-cudnn7-runtime. And i've checked in my current image the location of CUDA, /usr/local/cuda-9.0.
This is the code I'm using to install:
ENV PATH=$PATH:/usr/local/cuda/bin:$PATH
ENV LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH
RUN ldconfig
RUN wget https://github.com/opencv/opencv/archive/4.1.0.tar.gz && tar xf 4.1.0.tar.gz && rm 4.1.0.tar.gz
RUN wget https://github.com/opencv/opencv_contrib/archive/4.1.0.tar.gz && tar xf 4.1.0.tar.gz && rm 4.1.0.tar.gz
RUN cd opencv-4.1.0/ && mkdir build && cd build && cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D WITH_CUBLAS=ON -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_OPENGL=ON -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF -DCUDA_NVCC_FLAGS="-D_FORCE_INLINES" -D PYTHON2_EXECUTABLE=/usr/bin/python2.7 -D PYTHON_INCLUDE_DIR=/usr/include/python2.7/ -D PYTHON_INCLUDE_DIR2=/usr/include/x86_64-linux-gnu/python2.7/ -D PYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython2.7.so -D PYTHON2_NUMPY_INCLUDE_DIRS=/usr/local/lib/python2.7/dist-packages/numpy/core/include/ -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.1.0/modules/ -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-9.0 -D CUDA_CUDART_LIBRARY=/usr/local/cuda/lib64/libcudart.so -D CUDA_VERBOSE_BUILD=ON .. && make -j$(nproc) && make install
But I always get this error:
-- at: /app/opencv-3.4.6/build/3rdparty/ippicv/ippicv_lnx/iw
CMake Warning at cmake/OpenCVFindLibsPerf.cmake:35 (message):
OpenCV is not able to find/configure CUDA SDK (required by WITH_CUDA).
CUDA support will be disabled in OpenCV build.
To eliminate this warning remove WITH_CUDA=ON CMake configuration option.
Call Stack (most recent call first):
CMakeLists.txt:794 (include)
finally someone from the opencv repository pointed out that the problem I was having was due to the image I was using:
FROM nvidia/cuda:9.0-cudnn7-runtime
The runtime version usually doesn't contain the SDK files, the fix was to change -runtime for -develop.
I want to compile opencv from source on ubuntu 16.04.
I already did this successfully a couple of times before.
I am following this tutorial from pyimagesearch.
Normally this works very well, but this time I am getting the following error for the contrib module text.
[ 27%] Generating precomp.hpp.gch/opencv_text_RELEASE.gch In file
included from /usr/include/c++/5/cinttypes:35:0,
from /usr/local/include/tesseract/host.h:30,
from /usr/local/include/tesseract/serialis.h:26,
from /usr/local/include/tesseract/baseapi.h:37,
from /home/rvq/github/opencv-3.2.0/build/modules/text/precomp.hpp:51:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file
requires compiler and library support for the ISO C++ 2011 standard.
This support must be enabled with the -std=c++11 or -std=gnu++11
compiler options. #error This file requires compiler and library
support \ ^
[ 27%] Built target pch_Generate_opencv_saliency
Does somebody know how to resolve this?
Adding -D ENABLE_PRECOMPILED_HEADERS=OFF \ to CMake command resolved the issue.
Complete CMake Command:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH=~/github/opencv_contrib-3.2.0/modules \
-D PYTHON_EXECUTABLE=~/.virtualenvs/cv/bin/python \
-D ENABLE_PRECOMPILED_HEADERS=OFF \
-D BUILD_EXAMPLES=ON ..
I'm trying to build OpenCV on Ubuntu 15.10 with opencv_contrib (to use the nonfree modules). I did the following:
cmake -D CMAKE_BUILD_TYPE=RELEASE -DOPENCV_EXTRA_MODULES_PATH=/home/myname/Downloads/opencv_contrib-master/modules -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=OFF -D WITH_OPENGL=ON -D BUILD_opencv_ximgproc=ON ..
but I tried also with
BUILD_opencv_ximgproc=OFF
CMake goes well but it fails during the make step:
CMakeFiles/Makefile2:8403: recipe for target 'modules/xphoto/CMakeFiles/opencv_xphoto.dir/all' failed
make[1]: *** [modules/xphoto/CMakeFiles/opencv_xphoto.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
and then:
Makefile:136: recipe for target 'all' failed
make: *** [all] Error 2
Do you have any suggestions?
Thanks.
I solved it by deleting and re-downloading both opencv and opencv_contrib. Then I built everything again:
git clone https://github.com/Itseez/opencv.git
git clone https://github.com/Itseez/opencv_contrib.git
cd opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -DOPENCV_EXTRA_MODULES_PATH=/home/myname/Downloads/opencv_contrib/modules -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=OFF -D WITH_OPENGL=ON -D BUILD_opencv_ximgproc=ON ..
make -j7
sudo make install
it is a while I am trying to install opencv but each time I have some problems with the configuration of cmake.
this is the cmake I am trying to use:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_PYTHON_SUPPORT=ON
-D WITH_XINE=ON -D WITH_OPENGL=ON -D INSTALL_C_EXAMPLES=ON
-D INSTALL_PYTHON_EXAMPLES=ON -D WITH_TBB=ON -D BUILD_EXAMPLES=ON
-D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON
-D CMAKE_INSTALL_PREFIX=/home/username/main-env/opencv3.0
-D WITH_GTK = ON -D MATLAB_ROOT_DIR=/home/MATLAB/R2015a ..
,but got this error
Parse error in command line argument: -D
Should be: VAR:type=value
CMake Error: No cmake script provided.
CMake Error: Problem processing arguments. Aborting.
P.S. I want to put it in main-env folder which is the virtual environment folder to avoid any problems with system files and less struggling with various errors encountered in previous times. not sure possible maybe it is totally wrong. please let me know if you have some knowledge about it.
the all terms should be separated by -D and shouldn't be any attached terms with -D
I'm using python 2.7, Ubuntu 14.04 and cv2. I'm trying to run this simple code:
import cv2
cam = cv2.VideoCapture(0)
while True:
ret, frame = cam.read()
cv2.imshow("webcam", frame)
cv2.waitKey(1)
I want to take a single picture, but instead my webcam stays activated but it only returns this:
HIGHGUI ERROR: V4L/V4L2: VIDIOC_S_CROP
What I need to do to fix the problem?
Find your OpenCV directory in the the home folder and go there (something like the cd command I've written bellow, type your OpenCV directory there the code below is for my case!). Create a directory named Release and go inside the folder,
cd /home/user/OpenCV
mkdir Release
cd Release
sudo cmake -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 INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_GTK=ON -D WITH_OPENGL=ON ..
When running these commands on terminal please make sure you have permissions to those files or directories otherwise use sudo command to give them the access. After running the last one successfully type,
make
sudo make install