DeepStream Can Orientation App#

deepstream-can-orientation-app 示例应用程序位于 app/sample_apps/deepstream-can-orientation-app,供您参考。此示例演示了用于工业罐位置和旋转角度的罐体方向检测。针对原始数据输入、JPEG 输入和 Basler 相机仿真输入设置有多种配置。下图显示了此参考应用程序的架构。

DeepStream VPI Can Orientation Application Architecture

视频模板将加载自定义库 libnvds_vpicanmatch.so,以执行基于 CV 的 VPI 模板匹配,用于工业罐体方向检测。

入门#

先决条件#

  • 转到文件夹 sources/apps/sample_apps/deepstream-can-orientation-app

  • 准备所有测试示例图像和参考图像。运行以下命令将罐体测试图像和参考图像解压缩到文件夹 data 中,并生成原始示例图像数据文件。运行命令

    $ ./prepare_sample_data.sh
    

    注意

    如果存在文件权限问题,请尝试使用 sudo

  • 导出 DISPLAY 环境变量以进行正确的显示。例如:export DISPLAY=:0.0

  • 对于 Basler 相机仿真测试,请按照 deepstream-can-orientation-app/README 中的说明安装和构建所有依赖项。此仿真不需要物理 Basler 相机。

  • 用户可以通过 Pylon Viewer 修改和配置其 Basler 相机以创建新的 PFS,然后在该应用程序中使用它。

运行 DeepStream Can Orientation 示例#

  • 运行 JPEG 文件 EGL 显示测试

    $ deepstream-can-orientation-app -c ds_can_orientation_jpg.yaml
    
  • 运行 GREY 原始数据文件 EGL 显示测试

    $  deepstream-can-orientation-app -c ds_can_orientation_raw.yaml -r data/test_samples_raw.grey
    
  • 运行无显示性能测试。更新 ds_can_orientation_raw.yaml

    sink:
       egl_display: false
       sync: false
     debug:
       print_result: fasle
    
  • 运行性能测试

    $ deepstream-can-orientation-app -c ds_can_orientation_raw.yaml -r data/test_samples_raw.grey -l
    
  • 运行 Basler 相机仿真测试

    $ deepstream-can-orientation-app -c ds_can_orientation_basler_cam.yaml
    

DeepStream Can Orientation App 配置规范#

deepstream-can-orientation-app 设置#

下表指示了 ds_can_orientation_jpg.yamlds_can_orientation_raw.yaml 的组设置。

deepstream can orientation 应用程序设置#

属性

含义

类型和范围

示例

source

源设置

YAML 节点

source

uri

decodebin uri

字符串

uri: multifile:///opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/deepstream-can-orientation-app/data/sample1/test_sample_%2504d.jpg

source

framerate

multifile 源和原始格式数据源的帧率

字符串

framerate: 10/1

source

frame_settings

原始帧设置描述

YAML 节点

frame_settings

format: GREY width: 870 height: 1200

source.frame_settings

format

颜色格式,从 [GREY, RGBA] 中选择

字符串: [GREY, RGBA]

format: GREY

source.frame_settings

width

输入原始帧的宽度

整数: >0

width: 870

source.frame_settings

height

输入原始帧的高度

整数: >0

height: 1200

source

camera

Basler 相机设置

YAML 节点

camera

device_serial_number: 0815-0000 pfs_path: basler_cam_emulation_0815-0000.pfs width: 870 height: 1200

source.camera

device_serial_number

Basler 相机序列号

字符串

device_serial_number: 0815-0000

source.camera

pfs_path

Basler PFS 设置文件路径

字符串

pfs_path: basler_cam_emulation_0815-0000.pfs

source.camera

width

Basler 相机捕获图像宽度

整数: >0

width: 870

source.camera

height

Basler 相机捕获图像高度

整数: >0

height: 1200

video_template

deepstream 视频模板插件设置

YAML 节点

video_template

customlib_name

指示视频模板要加载的自定义库位置

字符串

customlib_name: /opt/nvidia/deepstream/deepstream/lib/libnvds_vpicanmatch.so

video_template

customlib_props

指示自定义库的配置设置

字符串

customlib_props: config-file:config_video_template_can_match.yaml

sink

sink 设置

YAML 节点

sink

egl_display: true

sink

egl_display

指示是否启用 EGL 显示

布尔值

egl_display: true

sink

sync

指示是否对时间戳进行同步

布尔值

sync: true

debug

debug 设置

YAML 节点

debug

print_result

指示是否打印方向结果

布尔值

print_result: true

用于罐体模板匹配的自定义库 libnvds_vpicanmatch.so 设置#

下表指示了 config_video_template_can_match.yaml 的组设置。

deepstream can orientation 应用程序设置#

属性

含义

类型和范围

示例

radius

指示罐体的半径,单位为厘米

浮点数

radius: 3.3

distance

指示从相机到罐体的距离,单位为厘米

浮点数

distance: 12.7

center

指示输入原始图像中罐体的中心,并由宽度归一化

浮点数

center: 0.5

can_width

指示输入原始图像中罐体的宽度,并由宽度归一化

浮点数

can_width: 1.0

input_width

指示输入原始图像的宽度,应为输入图像宽度

Uint32

input_width: 870

input_height

指示输入原始图像的高度,应为输入图像高度

Uint32

input_height: 1200

crop_width

指示要用于与参考图像匹配的解畸变推理图像的宽度

Uint32

crop_width: 500

target_x

指示参考图像中目标中心的像素

Uint32

target_x: 250

ref_image

指定参考图像参数

YAML 节点

ref_image.perimeter

指示参考图像中罐体周长的像素

Uint32

ref_image

perimeter: 1689

ref_image.image_path

指示参考图像路径,必须为颜色格式 GREY

ref_image

image_path: data/reference_sample.grey

ref_image.image_format

指示参考图像颜色格式,此版本仅支持 GREY

字符串: fourcc

ref_image

image_format: GREY

ref_image.image_width

指示参考图像宽度

Uint32

ref_image

image_width: 2508

ref_image.image_height

指示参考图像高度

Uint32

ref_image

image_height: 625

从源代码构建应用程序#

  • 转到文件夹 sources/apps/sample_apps/deepstream-can-orientation-app

  • 运行以下命令

    $ make
    $ make install