Skip to navigation

DeepStream Can Orientation App

View as Markdown

The deepstream-can-orientation-app sample application is provided at app/sample_apps/deepstream-can-orientation-app for your reference. This example demonstrates can orientation detection for industrial can position and rotation angles. There are several configurations for raw data input, JPEG input and Basler camera emulation input settings. The image below shows the architecture of this reference app.

DeepStream VPI Can Orientation Application Architecture

Getting Started

Prerequisites

  • Go to the folder sources/apps/sample_apps/deepstream-can-orientation-app
  • Prepare all test sample images and reference images. Run the following command to un-compress can test and reference images into folder data, and generate raw sample image data files. Run command
$ ./prepare_sample_data.sh

If there is file permission issues, try with sudo.

  • Export DISPLAY environment to correct display. e.g. export DISPLAY=:0.0.
  • For Basler camera emulation test, follow instructions in deepstream-can-orientation-app/README to install and build all dependencies. This emulation does not require a physical Basler camera.
  • Users can modify and configure their Basler cameras through Pylon Viewer to create new PFS and then use it in this app.

Run DeepStream Can Orientation Examples

  • Run tests for JPEG files with EGL display:
$ deepstream-can-orientation-app -c ds_can_orientation_jpg.yaml
  • Run tests for GREY raw datafile with EGL display:
$ deepstream-can-orientation-app -c ds_can_orientation_raw.yaml -r data/test_samples_raw.grey
  • Run tests for performance tests without display. Update ds_can_orientation_raw.yaml.
sink:
egl_display: false
sync: false
debug:
print_result: false
  • Run performance tests:
$ deepstream-can-orientation-app -c ds_can_orientation_raw.yaml -r data/test_samples_raw.grey -l
  • Run Basler Camera Emulation tests:
$ deepstream-can-orientation-app -c ds_can_orientation_basler_cam.yaml

DeepStream Can Orientation App Configuration Specifications

deepstream-can-orientation-app settings

The table below indicates the group settings for ds_can_orientation_jpg.yaml and ds_can_orientation_raw.yaml.

deepstream can orientation application settings

GroupPropertyMeaningType and RangeExample
sourcesource settingsYAML node
sourceuridecodebin uristringuri: multifile:///opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/deepstream-can-orientation-app/data/sample1/test_sample_%2504d.jpg
sourceframerateframerate for multifile source and raw format data sourcestringframerate: 10/1
sourceframe_settingsRaw frame setting descriptionYAML nodeframe_settings:
format: GREY
width: 870
height: 1200
source.frame_settingsformatcolor format, choose from [GREY, RGBA]String: [GREY, RGBA]format: GREY
source.frame_settingswidthwidth of input raw frameInteger: >0width: 870
source.frame_settingsheightheight of input raw frameInteger: >0height: 1200
sourcecameraBasler camera settingsYAML nodecamera:
device_serial_number: 0815-0000
pfs_path: basler_cam_emulation_0815-0000.pfs
width: 870
height: 1200
source.cameradevice_serial_numberBasler camera serial numberStringdevice_serial_number: 0815-0000
source.camerapfs_pathBasler PFS setting file pathStringpfs_path: basler_cam_emulation_0815-0000.pfs
source.camerawidthBasler camera capture image widthInteger: >0width: 870
source.cameraheightBasler camera capture image heightInteger: >0height: 1200
video_templatedeepstream video template plugin settingsYAML node
video_templatecustomlib_nameIndicate custom-lib location for video template to loadStringcustomlib_name: /opt/nvidia/deepstream/deepstream/lib/libnvds_vpicanmatch.so
video_templatecustomlib_propsIndicate the configuration settings for the custom-libStringcustomlib_props: config-file:config_video_template_can_match.yaml
sinksink settingsYAML nodesink:
egl_display: true
sinkegl_displayIndicate whether enable EGL displayboolegl_display: true
sinksyncIndicate whether do snchronization on timestampboolsync: true
debugdebug settingsYAML node
debugprint_resultIndicate whether print orientation resultboolprint_result: true

Custom lib libnvds_vpicanmatch.so Settings for Can Template Matching

Custom lib libnvds_vpicanmatch.so Settings for Can Template Matching

The table below indicates the group settings for config_video_template_can_match.yaml.

deepstream can orientation application settings

PropertyMeaningType and RangeExample
radiusIndicate radius of the can, unit in cmFloatradius: 3.3
distanceIndicate distance from camera to can, unit in cmFloatdistance: 12.7
centerIndicate center of the can in input raw image normalized by widthFloatcenter: 0.5
can_widthIndicate width of the can in input raw image normalized by widthFloatcan_width: 1.0
input_widthIndicate width of input raw image, It should be the input image widthUint32input_width: 870
input_heightIndicate height of input raw image, It should be the input image heightUint32input_height: 1200
crop_widthIndicate width of dewarped inference image to be used to match with reference imageUint32crop_width: 500
target_xIndicate target center in reference image in pixelsUint32target_x: 250
ref_imageSpecify reference image parametersYAML node
ref_image.perimeterIndicate can circumference in reference image in pixelsUint32ref_image:
perimeter: 1689
ref_image.image_pathIndicate reference image path, must be in color format GREYref_image:
image_path: data/reference_sample.grey
ref_image.image_formatIndicate reference image color format, only GREY supported in this versionString: fourccref_image:
image_format: GREY
ref_image.image_widthIndicate reference image widthUint32ref_image:
image_width: 2508
ref_image.image_heightIndicate reference image heightUint32ref_image:
image_height: 625

Build application From Source

  • Go to the folder sources/apps/sample_apps/deepstream-can-orientation-app.
  • Run the following commands:
$ make
$ make install