How to install xphoto from opencv_contrib [closed]
Hi,
I want to use the cv::xphoto::balanceWhite() function in my code. However, I have some problems installing the library. So far I understood that I need opencv 3.0.0 combined with the opencv_contrib repository. To install these I followed mostly the instructions by Rodrigo Berriel and the README.md in the opencv_contrib repository.
The steps I performed where (my operating system is Ubuntu 14.04):
sudo apt-get -y install libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff4-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip qt5-default libvtk6-dev zlib1g-dev libwebp-dev libpng-dev libtiff5-dev libopenexr-dev libgdal-dev libx264-dev yasm libxine2-dev libeigen3-dev python-tk python3-dev python3-tk python3-numpy ant default-jdk doxygen
These dependencies are probably more than I need. I combined the recommendations from several pages.
wget https://github.com/Itseez/opencv/archive/3.0.0.zip -O opencv-3.0.0.zip
git clone https://github.com/Itseez/opencv_contrib.git
unzip opencv-3.0.0.zip
cd opencv-3.0.0
mkdir -pv build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_TBB=ON \
-D WITH_V4L=ON \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D BUILD_opencv_ximgproc=OFF \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=OFF \
..
I removed ximgproc and python because these modules gave me some errors during configuration. However, I am only interested in xphoto anyway.
make -j 8
sudo make install
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
This process goes through without any errors. Further, I can compile my opencv code that does not contain any contrib modules so far. But, as soon as I add a call to the following code, compilation fails.
#include "opencv2/xphoto.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/imgproc/types_c.h"
...
cv::Mat whiteBalanced;
cv::xphoto::balanceWhite(ImageOriginal, whiteBalanced, cv::xphoto::WHITE_BALANCE_SIMPLE);
I identified the problem so far, that the compiler (clang) does not find the include files. I searched my machine and only found them scattered in the opencv_contrib repository, but not installed in a common place like /usr/include.
So my assumption is that opencv got compiled and installed correctly, however the modules from the opencv_contrib repository where only compiled but not installed.
Is there a step missing or did I something wrong during the installation? How do you compile opencv together with the xphoto module?
Thank you very much.
supplement: If I compile with the options:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_TBB=ON \
-D WITH_V4L=ON \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D BUILD_opencv_ximgproc=ON \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=OFF \
..
I get the error:
[ 94%] Building CXX object modules/ximgproc/CMakeFiles/opencv_ximgproc.dir/src/sparse_match_interpolators.cpp.o
In file included from /home/mkreim/bin/opencv/opencv/opencv-3.0.0/modules/core/include/opencv2/core.hpp:54:0,
from /home/mkreim/bin/opencv ...
if you disable the ximgproc module in cmake, the corresponding headers won't get copied with the install
what went wrong building ximgproc ?
I added the error message I get when I compile with ximgproc to the original post.
blunt guess : it's a synchronization problem. delete your build folder, update both opencv(trunk) and contrib, start from scratch.
Thanks a lot for your "blunt guess". I am using the opencv git repository now (instead of the stable relase zip file). I can compile opencv + modules now. However, when I try to link my own code I run into trouble. I documented everything in my original post as Supplement 2. Do you see the mistake in the linking process? Thanks in advance!
ah, this seems a faily easy one now:
you're missing
-lopencv_imgcodecs
(needed forimread()
)I have one further question: What is the common style in this forum for making edits to my posts? Should I keep adding supplements to my original question or should I rewrite the entire questions if I get new information from your answers? Thanks.
Thanks, that was really quite easy. However, that changes the problem to
But the compilation does work fine. Why does it not find the balanceWhite() function?
ah, just keep it the way it is. rewriting usually kills a lot of context (needed to understand comments)
did it work ?
oh, i missed that, it's
-lopencv_xphoto
(and it's the linker, which complains, not the compiler)Thanks a lot. That worked.