deepstream-app crashed due to OpenCV assertion

Following instruction https://github.com/NVIDIA-AI-IOT/deepstream_reference_apps/tree/master/sources/samples/objectDetector_YoloV3 to use yolov3 network to perform detection but encountered this problem. Not sure why it didn’t work. Thanks for your help!

Details

libnvtracker: Warning: exceeded max bounding boxes(4) < 4
libnvtracker: Warning: skipping next rectangles…
OpenCV Error: Assertion failed (0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows) in Mat, file /home/shaunakg/opencv-3.4.0-static/opencv-3.4.0/modules/core/src/matrix.cpp, line 538
An exception occurred. /home/shaunakg/opencv-3.4.0-static/opencv-3.4.0/modules/core/src/matrix.cpp:538: error: (-215) 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows in function Mat

Thread 35 “deepstream-app” received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffee63bd700 (LWP 17961)]
strlen () at …/sysdeps/x86_64/strlen.S:106
106 …/sysdeps/x86_64/strlen.S: No such file or directory.
(gdb) bt
#0 strlen () at …/sysdeps/x86_64/strlen.S:106
#1 0x00007fffc332678e in gst_nv_nvtracker_processMultiStream(void*) ()
from /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libnvdsgst_tracker.so
#2 0x00007ffff69dac55 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3 0x00007fffd7b9f6ba in start_thread (arg=0x7ffee63bd700) at pthread_create.c:333
#4 0x00007ffff636d41d in clone () at …/sysdeps/unix/sysv/linux/x86_64/clone.S:109

Config file deepstream_app_config_yoloV3.txt
[application]
enable-perf-measurement=1
perf-measurement-interval-sec=1
gie-kitti-output-dir=streamscl

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

[source0]
enable=1
type=3
num-sources=1
uri=file://…/…/…/…/DeepStream_Release/samples/streams/sample_720p.h264
gpu-id=0

[streammux]
gpu-id=0
batch-size=1
batched-push-timeout=-1
width=1280
height=720
cuda-memory-type=1

[sink0]
enable=1
type=4
codec=1
bitrate=20000
rtsp-port=8554
udp-port=5400
sync=1
source-id=0
gpu-id=0

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

[primary-gie]
enable=1
gpu-id=0
batch-size=1
gie-unique-id=1
interval=0
labelfile-path=labels.txt
model-engine-file=/home/ubuntu/deepstream_reference_apps/data/yolo/yolov3-kFLOAT-batch1.engine
config-file=config_infer_primary_YoloV3.txt

[tracker]
enable=1
tracker-width=640
tracker-height=368
gpu-id=0

The default yolov3 config file has height and width set to - 608
https://github.com/pjreddie/darknet/blob/master/cfg/yolov3.cfg#L8

However for this sample we are considering the height and width to be 416 -
https://github.com/NVIDIA-AI-IOT/deepstream_reference_apps/blob/master/sources/samples/objectDetector_YoloV3/nvdsinfer_custom_impl_YoloV3/nvdsparsebbox_YoloV3.cpp#L289

The issue is happening because of the network input size mismatch. Can you please update your yolov3.cfg file to fix the height and width to 416, regenerate the engine file and then use it with this sample ?

Changing the height and width did the trick. Thanks a lot!