Masking footage over 3d objects in Blender 2.8+?
Load the background image in the image editor or the movie clip editor.

Set the editor in mask mode

On the image, click while pressing the Ctrl key and draw a mask for the area you want to use as foreground.

Then in the compositor use that mask to combine the foreground and background elements.