Skip to content

Commit

Permalink
update docker file
Browse files Browse the repository at this point in the history
  • Loading branch information
oneLOH committed May 17, 2024
1 parent e888c3f commit c651a4c
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 73 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16)

project(xrsfm)

option(XRPRIMER_ENABLED "Buinding based on XRPRIMER, if available" ON)
option(XRPRIMER_ENABLED "Buinding based on XRPRIMER, if available" OFF)
option(CUDA_ENABLED "Whether to enable CUDA, if available" ON)
set(CUDA_ARCHS "Auto" CACHE STRING "List of CUDA architectures for which to \
generate code, e.g., Auto, All, Maxwell, Pascal, ...")
Expand Down Expand Up @@ -151,10 +151,13 @@ target_include_directories(xrsfm
if(XRPRIMER_ENABLED)
target_link_libraries(xrsfm
stdc++fs
sift_gpu
XRPrimer::xrprimer
${OpenCV_LIBS}
${GTEST_LIBRARIES}
sift_gpu
${Qt5Core_LIBRARIES}
${Qt5OpenGL_LIBRARIES}
${Qt5Widgets_LIBRARIES}
)
else ()
target_link_libraries(xrsfm
Expand Down
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ RUN apt-get install -y \
python3-pip \
libglew-dev \
libatlas-base-dev \
libgtest-dev
libgtest-dev \
qtbase5-dev \
libqt5opengl5-dev \
libeigen3-dev \
libceres-dev \
libopencv-dev

Run pip3 install numpy
45 changes: 15 additions & 30 deletions docs/en/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ Dependencies from the default Ubuntu repositories:
libatlas-base-dev \
libgtest-dev \
libgflags-dev \
libgoogle-glog-dev
libgoogle-glog-dev \
qtbase5-dev \
libqt5opengl5-dev \
libeigen3-dev \
libceres-dev \
libopencv-dev
```

If the version of CMake is less than 3.16, update it.
Expand All @@ -34,39 +39,12 @@ cp -r cmake-3.21.0-linux-x86_64 /usr/share/
ln -sf /usr/share/cmake-3.21.0-linux-x86_64/bin/cmake /usr/bin/cmake
```

Install [xrprimer](https://github.com/openxrlab/xrprimer)
```shell
git clone [email protected]:openxrlab/xrprimer.git
cd xrprimer
git checkout xrslam-opencv3.4.7
cmake -S. -Bbuild -DBUILD_EXTERNAL=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_PRECOMPILED_HEADERS=OFF
cmake --build build --target install -j4
```

Ensure that the root directories of xrsfm and xrprimer remain the same.

```
xrprimer
├──
...
xrsfm
├── docs
├── scripts
├── src
...
```

Compile xrsfm
```shell
git clone git@github.com:openxrlab/xrsfm.git
git clone https://github.com/openxrlab/xrsfm.git
cd xrsfm && cmake -B build && cmake --build build -j4
```

Note: If you encounter difficulties during the compilation of xrprimer, you can try installing xrsfm without xrprimer. This requires OpenCV and Ceres-Solver. Then you can install xrsfm using the following command:
```shell
cd xrsfm && cmake -B build -DXRPRIMER_ENABLED=OFF && cmake --build build -j4
```

### Dockerfile

We provide a [Dockerfile](../../Dockerfile) to build an image. Ensure that you are using [docker version](https://docs.docker.com/engine/install/) >=19.03 and `"default-runtime": "nvidia"` in daemon.json.
Expand All @@ -78,5 +56,12 @@ docker build -t xrsfm .
Run it with

```shell
docker run --gpus all --network=host -it xrsfm
docker run --name xrsfm-container --gpus all --network=host -it xrsfm
```
```
Compile xrsfm
```shell
git clone https://github.com/openxrlab/xrsfm.git
cd xrsfm && cmake -B build && cmake --build build -j4
```
48 changes: 16 additions & 32 deletions docs/zh/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
libatlas-base-dev \
libgtest-dev \
libgflags-dev \
libgoogle-glog-dev
libgoogle-glog-dev \
qtbase5-dev \
libqt5opengl5-dev \
libeigen3-dev \
libceres-dev \
libopencv-dev
```

如果cmake版本小于3.16,按照以下步骤更新
Expand All @@ -34,42 +39,15 @@ cp -r cmake-3.21.0-linux-x86_64 /usr/share/
ln -sf /usr/share/cmake-3.21.0-linux-x86_64/bin/cmake /usr/bin/cmake
```

安装 [XRPRimer](https://github.com/openxrlab/xrprimer)
```shell
git clone [email protected]:openxrlab/xrprimer.git
cd xrprimer
git checkout xrslam-opencv3.4.7
cmake -S. -Bbuild -DBUILD_EXTERNAL=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_PRECOMPILED_HEADERS=OFF
cmake --build build --target install -j4
```

确保xrsfm和xrprimer的根目录保持一致。
```
xrprimer
├──
...
xrsfm
├── docs
├── scripts
├── src
...
```


编译 XRSfM
```shell
git clone git@github.com:openxrlab/xrsfm.git
git clone https://github.com/openxrlab/xrsfm.git
cd xrsfm && cmake -B build && cmake --build build -j4
```

注意:如果您在编译xrprimer时遇到困难,可以尝试在没有xrprimer的情况下安装xrsfm。这需要OpenCV和Ceres-Solver。然后,您可以使用以下命令安装xrsfm:
```shell
cd xrsfm && cmake -B build -DXRPRIMER_ENABLED=OFF && cmake --build build -j4
```

### 通过Docker镜像运行
### Dockerfile

We provide a [Dockerfile](../../Dockerfile) to build an image. Ensure that you are using [docker version](https://docs.docker.com/engine/install/) >=19.03 and `"default-runtime": "nvidia"` in daemon.json.
我们提供了[Dockerfile](../../Dockerfile)文件来方便环境配置.使用前请确认[docker version](https://docs.docker.com/engine/install/) >=19.03,并且在daemon.json文件中已经设置`"default-runtime": "nvidia"` .

```shell
docker build -t xrsfm .
Expand All @@ -78,5 +56,11 @@ docker build -t xrsfm .
Run it with

```shell
docker run --gpus all --network=host -it xrsfm
docker run --name xrsfm-container --gpus all --network=host -it xrsfm
```

编译 XRSfM
```shell
git clone https://github.com/openxrlab/xrsfm.git
cd xrsfm && cmake -B build && cmake --build build -j4
```
16 changes: 8 additions & 8 deletions src/optimization/cost_factor_ceres.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,32 +127,32 @@ class PoseGraphCost : public ceres::SizedCostFunction<8, 4, 3, 4, 3, 1, 1> {
vector3 p2(parameters[3]);
double s1 = parameters[4][0];
double s2 = parameters[5][0];
map<Eigen::Vector<double, 8>> residual(residuals);
map<vector<3>> res_q(residuals);
map<vector<3>> res_p(residuals + 5);

quaternion q1_inverse = q1.inverse();
quaternion q12_estimated = q1_inverse * q2;
vector3 p12_estimated = (q1_inverse * (p2 - p1));

double weight_q = 1.0;
double weight_p = 1.0;
residual.head<3>() = weight_q * logmap(q_mea * q12_estimated.inverse());
residual.tail<3>() = weight_p * (p12_estimated - s1 * p_mea);
res_q = weight_q * logmap(q_mea * q12_estimated.inverse());
res_p = weight_p * (p12_estimated - s1 * p_mea);

// 1.0 00 seq be better
// 0.5 02 seq be better
double weight_s = 1.0;
residual(3) = weight_s * (s1 / s2 - 1);
residuals[3] = weight_s * (s1 / s2 - 1);

// double weight_o = 0.1; // 0.1 bad in seq_4761_478
if (s1 < 1) {
residual(4) = weight_o * (s1 - 1);
residuals[4] = weight_o * (s1 - 1);
} else {
residual(4) = weight_o * (1.0 / s1 - 1);
residuals[4] = weight_o * (1.0 / s1 - 1);
}

if (jacobians) {
matrix3 R1 = q1.toRotationMatrix();
matrix3 JRI = jri(residual.head<3>());
matrix3 JRI = jri(res_q);
if (jacobians[0]) {
map<matrix<8, 4, true>> j_q1(jacobians[0]);
j_q1.setZero();
Expand Down

0 comments on commit c651a4c

Please sign in to comment.