ocean学习笔记(一):ubuntu编译facebook开源ocean库

1.安装python环境

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 1.curl/wget命令
>> curl -LsSf https://astral.sh/uv/install.sh | sh
>> wget -qO- https://astral.sh/uv/install.sh | sh
# 2.修改环境变量
>> vim ~/.zshrc
export UV_DEFAULT_INDEX="https://pypi.tuna.tsinghua.edu.cn/simple"
. "$HOME/.local/bin/env"
# 3.刷新环境变量
>> source ~/.zshrc
# 4.创建python环境
>> uv venv --python 3.12
>> uv pip install pyyaml rich
# 5.激活python环境
>> source .venv/bin/activate

2.安装工具

1
2
3
4
5
6
7
8
9
10
11
## 1.安装库依赖
>> sudo apt-get install libx11-dev libudev-dev liblzma-dev libgl1-mesa-dev libxcb-glx0-dev -y
## 2.报错 fatal error: openjpeg.h: No such file or directory时
### 2.1 安装openjpg库
>> sudo apt-get install libopenjp2-7-dev -y
### 2.2 导入环境变量中
>> vim ~/.zshrc
export CPLUS_INCLUDE_PATH=/usr/include/openjpeg-2.5:$CPLUS_INCLUDE_PATH
export C_INCLUDE_PATH=/usr/include/openjpeg-2.5:$C_INCLUDE_PATH
### 2.3 刷新环境变量
>> source ~/.zshrc

3.编译第三方库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# 1.关闭libtiff的lzma选项,依赖配置文件对应libtiff新增lzma: OFF
>> vim build/python/dependencies.yaml
libtiff:
version: "4.6.0"
description: "TIFF library and utilities"
source:
type: git
url: https://gitlab.com/libtiff/libtiff.git
ref: "v4.6.0"
build:
system: cmake
options:
tiff-tools: OFF
tiff-tests: OFF
tiff-contrib: OFF
tiff-docs: OFF
# Disable GNU ld version script - not supported by Apple linker
HAVE_LD_VERSION_SCRIPT: OFF
# Disable C++ wrapper library - fails to link on iOS shared builds
cxx: OFF
# Disable optional codecs that would require additional libraries
# (jbig, zstd, webp, lerc, libdeflate) not built by Ocean's 3P system.
# Without this, libtiff auto-detects system libraries and links against
# them, causing undefined reference errors in static builds.
lzma: OFF
jbig: OFF
zstd: OFF
webp: OFF
lerc: OFF
libdeflate: OFF
dependencies:
- zlib
platforms: all
>> python build/python/build_ocean_3rdparty.py --with opencv --config release
Total builds: 19
Cumulative build time: 13m 59s
Wall-clock time: 10m 46s
Parallelism factor: 1.3x

✓ Build completed successfully!

══════════════════════════════════════════════════════════════════════
Next steps
══════════════════════════════════════════════════════════════════════
Third-party libraries installed at:
/home/mirror/workspace/ocean/ocean_3rdparty/install

Set OCEAN_THIRDPARTY_PATH so the Ocean Gradle apps (e.g. the PointTracker demo) can find them:

bash / zsh:
export OCEAN_THIRDPARTY_PATH="/home/mirror/workspace/ocean/ocean_3rdparty/install"

Alternatively, pass the path explicitly to build_ocean.py:
python build/python/build_ocean.py --third-party-dir /home/mirror/workspace/ocean/ocean_3rdparty/install
══════════════════════════════════════════════════════════════════════

4. 编译Ocean库

1
2
3
4
5
6
7
8
9
>> python build/python/build_ocean.py --config release
============================================================
Build Summary
============================================================

All builds completed successfully.

Install locations:
- /home/mirror/workspace/ocean/ocean_install/linux/linux_x86_64_static

参考资料