How to save deepstream output images and detected objects crops using python

I would like to know the steps involved to save the detected object image crops in deepstream.

I am using deepstream-5.0.1 container on a GTX1660 system.

You can refer sample deepstream-image-meta-test for how to save detected object image.