AR学习笔记:工具安装

Posted Sakurazzy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AR学习笔记:工具安装相关的知识,希望对你有一定的参考价值。

AR学习笔记(一):工具安装

课题需要把3D模型投影到图像上,用到了github开源工具mesh_image_align,这里记录一下安装使用的过程和问题,已经安装好了Ubuntu18.04的双系统,但是还需要装很多依赖包,本人也因为对Ubuntu系统不太熟悉(只短暂使用过ROS做了一个夏令营项目),预计要花不少的时间


mesh_image_align的安装

项目地址:https://github.com/mpkuse/mesh_image_align
摘取了一下编译和运行代码,用cmake即可

$ mkdir build
$ cmake ..
$ make
$ ./main

下面的图是作者运行的结果,把香蕉的3D模型投影到了图像上

当然前提还需要安装相应的依赖包,根据CMakeLists.txt的find_package()一一对应
下面是依赖包的汇总,包括自己找的教程,几乎花了大半天的时间

1.OpenCV

首先是装C++版本的opencv,我安装了最新版的4.5.3
第一次安装的时候cmake没有生成opencv.pc文件,导致环境配置出现了问题,版本号查询始终为3.2.0(可能是系统自带的版本),然后又重新安装了一次,另外也删除了系统自带的3.2.0版本的opencv
安装教程:https://blog.csdn.net/s15810751918/article/details/107705387
(尤其注意opencv4以上版本)

2.Eigen3

直接使用apt安装即可

$ sudo apt install libeigen3-dev

源码安装见下链接
安装教程:https://blog.csdn.net/p942005405/article/details/100653731

3.Ceres

稍微复杂一点,下载源码包,然后cmake编译安装
安装教程:https://www.cnblogs.com/qilai/p/13654810.html

4.Theia

安装这个包踩了很多坑,一开始直接搜发现都是eclipse_theia的安装,貌似是一套IDE,感觉就不太对劲,后来发现作者在README.md是提到了这个包的

I use [Theia-sfm’s DlsPnp method] (http://theia-sfm.org/pose.html#perspective-n-point).

官方的安装教程:http://theia-sfm.org/building.html
下面是这个包的介绍,看起来就对劲多了

Theia is a computer vision library developed by Chris Sweeney aimed at providing efficient and reliable algorithms for Structure from Motion (SfM). The goal of this library is to provide researchers with an out of the box tool for multi-view reconstruction that can be easily extended. Many common algorithms for pose, feature detection and description, matching, and reconstruction have been implemented.

软件包地址:https://github.com/sweeneychris/TheiaSfM
安装方法也很简单,用cmake即可,具体的在教程里也提了

$ mkdir theia-build
$ cd theia-build
$ cmake ..
$ make -j4
$ make test
$ make install

当然,编译Theia也是需要安装依赖包的,很折磨,下面是我需要安装的几个包

OpenImageIO

github源码地址:https://github.com/OpenImageIO/oiio
根据github项目的介绍,还要额外的依赖包:Boost/libjpeg/libtiff/libpng/OpenEXR
尤其是这个OpenEXR,我尝试安装了很久,显然对于我这个小白来说非常复杂

这个包安装实际上不需要github中这么麻烦,我找到了一个简单的安装教程直接apt搞定
https://blog.csdn.net/weixin_42587961/article/details/107457917

$ sudo apt-get install zlib1g-dev
$ sudo apt-get install libopenexr-dev
$ sudo apt-get install python3-pip
$ pip3 install OpenEXR
$ sudo apt-get install libopenimageio-dev

RapidJSON

RapidJSON 是一个 C++ 的 JSON 解析器及生成器

软件包镜像源码:https://codechina.csdn.net/mirrors/Tencent/rapidjson?utm_source=csdn_github_accelerator
安装教程:http://rapidjson.org/zh-cn/

用cmake编译安装一下就好了

RockSDB

安装起来相对也比较复杂,下面这个教程比较全面
安装教程:https://www.cnblogs.com/renjc/archive/2021/01/15/rocksdb-install.html


遇到的问题

1.make install的缺少权限

在运行make install时会有缺少权限的问题(直接把include复制过去也会报错)

CMake Error at cmake_install.cmake:41 (file):
  file cannot create directory: /usr/local/include/theia.  Maybe need administrative privileges.

解决:在前面加上sudo即可

$ sudo make install

2.CV的函数缺失

在编译mesh_image_align-master的时候出现了opencv找不到对应函数的问题

/home/zzy/2d-to-3d/mesh_image_align-master/utils/CameraGeometry.cpp:82:35: error: no matching function for call to ‘cv::StereoSGBM::create()’
     sgbm = cv::StereoSGBM::create();

解决:由于系统自带了一个opencv,容易出现函数未声明的问题,所以可以用以下语句把系统自带的版本删了(看了下日志它居然把我的gazebo删了…),之后又重新安装了一次opencv,配置好环境,这个错误就解决了

$ sudo apt-get autoremove libopencv-dev

3.未声明的变量

解决了第二个问题后进行make编译,又出现了一些error,主要是一些变量未声明的问题

/home/zzy/2d-to-3d/mesh_image_align-master/utils/CameraGeometry.cpp:42:54: error: ‘CV_INTER_LINEAR’ was not declared in this scope
     cv::remap( im_raw, im_undistorted, map_x, map_y, CV_INTER_LINEAR );

/home/zzy/2d-to-3d/mesh_image_align-master/utils/CameraGeometry.cpp:144:68: error: ‘CV_GRAY2BGR’ was not declared in this scope
         cv::cvtColor(imleft_undistorted, imleft_undistorted_3chnl, CV_GRAY2BGR );

error: ‘CV_INTER_LINEAR’ was not declared in this scope
     cv::remap( imleft_undistorted, imleft_srectified, this->map1_x, this->map1_y, CV_INTER_LINEAR );

解决:还是和opencv的版本有关系,opencv4中修改了这些标识符,从官方文档一个个找…
链接:https://docs.opencv.org/4.5.3/index.html

CV_INTER_LINEAR            - - - >  cv::INTER_LINEAR
CV_GRAY2BGR                - - - >  cv::COLOR_GRAY2BGR
CV_BGR2GRAY                - - - >  cv::COLOR_BGR2GRAY
CV_MINMAX                  - - - >  cv::NORM_MINMAX
CV_AA                       - - - > cv::LINE_AA
CV_CALIB_CB_ADAPTIVE_THRESH - - - > cv::CALIB_CB_ADAPTIVE_THRESH
CV_ADAPTIVE_THRESH_MEAN_C   - - - > cv::ADAPTIVE_THRESH_MEAN_C
CV_THRESH_BINARY            - - - > cv::THRESH_BINARY
CV_CALIB_CB_FAST_CHECK      - - - > cv::CALIB_CB_FAST_CHECK
CV_SHAPE_CROSS              - - - > cv::MORPH_CROSS
CV_SHAPE_RECT               - - - > cv::MORPH_RECT
CV_TREMCRIT_ITER            - - - > cv::TermCriteria::EPS
CV_TERMCRIT_EPS             - - - > cv::TermCriteria::COUNT
CV_RETR_CCOMP               - - - > cv::RETR_CCOMP
CV_CHAIN_APPROX_SIMPLE      - - - > cv::CHAIN_APPROX_SIMPLE

运行结果

搞定了…

以上是关于AR学习笔记:工具安装的主要内容,如果未能解决你的问题,请参考以下文章

SDRAM学习笔记

AR学习笔记:相关文献查阅

AR学习笔记:相关文献查阅

AR学习笔记:相关文献查阅

AR学习笔记:Exiv2库的编译

AR学习笔记:Exiv2库的编译