이번에는 간단한 DeepStream Config 내용을 좀 더 자세히 들여다 보고 각 세그먼트 그룹에서 설정하는 내용 및 커스텀하게 설정할 수 있는 항목 등을 살펴보겠습니다.

앞서 살펴본 NVIDIA Jetson TX2 DeepStream Example 에서 deepstream-app -c <CONFIG> 와 같은 형태로 DeepStream app 예제를 실행하는 것을 살펴보았습니다.

DeepStream 샘플 애플리케이션을 구동해 보는 것은 어렵지 않고 유익합니다. 하지만 다음에 무엇을 해야 하는지 어려움을 겪을 수도 있습니다. DeepStream 애플리케이션의 구동 원리와 멀티미디어 파이프라인 구성에 대해 이해하는 것이 바로 다음 단계에 살펴보아야 할 내용입니다.

예제 동영상을 제작할 때 사용했던 가장 간단한 config 파일을 이용하도록 하겠습니다. 관련 내용에 대해 더 자세히 살펴보고 싶은 부분이 있다면 NVIDIA 공식 SDK 문서의 Configuration Groups 부분을 참고하시기 바랍니다.

NVIDIA System HW/SW Layer
NVIDIA System HW/SW Layer

Sample DeepStream Config File

DeepStream 예제 config 파일은 다음의 경로에서 찾을 수 있습니다.

$ cd /opt/nvidia/deepstream/deepstream/samples/configs/deepstream-app

디렉토리 내에 여러가지 config 파일이 있습니다. 그 중에서 source1_csi_dec_infer_resnet_int8.txt 파일을 위주로 내용을 살펴보겠습니다. 전체 내용은 아래와 같습니다.

# Copyright (c) 2018 NVIDIA Corporation.  All rights reserved.
#
# NVIDIA Corporation and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto.  Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA Corporation is strictly prohibited.

[application]
enable-perf-measurement=1
perf-measurement-interval-sec=5
#gie-kitti-output-dir=streamscl

[tiled-display]
enable=1
rows=1
columns=1
width=1280
height=720

[source0]
enable=1
#Type - 1=CameraV4L2 2=URI 3=MultiURI 4=RTSP 5=CSI
type=5
camera-width=1280
camera-height=720
camera-fps-n=30
camera-fps-d=1

[sink0]
enable=1
#Type - 1=FakeSink 2=EglSink 3=File 4=RTSPStreaming 5=Overlay
type=5
sync=0
display-id=0
offset-x=0
offset-y=0
width=0
height=0
overlay-id=1
source-id=0

[sink1]
enable=0
type=3
#1=mp4 2=mkv
container=1
#1=h264 2=h265 3=mpeg4
codec=1
#encoder type 0=Hardware 1=Software
enc-type=0
sync=0
bitrate=2000000
#H264 Profile - 0=Baseline 2=Main 4=High
#H265 Profile - 0=Main 1=Main10
profile=0
output-file=out.mp4
source-id=0

[sink2]
enable=0
#Type - 1=FakeSink 2=EglSink 3=File 4=RTSPStreaming 5=Overlay
type=4
#1=h264 2=h265
codec=1
#encoder type 0=Hardware 1=Software
enc-type=0
sync=0
bitrate=4000000
#H264 Profile - 0=Baseline 2=Main 4=High
#H265 Profile - 0=Main 1=Main10
profile=0
# set below properties in case of RTSPStreaming
rtsp-port=8554
udp-port=5400

[osd]
enable=1
border-width=2
text-size=15
text-color=1;1;1;1;
text-bg-color=0.3;0.3;0.3;1
font=Serif
show-clock=0
clock-x-offset=800
clock-y-offset=820
clock-text-size=12
clock-color=1;0;0;0

[streammux]
##Boolean property to inform muxer that sources are live
live-source=1
batch-size=1
##time out in usec, to wait after the first buffer is available
##to push the batch even if the complete batch is not formed
batched-push-timeout=40000
## Set muxer output width and height
width=1280
height=720
## If set to TRUE, system timestamp will be attached as ntp timestamp
## If set to FALSE, ntp timestamp from rtspsrc, if available, will be attached
# attach-sys-ts-as-ntp=1

# config-file property is mandatory for any gie section.
# Other properties are optional and if set will override the properties set in
# the infer config file.
[primary-gie]
enable=1
model-engine-file=../../models/Primary_Detector/resnet10.caffemodel_b30_gpu0_int8.engine
#Required to display the PGIE labels, should be added even when using config-file
#property
batch-size=1
#Required by the app for OSD, not a plugin property
bbox-border-color0=1;0;0;1
bbox-border-color1=0;1;1;1
bbox-border-color2=0;0;1;1
bbox-border-color3=0;1;0;1
interval=0
#Required by the app for SGIE, when used along with config-file property
gie-unique-id=1
config-file=config_infer_primary.txt

[tests]
file-loop=0

개략적으로 봤을 때 Application, Tiled Display, Source, Sink, OSD, StreamMux, Primary GIE, Tests 와 같은 그룹으로 설정이 구분되어 있는 것을 확인할 수 있습니다.

DeepStream Config Application Group

[application]
enable-perf-measurement=1
perf-measurement-interval-sec=5
#gie-kitti-output-dir=streamscl
설정키의미
enable-perf-measurement응용 프로그램 성능 측정이 활성화되어 있는지 여부를 나타냅니다.
perf-measurement-interval-sec성능 샘플링과 출력 간격을 초 단위로 설정합니다.
Application Group 설정 항목별 의미

DeepStream Config Tiled Display Group

[tiled-display]
enable=1
rows=1
columns=1
width=1280
height=720
설정키의미
enable타일 디스플레이 활성화 설정. 0=disabled, 1=enabled, 2= tiler-and-parallel-demux-to-sink-enabled
rows타일 디스플레이의 행 개수
columns타일 디스플레이의 열 개수
width해상도 가로 픽셀 수
height해상도 세로 픽셀 수
Tiled-Display Group 설정 항목별 의미

DeepStream Config Source Group

Source와 Sink Group은 가장 유명한 open source multimedia framework 중 하나인 GStreamer 에서 사용하고 있는 개념으로부터 가져왔습니다. GStreamer 에서 가장 단순한 Multimedia Pipeline은 Source에서 데이터를 생산하고, 복수의 Filter를 거치며 데이터가 가공이 되고, Sink에서 데이터가 소모되는 형태로 구성됩니다. 자세한 내용은 별도의 글에서 한번 다루도록 하겠습니다. DeepStream 도 GStreamer와 동일한 형태로 구성되어 있습니다. Source Group부터 살펴보겠습니다.

[source0]
enable=1
#Type - 1=CameraV4L2 2=URI 3=MultiURI 4=RTSP 5=CSI
type=5
camera-width=1280
camera-height=720
camera-fps-n=30
camera-fps-d=1
설정키의미
enableSource 활성화 설정. Set enable=1
typeSource type. 1=Camera V4L2, 2=URI, 3=MultiURI, 4=RTSP, 5=CSI
5 CSI 카메라는 Jetson에서만 사용할 수 있음.
camera-width카메라로부터 캡쳐하는 프레임의 가로 픽셀 수.
V4L2 또는 CSI 카메라 type에서만 사용할 수 있음.
camera-height카메라로부터 캡쳐하는 프레임의 세로 픽셀 수.
V4L2 또는 CSI 카메라 type에서만 사용할 수 있음.
camera-fps-n카메라로부터 캡쳐하는 frame rate 프레임 수.
camera-fps-d카메라로부터 캡쳐하는 frame rate 기준 시간.
Source Group

설정키 중 camera-fps-n과 camera-fps-d는 capture frame rate를 설정하는 항목입니다. 예를 들어 1초에 30 프레임을 캡쳐하기 위해서 N은 30, D는 1로 설정합니다.

Sink Group (Overlay)

[sink0]
enable=1
#Type - 1=FakeSink 2=EglSink 3=File 4=RTSPStreaming 5=Overlay
type=5
sync=0
display-id=0
offset-x=0
offset-y=0
width=0
height=0
overlay-id=1
source-id=0
설정키의미
enableSink 활성화 설정. Set enable=1
type1=Fake Sink, 아무 동작하지 않음
2=Egl Sink, EGL 기반 윈도우 형태 Sink
3=File Sink, 영상 출력을 파일로 저장
4=RTSP Streaming, 영상 출력을 RTSP 프로토콜로 스트리밍
5=Overlay, Jetson 전용 type으로 Ubuntu UI 위에 overlay 출력
syncStream Render 유형 설정. 0=가능한 빠르게 렌더링, 1=싱크 맞춰서 렌더링
display-idOverlay 유형의 sink에서만 유효. Display HEAD의 ID 설정
offset-x렌더러 윈도우의 가로 픽셀 오프셋
offset-y렌더러 윈도우의 세로 픽셀 오프셋
width렌더러 가로 픽셀 수
height렌더러 세로 픽셀 수
overlay-idHEAD 0 Overlay의 인덱스, HEAD 0 오버레이 개수보다 크게 설정하면 안됨
source-id연결하고자 하는 source 그룹의 이름에 달려 있는 숫자. [source1] 이면 source-id=1
Overlay Type의 Sink Group

Sink Group (File)

[sink1]
enable=0
type=3
#1=mp4 2=mkv
container=1
#1=h264 2=h265 3=mpeg4
codec=1
#encoder type 0=Hardware 1=Software
enc-type=0
sync=0
bitrate=2000000
#H264 Profile - 0=Baseline 2=Main 4=High
#H265 Profile - 0=Main 1=Main10
profile=0
output-file=out.mp4
source-id=0
설정키의미
container영상 파일 컨테이너 유형 설정. 1=mp4, 2=mkv
codec영상 인코딩 코덱 유형 설정. 1=h.264, 2=h.265, 3=mpeg4
enc-type인코더 유형 설정. 1=하드웨어 인코더(전용HW블록), 2=소프트웨어 인코더(ARM)
bitrate인코딩 비트레이트
profile인코딩 프로파일
H.264의 경우 0=Baseline, 2=Main, 4=High
H.265의 경우 0=Main, 1=Main10
output-file저장하고자 하는 파일의 경로
File Sink Group

Sink Group (RTSP Stream)

[sink2]
enable=0
#Type - 1=FakeSink 2=EglSink 3=File 4=RTSPStreaming 5=Overlay
type=4
#1=h264 2=h265
codec=1
#encoder type 0=Hardware 1=Software
enc-type=0
sync=0
bitrate=4000000
#H264 Profile - 0=Baseline 2=Main 4=High
#H265 Profile - 0=Main 1=Main10
profile=0
# set below properties in case of RTSPStreaming
rtsp-port=8554
udp-port=5400
설정키의미
rtsp-portRTSP 스트리밍하기 위한 서비스 포트
udp-port내부용 포트
RTSP Sink Group
[osd]
enable=1
border-width=2
text-size=15
text-color=1;1;1;1;
text-bg-color=0.3;0.3;0.3;1
font=Serif
show-clock=0
clock-x-offset=800
clock-y-offset=820
clock-text-size=12
clock-color=1;0;0;0

OSD Group

설정키의미
border-width경계박스의 굵기
text-color객체 설명 글자색. RGBA 순서로 0~1 사이의 소수를 ;으로 구분하여 설정
show-clock영상 프레임에 Clock 시간을 overlay할지 설정
OSD Group

Stream Mux Group

Mux는 Multiplexer를 축약해서 부르는 말입니다. 일반적으로 복수개의 입력을 기반으로 하나의 출력을 만들어주는 필터 유형을 Mux로 정의합니다. 반대로 하나의 입력을 이용해 여러 개의 출력을 발생시키는 필터 유형은 Demux라고 합니다.

예를 들어 4개의 영상 입력을 받아서 Scaling과 Transcoding을 거쳐 Mosaic 형태의 하나의 영상을 출력하는 필터가 있다면 이는 Mux라고 할 수 있습니다.

만약 하나의 영상 입력을 받아서 영상, 음성, 자막 Stream을 분리하여 각각의 출력을 내보내는 필터가 있다면 이는 Demux라고 할 수 있습니다.

[streammux]
##Boolean property to inform muxer that sources are live
live-source=1
batch-size=1
##time out in usec, to wait after the first buffer is available
##to push the batch even if the complete batch is not formed
batched-push-timeout=40000
## Set muxer output width and height
width=1280
height=720
## If set to TRUE, system timestamp will be attached as ntp timestamp
## If set to FALSE, ntp timestamp from rtspsrc, if available, will be attached
# attach-sys-ts-as-ntp=1

# config-file property is mandatory for any gie section.
# Other properties are optional and if set will override the properties set in
# the infer config file.
설정키의미
live-sourceSource가 live인지 설정.
batch-sizeMuxer 배치 사이즈.
batched-push-timeoutusec 단위 timeout. 첫번째 버퍼를 내보내고 다음 batch를 푸시하기 위해 기다리는 최대 시간.
Streammux

GIE group

DeepStream 응용 프로그램은 여러 보조 GIE를 지원합니다. 각 보조 GIE에 대해 이름이 secondary-gie[n] 인 별도의 그룹을 구성 파일에 추가해야합니다. 예를 들면 다음과 같습니다.

[primary-gie]
key1=value1
key2=value2
...
 
[secondary-gie1]
key1=value1
key2=value2
...
[primary-gie]
enable=1
model-engine-file=../../models/Primary_Detector/resnet10.caffemodel_b30_gpu0_int8.engine
#Required to display the PGIE labels, should be added even when using config-file
#property
batch-size=1
#Required by the app for OSD, not a plugin property
bbox-border-color0=1;0;0;1
bbox-border-color1=0;1;1;1
bbox-border-color2=0;0;1;1
bbox-border-color3=0;1;0;1
interval=0
#Required by the app for SGIE, when used along with config-file property
gie-unique-id=1
config-file=config_infer_primary.txt
설정키의미
model-engine-fileSerialize 된 엔진 모델 파일의 경로
batch-size한번에 추론하는 프레임 개수
box-border-color[n]R;G;B;A 컬러 weight를 각각 0~1 로 설정
interval모든 batch에 대해 추론하지 않고자 할 때 설정.
한번 추론한 뒤 몇 번의 batch를 건너뛸 것인지 설정.
gie-unique-idnvinfer 인스턴스에 할당 할 고유 구성 요소 ID.
인스턴스에서 생성 된 메타 데이터를 식별하는 데 사용됨.
config-filegst-nvinfer 플러그인의 속성을 지정하는 구성 파일의 경로
GIE Group

이 외에도 플러그인의 cap을 비롯해 property, 입출력 등 다양한 가변 요소가 config로 빠져 있으므로, 필요한 부분은 NVIDIA DeepStream SDK Developer Guide 문서를 참고하여 스터디하는 것이 좋습니다.


Jay

Jay

S/W Engineer!!

0개의 댓글

답글 남기기

Avatar placeholder