You can refer this sample at /opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/deepstream-image-meta-test/deepstream_image_meta_test.c
.
The nvds_obj_enc_process
can encode objects into jpeg images. However, there is no corresponding python binding for this function, so you need to do it yourself.
Do you mean memory leak? You can use valgrind
to check it.