ubuntu 16.04 opencv3.1.0 opencvv_contrib编译遇到的问题

想搞下追踪的东西,opencv的opencv_contrib包中有类似的tracking可用

在编译好opencv3.1.0的基础上继续执行下面即可

1。下载 选择对应版本

cd /home
git clone https://github.com/Itseez/opencv_contrib.git
cd opencv_contrib
git checkout 3.1.0  #我使用的是opencv3.1 注意opencv_contrib 要和你的opencv相对应

2。安装opencv_contrib模块

cd ~/opencv-3.1.0/build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=/home/yourname/opencv-3.1.0/opencv_contrib-master/modules/ ..

# 上述无报错,开始安装!
make -j8
sudo make install -j8

ubuntu 14.04 64位安装Opencv3.1.0+包含opencv_contrib模块

http://blog.csdn.net/jay463261929/article/details/53197228
报错:fatal error hdf5.h no such file or directory
这里写图片描述
解决办法:
在opencv-3.1.0/modules/python/common.cmake首行添加如下代码:

find_package(HDF5)
include_directories(${HDF5_INCLUDE_DIRS})

遇到的报错

[ 98%] Building CXX object modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o
In file included from /home/epinux/dev/opencv_contrib/modules/tracking/include/opencv2/tracking/tracker.hpp:48:0,
                 from /home/epinux/dev/opencv/build2/modules/python2/pyopencv_generated_include.h:50,
                 from /home/epinux/dev/opencv/modules/python/src2/cv2.cpp:12:
/home/epinux/dev/opencv_contrib/modules/tracking/include/opencv2/tracking/onlineMIL.hpp:57:23: error: expected unqualified-id before ‘>’ token
 #define  sign(s)  ((s > 0 ) ? 1 : ((s<0) ? -1 : 0))
                       ^
/home/epinux/dev/opencv_contrib/modules/tracking/include/opencv2/tracking/onlineMIL.hpp:57:23: error: expected ‘)’ before ‘>’ token
/home/epinux/dev/opencv_contrib/modules/tracking/include/opencv2/tracking/onlineMIL.hpp:57:23: error: expected ‘)’ before ‘>’ token
modules/python2/CMakeFiles/opencv_python2.dir/build.make:296: recipe for target 'modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o' failed
make[2]: *** [modules/python2/CMakeFiles/opencv_python2.dir/__/src2/cv2.cpp.o] Error 1
CMakeFiles/Makefile2:13133: recipe for target 'modules/python2/CMakeFiles/opencv_python2.dir/all' failed
make[1]: *** [modules/python2/CMakeFiles/opencv_python2.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

解决方案:

# 打开问题文件
gedit ~/opencv_contrib/modules/tracking/include/opencv2/tracking/onlineMIL.hpp 

# 修改代码
# 找到下面这一行
#define sign(a) a > 0 ? 1 : a == 0 ? 0 : -1

替换为
namespace {
    template
    CV_INLINE int sign(const T v) {
        return (v > 0) ? 1 : ((v < 0) ? -1 : 0);
    }
} // anon namespace


# 然后重新
make -j8
sudo make install -j8

你可能感兴趣的:(Personal,Notes)