注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

hhfighting的博客

以责人之心责己,以恕己之心恕人

 
 
 

日志

 
 
 
 

ubuntu11.10下安装PTAMM  

2012-05-25 14:42:13|  分类: ubuntu 下程序开 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
本文的安装是在自带的安装手册(manual.pdf)的指导下进行安装的。
1 安装所需要的依赖库
通过cvs和ssh获得以下库(首先需要安装cvs:sudo apt-get install cvs,然后设置export CVS_RSH=ssh)
(1)安装blas和lapack库
参考个人日志“Ubuntu下Boost、BLAS、Lapack及CGAL安装  ”。
本次安装的boost是1.49.0版本。lapack是3.4.1版本。CGAL是4.0版本。
另外一种简单的boost安装方式:sudo apt-get install libboost-dev libboost-doc(没有亲自测试,来源于网络)
安装lapack的另一种方法:wendy@wendy-Lenovo-Product:~$ sudo apt-get install liblapack-dev
另外还可以通过cmake去生成lapack库,可以生成动态的链接库(cmak-gui .       make     sudo make install). 个人电脑此编译方式生成的文件在build目录下。
(2)安装libpng、libjpeg、libtiff、libdc1394
wendy@wendy-Lenovo-Product:~/work$ sudo apt-get install libpng-dev
wendy@wendy-Lenovo-Product:~/work$ sudo apt-get install libtiff-dev
wendy@wendy-Lenovo-Product:~/work$ sudo apt-get install libjpeg62-dev
wendy@wendy-Lenovo-Product:~/work$ sudo apt-get install libdc1394-22-dev
(3)安装opengl
wendy@wendy-Lenovo-Product:~/work$ sudo apt-get install mesa-common-dev
wendy@wendy-Lenovo-Product:~/work$ sudo apt-get install libgl1-mesa-dev
wendy@wendy-Lenovo-Product:~/work$ sudo apt-get install libglu1-mesa-dev
wendy@wendy-Lenovo-Product:~/work$ sudo apt-get install freeglut3-dev
测试opengl是否安装成功的例子test_gl.cpp:

# include <GL/glut.h>
# include <stdlib.h>

/**//* 初始化材料属性、光源属性、光照模型,打开深度缓冲区 */
void init ( void )
{
   GLfloat mat_specular [ ] = { 1.0, 1.0, 1.0, 1.0 };
     GLfloat mat_shininess [ ] = { 50.0 };
     GLfloat light_position [ ] = { 1.0, 1.0, 1.0, 0.0 };

     glClearColor ( 0.0, 0.0, 0.0, 0.0 );
     glShadeModel ( GL_SMOOTH );

     glMaterialfv ( GL_FRONT, GL_SPECULAR, mat_specular);
     glMaterialfv ( GL_FRONT, GL_SHININESS, mat_shininess);
     glLightfv ( GL_LIGHT0, GL_POSITION, light_position);

     glEnable (GL_LIGHTING);
     glEnable (GL_LIGHT0);
     glEnable (GL_DEPTH_TEST);
}

/**//*调用GLUT函数,绘制一个球*/
void display ( void )
{
     glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     glutSolidSphere (1.0, 40, 50);
     glFlush ();
}


/**//* 定义GLUT的reshape函数,w、h分别是当前窗口的宽和高*/
void reshape (int w, int h)
{
     glViewport (0, 0, (GLsizei) w, (GLsizei) h);
     glMatrixMode (GL_PROJECTION);
     glLoadIdentity ( );
     if (w <= h)
         glOrtho (-1.5, 1.5, -1.5 * ( GLfloat ) h / ( GLfloat ) w,

1.5 * ( GLfloat ) h / ( GLfloat ) w, -10.0, 10.0 );
     else
         glOrtho (-1.5 * ( GLfloat ) w / ( GLfloat ) h, 1.5 * ( GLfloat ) w / ( GLfloat ) h,

-1.5, 1.5, -10.0, 10.0);
     glMatrixMode ( GL_MODELVIEW );
     glLoadIdentity ( ) ;
}


/**//* 定义对键盘的响应函数 */
void keyboard ( unsigned char key, int x, int y)
{
     /**//*按Esc键退出*/
     switch (key)
     {
         case 27:
         exit ( 0 );
         break;
     }
}


int main(int argc, char** argv)
{
    /**//* GLUT环境初始化*/
     glutInit (&argc, argv);
     /**//* 显示模式初始化 */
     glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
     /**//* 定义窗口大小 */
     glutInitWindowSize (300, 300);
     /**//* 定义窗口位置 */
     glutInitWindowPosition (100, 100);
     /**//* 显示窗口,窗口标题为执行函数名 */
     glutCreateWindow ( argv [ 0 ] );
     /**//* 调用OpenGL初始化函数 */
     init ( );
     /**//* 注册OpenGL绘图函数 */
     glutDisplayFunc ( display );
     /**//* 注册窗口大小改变时的响应函数 */
     glutReshapeFunc ( reshape );
     /**//* 注册键盘响应函数 */
     glutKeyboardFunc ( keyboard );
     /**//* 进入GLUT消息循环,开始执行程序 */
     glutMainLoop( );
     return 0;
}

运行:wendy@wendy-Lenovo-Product:~/work$ gcc test_gl.cpp -lglut
           wendy@wendy-Lenovo-Product:~/work$ ./a.out

(4)TooN         线性代数库
下载:cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/toon co TooN
安装:wendy@wendy-Lenovo-Product:~/work/TooN$ ./configure
          wendy@wendy-Lenovo-Product:~/work/TooN$ make
          wendy@wendy-Lenovo-Product:~/work/TooN$ sudo make install

(5)libCVD      图像处理、视频捕捉、计算机视觉库
下载:cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/libcvd co libcvd
安装:
    1)wendy@wendy-Lenovo-Product:~/work/libcvd$ ./configure --without-ffmpeg
         提示信息:

checking for v4l2... no
               checking for strange v4l2... no
                checking linux/videodev.h usability... no
                checking linux/videodev.h presence... no
                checking for linux/videodev.h... no
                Missing options for linux-gnu: dc1394v1 ffmpeg lapack v4l1buffer v4l2buffer
-D_REENTRANT -Wall -Wextra -pipe -ggdb -fPIC -mmmx -msse -msse -msse2 -msse3 -pthread
-ltiff -ljpeg -lpng -lpng -lGLU -lGL -lrt -ldc1394 -L -lX11 -lXext -pthread

         提示信息解析:
              a. dc1394v1问题:虽然没有找到dc1394v1,但是应该找到了dc1394v2,相关提示如
                     Options:inline_asm assembler dc1394v2 posix_rt videodisplay tr1_shared_ptr toon pthread png jpeg tiff glob memalign
              b. ffmpeg问题:手册中的配置命令是不安装ffmpeg的( ./configure --without-ffmpeg)
              c. lapack问题:明明安装了lapack,為什麼找不到呢?疑惑...
                  使用apt-get自动安装lapack,此时再运行配置,即可检测到lapack了。(经过测试可行,但是该方法不可取。因为lapack的版本可能不一致)
使用cmake生成的库,可以解决此问题,是一种比较完美的解决方案。

                       
              d. v4lbuffer问题:(ubuntu从11.04开始不支持v4l1buffer,故本文应该使用v4l2buffer)
                       安装v4l:wendy@wendy-Lenovo-Product:~/work/libcvd$ sudo apt-get install libv4l-dev   到此为止问题仍没解决。
                       检查是否安装了v4l2:wendy@wendy-Lenovo-Product:~$ pkg-config --libs /usr/lib/i386-linux-gnu/pkgconfig/libv4l2.pc
                                                         正确运行输出-lv4l2.
                      检查错误的时候察看config.log文件。

configure:7322: checking for v4l2
configure:7336: g++ -c -g  -Wall -Wextra -pipe -ggdb -fPIC -mmmx -msse -msse -msse2 -msse3 

-INONE/include conftest.cpp >&5
conftest.cpp:3:36: fatal error: linux/videodev.h: No such file or directory
compilation terminated.
configure:7343: $? = 1
configure: failed program was:
|     #include <sys/types.h>
|                                 #include <linux/types.h>
|                                 #include <linux/videodev.h>
|                                 int main(){V4L2_PIX_FMT_GREY;return 0;}
configure:7354: result: no

检查在ubuntu11.10中确实不存在videodev.h变成了videodev2.h,同时出现了libv4l1-videodev.h(在usr/include下)文件。因此需要修改配置文件(configure),包含这两个文件去替换 #include <linux/videodev.h>。
再次配置:checking for v4l2... yes  (正常了ubuntu11.10下安装PTAMM - hhfighting - hhfighting的博客

e. 错误信息

checking for dgesvd_ in -lacml... no
checking if Accelerate framework is needed for LAPACK...
checking for dgesvd_... no

从config.log文件中查找出和“dgesvd_...no”相关的错误信息:

/* Define dgesvd_ to an innocuous variant, in case <limits.h> declares dgesvd_.
| For example, HP-UX 11i <limits.h> declares gettimeofday. */
| #define dgesvd_ innocuous_dgesvd_
|
| /* System header to define __stub macros and hopefully few prototypes,
| which can conflict with char dgesvd_ (); below.
| Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
| <limits.h> exists even on freestanding compilers. */
|
| #ifdef __STDC__
| # include <limits.h>
| #else
| # include <assert.h>
| #endif
|
| #undef dgesvd_
|
| /* Override any GCC internal prototype to avoid an error.
| Use char because int might match the return type of a GCC
| builtin and then its argument prototype would still apply. */
| #ifdef __cplusplus
| extern "C"
| #endif
| char dgesvd_ ();
| /* The GNU C library defines this for functions which it implements
| to always fail with ENOSYS. Some functions are actually named
| something starting with __ and the normal name is an alias. */
| #if defined __stub_dgesvd_ || defined __stub___dgesvd_
| choke me
| #endif
|
| int
| main ()
| {
| return dgesvd_ ();
| ;
| return 0;
| }
configure:9111: result: no



(安装v4l-ctrl:http://www.techytalk.info/webcam-settings-control-ubuntu-fedora-linux-operating-system-cli/
         sudo add-apt-repository ppa:libv4l/ppa          
sudo
apt-get update
sudo
apt-get install v4l-utils

(v4l的一些相关网址记录:http://blog.csdn.net/xiao888lin/article/details/5727446)

最终运行配置使用的命令是:wendy@wendy-Lenovo-Product:~/work/libcvd$ ./configure --without-ffmpeg --without-v4l1buffer
    2)配置完后,编译安装。
       运行make,出现的error:
      a) ./cvd/image.h:193:11: error: ‘ptrdiff_t’ does not name a type
./cvd/image.h:568:97: error: ‘ptrdiff_t’ was not declared in this scope
解决办法:添加头文件包含#include <cstddef>   (已测试,可以解决问题)
                网上的另一种解决办法是#include <stddef.h>  (这两个应该都是默认的一些头文件,印象中一个是标准头文件,一个是c++      标准头文件)
     b) ./cvd/Linux/v4l2frame.h:40:29: fatal error: linux/videodev.h: No such file or directory
 解决办法:修改为#include <linux/videodev2.h>
    c) 

cvd_src/Linux/v4l2buffer.cc:79:3: error: #error "Can't do v4l2 for this kernel version"
cvd_src/Linux/v4l2buffer.cc: In member function ‘void CVD::V4L2Buffer_Base::put_frame(

CVD::V4L2FrameT<unsigned char>*)’:
cvd_src/Linux/v4l2buffer.cc:351:7: error: expected primary-expression before ‘if’
cvd_src/Linux/v4l2buffer.cc:351:54: error: ‘K24’ was not declared in this scope
cvd_src/Linux/v4l2buffer.cc:352:3: error: expected ‘;’ before ‘K26’
cvd_src/Linux/v4l2buffer.cc: In member function ‘CVD::V4L2FrameT<unsigned char>*

CVD::V4L2Buffer_Base::get_frame()’:
cvd_src/Linux/v4l2buffer.cc:422:7: error: expected primary-expression before ‘if’
cvd_src/Linux/v4l2buffer.cc:423:7: error: ‘else’ without a previous ‘if’
cvd_src/Linux/v4l2buffer.cc:423:28: error: ‘V4L2_BUF_FLAG_TOPFIELD’ was not declared in this scope
cvd_src/Linux/v4l2buffer.cc:424:40: error: expected primary-expression before ‘)’ token
cvd_src/Linux/v4l2buffer.cc:424:40: error: expected ‘;’ before ‘)’ token
cvd_src/Linux/v4l2buffer.cc:442:3: error: expected primary-expression before ‘)’ token
cvd_src/Linux/v4l2buffer.cc:442:3: error: expected ‘;’ before ‘)’ token

对上述错误进行分析,查找原因可能出自v4l2buffer.cc的如下几句话:

#if CVD_KERNEL_MAJOR == 2 && CVD_KERNEL_MINOR == 4
#define USE_24
#define K24(X) X
#define K26(X)
#elif CVD_KERNEL_MAJOR == 2 && CVD_KERNEL_MINOR == 6
#define K26(X) X
#define K24(X)
#else
#error "Can't do v4l2 for this kernel version"
#endif

于是去查找了配置文件config.h,相关变量定义为

#define CVD_KERNEL_MAJOR 3 #define CVD_KERNEL_MINOR 0

从网上找到以前版本的定义是(网址:http://www.edwardrosten.com/cvd/html/config_8h-source.html)
00095 #define CVD_KERNEL_MAJOR 2 00096 #define CVD_KERNEL_MINOR 6
于是做相应的修改,然后再make。
d)

In file included from ./cvd/Linux/v4l1buffer.h:27:0,
from cvd_src/Linux/v4l1buffer.cc:29:
./cvd/Linux/v4l1frame.h:40:29: fatal error: linux/videodev.h: No such file or directory

修改为包含#include <libv4l1-videodev.h>继续。
e)

cvd_src/SSE2/half_sample.o: In function `CVD::halfSample(CVD::BasicImage<unsigned char> const&,

CVD::BasicImage<unsigned char>&)':
/home/wendy/work/libcvd/./cvd/vision.h:125: multiple definition of `CVD::halfSample(

CVD::BasicImage<unsigned char> const&, CVD::BasicImage<unsigned char>&)'
cvd_src/MMX/half_sample.o:/home/wendy/work/libcvd/cvd_src/MMX/half_sample.cc:14: first defined here

错误在于重定义。原因是在vision.h文件141行声明的函数void halfSample(const BasicImage<byte>& in, BasicImage<byte>& out)在mmx和sse2下均进行了定义,因此导致重复定义。故修改makefile文件去掉cvd_src/SSE2/half_sample.o或者去掉MMX。

到此为止,成功编译了libcvd,察看makefile,发现cvd_src/Linux/videosource_nov4lbuffer.o。
如果linux内核版本较高的话,去掉了v4l1,libcvd的configure能够检测到v4l2buffer但不会编译v4lbuffer.cc,此时需要在Makefile文件中手动添加,添加的内容为:cvd_src/Linux/v4lbuffer.o cvd_src/Linux/videosource_v4lbuffer.o
sudo make install安装即可。
 通过video_play_source v4l2:///dev/video0  验证视频采集。

root@wendy-Lenovo-Product:/home/wendy/work/libcvd# video_play_source v4l2:///dev/video0
video_play_source: error while loading shared libraries: libcvd.so: cannot open shared object file:

No such file or directory

解决办法:gedit /etc/ld.so.conf   添加/usr/local/lib,保存   然后执行ldconfig。

root@wendy-Lenovo-Product:/home/wendy/work/libcvd# video_play_source v4l2:///dev/video0
Error: V4LBuffer: No colourspace on /dev/video0 matching None


(6)Gvars3     libcvd的一个子工程
下载:cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/libcvd co gvars3
安装:./configure --disable-widgets
           make
           sudo make install

(7)lib3ds       处理3ds模型(版本是lib3ds-20080909)
 下载网址:http://www.lib3ds.org
 安       装:./configure;    make;    sudo make install

2 安装编译PTAMM库
make编译。
错误代码1:

HomographyInit.o: In function `PTAMM::HomographyInit::HomographyFromMatches(std::vector<PTAMM::HomographyMatch, std::allocator<PTAMM::HomographyMatch> >)':
HomographyInit.cc:(.text+0x1219): undefined reference to `dgesvd_'
HomographyInit.cc:(.text+0x12b1): undefined reference to `dgesvd_'
HomographyInit.o: In function `_ZN5PTAMM14HomographyInit21HomographyFromMatchesESt6vectorINS_15HomographyMatchESaIS2_EE.constprop.478':
HomographyInit.cc:(.text+0x181e): undefined reference to `dgesvd_'
HomographyInit.cc:(.text+0x18b6): undefined reference to `dgesvd_'
HomographyInit.o: In function `PTAMM::HomographyInit::DecomposeHomography()':
HomographyInit.cc:(.text+0x247d): undefined reference to `dgesvd_'
HomographyInit.o:HomographyInit.cc:(.text+0x2526): more undefined references to `dgesvd_' follow
ShooterGame.o: In function `PTAMM::ShooterGame::Init()':
ShooterGame.cc:(.text+0x3fd0): undefined reference to `gluNewQuadric'
ShooterGame.cc:(.text+0x3ff0): undefined reference to `gluSphere'
ShooterGame.cc:(.text+0x3ff8): undefined reference to `gluDeleteQuadric'
collect2: ld returned 1 exit status
make: *** [PTAMM] Error 1

编辑MakeFile,加入-lGL -lGLU -llapack选项,再make即正常。
  评论这张
 
阅读(2943)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018