In opencv-python Image stitching How to eliminate the foreground moving objects from multiple images

Assume I have two images (like panorama) and I need to stitch these images together but the moving foreground images of people should not be present in the result image.Only background info should be present.

I am using Sift to detect keypoints and features, identifying the matches, then using getPerspectiveTransform method to find the transformation matrix. Then using warpPerspective method by passing this transformation matrix as one of the arguments and finding the stitched image.

But how do I implement the logic for eliminating the foreground moving object.