building opencv fail on Qiana - c++

I encountered the problem during compiling OpenCV. Error message said that I don't have Eigen. However, I do have one in my /usr/local/include directory. Also, I ran CMake with option below.
CMake:
cmake -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_OPENGL=ON -D CUDA_GENERATION=Auto USE_EIGEN=/usr/local/include/Eigen ..
Compiling OpenCV(by make):
[ 75%] Building CXX object modules/contrib/CMakeFiles/opencv_contrib.dir/src/rgbdodometry.cpp.o
/home/gom7745/IR/opencv-2.4.11/modules/contrib/src/rgbdodometry.cpp:65:47: fatal error: unsupported/Eigen/MatrixFunctions: No such file or directory
# include <unsupported/Eigen/MatrixFunctions>
^
compilation terminated.
make[2]: *** [modules/contrib/CMakeFiles/opencv_contrib.dir/src/rgbdodometry.cpp.o] Error 1
make[1]: *** [modules/contrib/CMakeFiles/opencv_contrib.dir/all] Error 2
make: *** [all] Error 2
Does anyone have any idea about this? Thanks!!

Building it with -DWITH_EIGEN=OFF solved the issue for me.

here cmake is unable to find unsupported/Eigen/MatrixFunctions. First find where Eigen is installed, in my case it was located at /usr/local/include/eigen3. Now locate your rgbdodometry.cpp file, in my case it was in /opencv_contrib/modules/rgbd/src. Open the cpp file and modify the previous line with something like
"/usr/local/include/eigen3/unsupported/Eigen/MatrixFunctions"

Related

macOS Monterey --> fatal error: 'opencv2/videoio.hpp' file not found

I am trying to build opencv on macOS for a CPP capstone project but when I try to compile like so:
cmake -D CMAKE_BUILD_TYPE=RELEASE -DBUILD_SHARED_LIBS=OFF -D BUILD_opencv_objdetect=OFF -D BUILD_opencv_video=OFF -D BUILD_opencv_videoio=OFF -D BUILD_opencv_features2d=OFF -D BUILD_opencv_flann=OFF -D BUILD_opencv_highgui=OFF -D BUILD_opencv_ml=OFF -D BUILD_opencv_photo=OFF -D BUILD_opencv_python=OFF -D BUILD_opencv_shape=OFF -D BUILD_opencv_stitching=OFF -D BUILD_opencv_superres=OFF -D BUILD_opencv_ts=OFF -D BUILD_opencv_videostab=OFF ..
make -j8
I am getting the following error:
[ 98%] Built target opencv_model_diagnostics
make[2]: *** No rule to make target `zlib', needed by `lib/python3/cv2.cpython-39-darwin.so'. Stop.
make[2]: *** Waiting for unfinished jobs....
[ 98%] Building CXX object modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o
In file included from /Users/username/Projects/opencv/opencv/modules/python/src2/cv2.cpp:11:
In file included from /Users/username/Projects/opencv/opencv/build/modules/python_bindings_generator/pyopencv_generated_include.h:50:
/Users/username/Projects/opencv/opencv/modules/gapi/include/opencv2/gapi/streaming/cap.hpp:26:10: fatal error: 'opencv2/videoio.hpp' file not found
#include "opencv2/videoio.hpp"
^~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o] Error 1
make[1]: *** [modules/python3/CMakeFiles/opencv_python3.dir/all] Error 2
make: *** [all] Error 2
I did follow at first the instruction from opencv but make step fails at:
[ 36%] Building CXX object modules/dnn/CMakeFiles/opencv_dnn.dir/int8layers/layers_common.avx512_skx.cpp.o
[ 36%] Linking CXX shared library ../../lib/libopencv_dnn.dylib
[ 36%] Built target opencv_dnn
make: *** [all] Error 2
Any help is highly appreciated.

/usr/bin/ld: cannot find -lopencv_nonfree

I installed OpenCV 4.1 on Ubuntu 18.04 LTS. The problem is when I compile my project's CMake file, the output is:
/usr/bin/ld: cannot find -lopencv_nonfree
collect2: error: ld returned 1 exit status
CMakeFiles/river_flow_velocity_estimation.dir/build.make:274: recipe for target 'river_flow_velocity_estimation' failed
make[2]: *** [river_flow_velocity_estimation] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/river_flow_velocity_estimation.dir/all' failed
make[1]: *** [CMakeFiles/river_flow_velocity_estimation.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
My CMake flags when I compile OpenCV are:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D BUILD_EXAMPLES=ON -D OPENCV_GENERATE_PKGCONFIG=YES -D OPENCV_ENABLE_NONFREE=ON -D WITH_OPENMP=ON -D WITH_OPENCL=ON -D INSTALL_CREATE_DISTRIB=ON -DBUILD_opencv_world=OFF -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..
Can someone help me?

how to build kate with cmake?

Dear stackoverflow users,
I'm trying to compile kate from source but I'm getting an error with a not declared variable.
So far these are the commands I'm using:
#! /bin/bash
cmake \
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
-D CMAKE_INSTALL_PREFIX=~/kde/usr \
-D KDE_INSTALL_USE_QT_SYS_PATHS:BOOL=ON \
-D TARGET_include_directories:PATH="/usr/include/x86_64-linux-gnu/qt5/" \
-D Qt5_INCLUDE_DIRS:PATH="/usr/include/x86_64-linux-gnu/qt5/" \
-D Qt5_LIBRARY_DIRS:PATH="/usr/lib/x86_64-linux-gnu/qt5/" \
../kate/
make
make install
Please find below the error during compiling: I think it has to be related with not including some path file that should be there which declares the variable QWidgetAction, however I'm not sure why, since I installed all required packages as per the website.
(qtbase5-dev qtscript5-dev extra-cmake-modules plasma-framework-dev libkf5crash-dev libkf5config-dev libkf5activities-dev kinit-dev kdoctools-dev libkf5i18n-dev libkf5parts-dev libkf5guiaddons-dev libkf5iconthemes-dev libkf5jobwidgets-dev kio-dev libkf5texteditor-dev libkf5windowsystem-dev libkf5xmlgui-dev libgit2-dev).
The reason I'm compiling it is because I messed up with my original installed kate and I just can't load back all plugins, since my /.config kate folder is gone. Please any help is appreciated.
[ 69%] Automatic moc for target katecloseexceptplugin [ 69%] Built
target katecloseexceptplugin_automoc [ 71%] Built target
katecloseexceptplugin [ 71%] Automatic moc for target
katesqlplugin [ 71%] Built target katesqlplugin_automoc [
71%] Building CXX object addons/katesql/CMakeFiles/katesqlplugin.dir
/katesqlview.cpp.o
/home/pablo/kde/kate/addons/katesql/katesqlview.cpp: In member
function ‘void KateSQLView::setupActions()’:
/home/pablo/kde/kate/addons/katesql/katesqlview.cpp:141:3: error:
‘QWidgetAction’ was not declared in this scope QWidgetAction
*wa = new QWidgetAction(this); ^ /home/pablo/kde/kate/addons/katesql/katesqlview.cpp:141:18: error:
‘wa’ was not declared in this scope QWidgetAction *wa =
new QWidgetAction(this);
^ /home/pablo/kde/kate/addons/katesql/katesqlview.cpp:141:27: error:
expected type-specifier before ‘QWidgetAction’
QWidgetAction wa = new QWidgetAction(this);
^ addons/katesql/CMakeFiles/katesqlplugin.dir/build.make:96: recipe for
target
'addons/katesql/CMakeFiles/katesqlplugin.dir/katesqlview.cpp.o' failed
make[2]:
[addons/katesql/CMakeFiles/katesqlplugin.dir/katesqlview.cpp.o]
Error 1 CMakeFiles/Makefile2:2439: recipe for target
'addons/katesql/CMakeFiles /katesqlplugin.dir/all' failed
make[1]: * [addons/katesql/CMakeFiles/katesqlplugin.dir/all] Error 2
Makefile:138: recipe for target 'all' failed make: *** [all]
Error 2
QWidgetAction is a part of Qt. Have you got the Qt libraries and headers properly in your path?
Header: #include

OpenCV linking error

The same error first occured in the middle of the build when linking another shared library. Then I've added BUILD_SHARED_LIBS=OFF so now it occurs at the very end only. The last two options were also added in hope of fixing it. Using LinuxMint 17.
[ 99%] Building CXX object modules/videostab/CMakeFiles/opencv_videostab.dir/src/deblurring.cpp.o
[ 99%] Building CXX object modules/videostab/CMakeFiles/opencv_videostab.dir/src/motion_stabilizing.cpp.o
Linking CXX static library ../../lib/libopencv_videostab.a
[ 99%] Built target opencv_videostab
[ 99%] Generating pyopencv_generated_include.h, pyopencv_generated_funcs.h, pyopencv_generated_types.h, pyopencv_generated_type_reg.h, pyopencv_generated_ns_reg.h
Scanning dependencies of target opencv_python2
[ 99%] Building CXX object modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o
Linking CXX shared module ../../lib/cv2.so
/usr/bin/ld: //usr/local/lib/libavformat.a(allformats.o): relocation R_X86_64_32 against `ff_a64_muxer' can not be used when making a shared object; recompile with -fPIC
//usr/local/lib/libavformat.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [lib/cv2.so] Error 1
make[1]: *** [modules/python2/CMakeFiles/opencv_python2.dir/all] Error 2
make: *** [all] Error 2
Command:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D PYTHON_EXECUTABLE=/home/serj/work/beautytorch/venv/bin/python \
-D BUILD_EXAMPLES=OFF \
-D BUILD_SHARED_LIBS=OFF \
-D CMAKE_CXX_FLAGS=-fPIC \
-D WITH_IPP=OFF \
..
It is ffmpeg which should have been compiled with -fPIC. enter link description here I had ffmpeg compiled from sources. After deinstallation, opencv links fine.

OpenCV make on Ubuntu with opencv_contrib fails due to opencv_xphoto

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