ubuntu 13.04 安装OpenCV礼记

1) 首先,不要系统默认安装,访问以下链接:

https://help.ubuntu.com/community/OpenCV

2)按照里面步骤安装即可。


然后sudo vim /etc/bash.bashrc
 最后面添加
 PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
 export PKG_CONFIG_PATH
 保存后,要重启,不重启用不了。
 

重启后,如何测试配置正确。
 cd /usr/local/share/OpenCV/samples
 cd c
 sudo chmod +x build_all.sh
 sudo ./build_all.sh
 这时编译c文件会出现错误。

compiling contours.c

/usr/bin/ld: /tmp/cc7GbY6W.o: undefined reference to symbol 'cos@@GLIBC_2.0'
/usr/bin/ld: note: 'cos@@GLIBC_2.0' is defined in DSO /lib/i386-linux-gnu/libm.so.6 so try adding it to the linker command line
/lib/i386-linux-gnu/libm.so.6: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
 
 解决办法是
 Try adding -lm, to include the math library that provides lrint
 在c后面添加-lm这个选项,修改build_all.sh
 修改后的内容为
 #!/bin/sh
 

if [ $# -gt 0 ] ; then
 base=`basename $1 .c`
 echo "compiling $base"
 gcc -ggdb `pkg-config opencv --cflags --libs` $base.c -o $base 
 else
 for i in *.c; do
    echo "compiling $i"
    gcc -ggdb `pkg-config --cflags opencv` -o `basename $i .c` $i `pkg-config --libs opencv` -lm;
 done
 for i in *.cpp; do
    echo "compiling $i"
    g++ -ggdb `pkg-config --cflags opencv` -o `basename $i .cpp` $i `pkg-config --libs opencv`;
 done
 fi
 然后再编译c文件就不会出错了。


有时下载的DLT包编译会失败


Scanning dependencies of target tld
[ 80%] Building CXX object CMakeFiles/tld.dir/TLD.o
In file included from /home/haiping/opentld/OpenTLD-master/src/TLD.cpp:8:0:
opentld/OpenTLD-master/src/../include/TLD.h:51:3: error: ‘PatchGenerator’ in namespace ‘cv’ does not name a type
opentld/OpenTLD-master/src/TLD.cpp: In member function ‘void TLD::init(const cv::Mat&, const Rect&, FILE*)’:
opentld/OpenTLD-master/src/TLD.cpp:68:3: error: ‘generator’ was not declared in this scope
opentld/OpenTLD-master/src/TLD.cpp:68:162: error: ‘PatchGenerator’ was not declared in this scope
opentld/OpenTLD-master/src/TLD.cpp: In member function ‘void TLD::generatePositiveData(const cv::Mat&, int)’:
opentld/OpenTLD-master/src/TLD.cpp:156:51: error: ‘generator’ was not declared in this scope
make[2]: *** [CMakeFiles/tld.dir/TLD.o] Error 1
make[1]: *** [CMakeFiles/tld.dir/all] Error 2
make: *** [all] Error 2


这个是新版opencv的库函数位置更新了,


TLD.h 添加上

#include <opencv2/legacy/legacy.hpp>


再编译就好了




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值