JetsonNano Multimedia API工程搭建及编译

官方文档:

jetson Nano上Multimedia API位于/usr/src/jetson_multimedia_api

编译libagrus

1
2
3
4
5
6
7
8
9
10
11
12
cd code # 切换到自己的工作目录
sudo cp -r /usr/src/jetson_multimedia_api/argus/samples/* ./argus_samples
sudo chown -R jetson:jetson ./argus_samples

# 安装依赖
sudo apt install cmake build-essential pkg-config libx11-dev libgtk-3-dev libexpat1-dev libjpeg-dev libgstreamer1.0-dev

# 需要提前编译 utils 组件
cd ./argus_samples/utils
mkdir build && cd build
cmake -DCMAKE_MODULE_PATH=/usr/src/jetson_multimedia_api/argus/cmake -DARGUS_INCLUDE_DIR=/usr/src/jetson_multimedia_api/argus/include ../
make -j4

之后便可以正常编译所有sample,这里以oneShot为例进行编译:

1
2
3
4
5
cd code/argus_samples/oneShot
mkdir build && cd build

# 修改上层 CMakeLists.txt 添加之前编译的 utils 组件
vim ../CMakeLists.txt

将 CMakeLists.txt 中的:

  1. ${CMAKE_SOURCE_DIR}/samples/utils修改为${ARGUS_INCLUDE_DIR}/../samples/utils
  2. argussampleutils修改为${CMAKE_SOURCE_DIR}/../../utils/build/libargussampleutils

即:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
include_directories(
${ARGUS_INCLUDE_DIR}
# 修改下面这里
# ${CMAKE_SOURCE_DIR}/samples/utils
${ARGUS_INCLUDE_DIR}/../samples/utils
)

add_executable(${PROJECT_NAME} ${SOURCES})

target_link_libraries(${PROJECT_NAME}
${ARGUS_LIBRARIES}
# 修改下面这里
# argussampleutils
${CMAKE_SOURCE_DIR}/../utils/build/libargussampleutils.a
)

之后正常编译即可:

1
2
cmake -DCMAKE_MODULE_PATH=/usr/src/jetson_multimedia_api/argus/cmake -DARGUS_INCLUDE_DIR=/usr/src/jetson_multimedia_api/argus/include ../
make -j4

编译Multimedia API

1
2
3
cd code # 切换到自己的工作目录
sudo cp -r /usr/src/jetson_multimedia_api/samples/* ./mmapi_samples
sudo chown -R jetson:jetson ./mmapi_samples

修改mmapi_samples/Rules.mk文件中的如下内容,更换目录为当前文件夹:

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
...
# 将下面这四行中的路径改为当前路径
# TOP_DIR := $(shell pwd | awk '{split($$0, f, "/samples"); print f[1]}')
# CLASS_DIR := $(TOP_DIR)/samples/common/classes
# ALGO_CUDA_DIR := $(TOP_DIR)/samples/common/algorithm/cuda
# ALGO_TRT_DIR := $(TOP_DIR)/samples/common/algorithm/trt
# samples更改为mmapi_samples
TOP_DIR := $(shell pwd | awk '{split($$0, f, "/mmapi_samples"); print f[1]}')
CLASS_DIR := $(TOP_DIR)/mmapi_samples/common/classes
ALGO_CUDA_DIR := $(TOP_DIR)/mmapi_samples/common/algorithm/cuda
ALGO_TRT_DIR := $(TOP_DIR)/mmapi_samples/common/algorithm/trt
...
# 修改CPPFLAGS中带$(TOP_DIR)的路径:
# CPPFLAGS += -std=c++11 \
# -I"$(TOP_DIR)/include" \
# -I"$(TOP_DIR)/include/libjpeg-8b" \
# -I"$(ALGO_CUDA_DIR)" \
# -I"$(ALGO_TRT_DIR)" \
# -I"$(TARGET_ROOTFS)/$(CUDA_PATH)/include" \
# -I"$(TARGET_ROOTFS)/usr/include/$(TEGRA_ARMABI)" \
# -I"$(TARGET_ROOTFS)/usr/include/libdrm" \
# -I"$(TARGET_ROOTFS)/usr/include/opencv4"
CPPFLAGS += -std=c++11 \
-I/usr/src/jetson_multimedia_api/include \
-I/usr/src/jetson_multimedia_api/include/libjpeg-8b \
-I"$(ALGO_CUDA_DIR)" \
-I"$(ALGO_TRT_DIR)" \
-I"$(TARGET_ROOTFS)/$(CUDA_PATH)/include" \
-I"$(TARGET_ROOTFS)/usr/include/$(TEGRA_ARMABI)" \
-I"$(TARGET_ROOTFS)/usr/include/libdrm" \
-I"$(TARGET_ROOTFS)/usr/include/opencv4"
...

之后便可以正常编译所有sample,这里以10_camera_recording为例进行编译:

1
cd code/mmapi_samples/10_camera_recording
  • 由于该工程需要用到libagrus中的utils组件,所以需要修改对应的makefile:

    1
    2
    3
    # 修改 ARGUS_UTILS_DIR 路径即可
    # ARGUS_UTILS_DIR := $(TOP_DIR)/argus/samples/utils
    ARGUS_UTILS_DIR := $(TOP_DIR)/argus_samples/utils
  • 之后即可正常make